diff --git a/.github/workflows/darwin-tests.yaml b/.github/workflows/darwin-tests.yaml index d4db7d1ce0f289..288166dfb87130 100644 --- a/.github/workflows/darwin-tests.yaml +++ b/.github/workflows/darwin-tests.yaml @@ -106,6 +106,7 @@ jobs: run: | ./scripts/run_in_build_env.sh \ "./scripts/tests/run_test_suite.py \ + --runner darwin_framework_tool_python \ --chip-tool ./out/darwin-x64-darwin-framework-tool-${BUILD_VARIANT_FRAMEWORK_TOOL}/darwin-framework-tool \ --target-skip-glob '{TestAccessControlConstraints}' \ run \ diff --git a/.github/workflows/darwin.yaml b/.github/workflows/darwin.yaml index 55526db1ccfc4b..2d7443f9e9758c 100644 --- a/.github/workflows/darwin.yaml +++ b/.github/workflows/darwin.yaml @@ -123,6 +123,13 @@ jobs: run: | xcodebuild -target "MatterTvCastingBridge" -sdk iphoneos working-directory: examples/tv-casting-app/darwin/MatterTvCastingBridge + - name: Uploading .ips files in Xcode derived data to debug the failure + uses: actions/upload-artifact@v4 + if: ${{ failure() && !env.ACT }} + with: + name: darwin-framework-derived-data + path: ~/Library/Developer/Xcode/DerivedData/**/*.ips + retention-days: 5 - name: Uploading log files uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} diff --git a/.github/workflows/issue-labeler.yaml b/.github/workflows/issue-labeler.yaml index e7819c57f20b84..8c3df4cdb40399 100644 --- a/.github/workflows/issue-labeler.yaml +++ b/.github/workflows/issue-labeler.yaml @@ -11,7 +11,7 @@ jobs: triage: runs-on: ubuntu-latest steps: - - uses: github/issue-labeler@v3.3 #May not be the latest version + - uses: github/issue-labeler@v3.4 #May not be the latest version with: configuration-path: .github/issue-labeler.yml not-before: 2020-01-15T02:54:32Z diff --git a/.github/workflows/kotlin-style.yaml b/.github/workflows/kotlin-style.yaml index 08bade12d21963..2f8df6f486123b 100644 --- a/.github/workflows/kotlin-style.yaml +++ b/.github/workflows/kotlin-style.yaml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v4 - name: "detekt" - uses: natiginfo/action-detekt-all@1.23.4 + uses: natiginfo/action-detekt-all@1.23.5 # Detekt seems not to like circular symlinks, so we set up # explicit paths below with: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index bdfb51adeec423..61db68f0233509 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -118,6 +118,7 @@ jobs: src/app/zap-templates/zcl/data-model/chip/diagnostic-logs-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/dishwasher-alarm-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/dishwasher-mode-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/measurement-and-sensing.xml \ src/app/zap-templates/zcl/data-model/chip/microwave-oven-mode-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/microwave-oven-control-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/door-lock-cluster.xml \ @@ -154,6 +155,7 @@ jobs: src/app/zap-templates/zcl/data-model/chip/operational-state-oven-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/oven-mode-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/power-topology-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/pressure-measurement-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/power-source-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/power-source-configuration-cluster.xml \ @@ -194,6 +196,8 @@ jobs: src/app/zap-templates/zcl/data-model/draft/onoff-switch-configuration-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/resource-monitoring-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/electrical-power-measurement-cluster.xml \ " - name: Build Apps run: | @@ -459,8 +463,8 @@ 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RR_1_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_DeviceBasicComposition.py" --script-args "--storage-path admin_storage.json --manual-code 10054912339 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_SC_3_6.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_DA_1_7.py" --script-args "--storage-path admin_storage.json --bool-arg allow_sdk_dac:true --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_TestEventTrigger.py" --script-args "--storage-path admin_storage.json --bool-arg allow_sdk_dac:true --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_ACE_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_ACE_1_3.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' @@ -469,20 +473,20 @@ 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TestGroupTableReports.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TestBatchInvoke.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_TIMESYNC_2_1.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_TIMESYNC_2_2.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_TIMESYNC_2_4.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_TIMESYNC_2_5.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_TIMESYNC_2_6.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_TIMESYNC_2_7.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_TIMESYNC_2_8.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_TIMESYNC_2_9.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_TIMESYNC_2_10.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_TIMESYNC_2_11.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_TIMESYNC_2_12.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_TIMESYNC_2_13.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_TIMESYNC_3_1.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_DGGEN_2_4.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_TIMESYNC_2_1.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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_TIMESYNC_2_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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_TIMESYNC_2_4.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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_TIMESYNC_2_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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_TIMESYNC_2_6.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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_TIMESYNC_2_7.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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_TIMESYNC_2_8.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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_TIMESYNC_2_9.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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_TIMESYNC_2_10.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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_TIMESYNC_2_11.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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_TIMESYNC_2_12.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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_TIMESYNC_2_13.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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_TIMESYNC_3_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_DGGEN_2_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lit-icd-ipv6only-no-ble-no-wifi-tsan-clang-test/lit-icd-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_ICDM_2_1.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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_IDM_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' @@ -495,15 +499,15 @@ 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_5.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCCLEANM_1_2.py" --script-args "--int-arg PIXIT_ENDPOINT:1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCRUNM_1_2.py" --script-args "--int-arg PIXIT_ENDPOINT:1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestMatterTestingSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestConformanceSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestSpecParsingSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lock-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-lock-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_DRLK_2_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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lock-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-lock-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_DRLK_2_3.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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lock-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-lock-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_DRLK_2_12.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 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + 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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_AccessChecker.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lock-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-lock-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_DeviceConformance.py" --script-args "--storage-path admin_storage.json --manual-code 10054912339 --bool-arg ignore_in_progress:True allow_provisional:True --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto --tests test_TC_IDM_10_2"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestMatterTestingSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestConformanceSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestSpecParsingSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/TestTimeSyncTrustedTimeSourceRunner.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_AccessChecker.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-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TC_DeviceConformance.py" --app out/linux-x64-lock-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-lock-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--storage-path admin_storage.json --manual-code 10054912339 --bool-arg ignore_in_progress:True allow_provisional:True --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto --tests test_TC_IDM_10_2"' - name: Uploading core files uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} diff --git a/BUILD.gn b/BUILD.gn index b51ab7238414e9..89861ea79af5d0 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -16,7 +16,6 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") import("//build_overrides/mbedtls.gni") import("//build_overrides/nlassert.gni") -import("//build_overrides/nlio.gni") import("//build_overrides/nlunit_test.gni") import("//build_overrides/pigweed.gni") @@ -136,7 +135,6 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { "${chip_root}/src/system", "${chip_root}/src/transport", "${nlassert_root}:nlassert", - "${nlio_root}:nlio", "${nlunit_test_root}:nlunit-test", ] diff --git a/config/esp32/components/chip/CMakeLists.txt b/config/esp32/components/chip/CMakeLists.txt index a3ad2d9c438619..7f62ce6cc0087a 100644 --- a/config/esp32/components/chip/CMakeLists.txt +++ b/config/esp32/components/chip/CMakeLists.txt @@ -185,6 +185,12 @@ if ((CONFIG_BT_ENABLED) AND (CONFIG_ENABLE_CHIPOBLE)) endif() endif() +if (CONFIG_ENABLE_PERSIST_SUBSCRIPTIONS) + chip_gn_arg_append("chip_persist_subscriptions" "true") +else() + chip_gn_arg_append("chip_persist_subscriptions" "false") +endif() + if (CONFIG_ENABLE_ESP32_BLE_CONTROLLER) chip_gn_arg_append("chip_enable_ble_controller" "true") endif() diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index 8ba2c1b3986e15..0dce48b5f720be 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -130,6 +130,13 @@ menu "CHIP Core" help Some device types don't require the read client. Enabling this option may save some flash/ram. + config ENABLE_PERSIST_SUBSCRIPTIONS + bool "Enable persist subscriptions" + default y + help + Enable persist subscriptions to make the device resume the subscriptions from the persist + subscriptions information after reboot. + config BUILD_CHIP_TESTS bool "Build CHIP tests" default n @@ -202,6 +209,13 @@ menu "CHIP Core" help Enable this option to use LwIP default IPv6 route hook for Route Information Option(RIO) feature. + config ENABLE_ENDPOINT_QUEUE_FILTER + bool "Enable UDP Endpoint queue filter for mDNS Broadcast packets" + depends on USE_MINIMAL_MDNS + default y + help + Enable this option to start a UDP Endpoint queue filter for mDNS Broadcast packets + config ENABLE_LWIP_THREAD_SAFETY bool "Enable LwIP Thread safety options" default y @@ -1038,6 +1052,12 @@ menu "CHIP Device Layer" endmenu + config CHIP_ENABLE_BDX_LOG_TRANSFER + bool "Enable BDX log transfer" + default n + help + Enables the BDX protocol for diagnostics log transfer + menu "Matter OTA Image" config CHIP_OTA_IMAGE_BUILD diff --git a/config/telink/chip-module/Kconfig b/config/telink/chip-module/Kconfig index 1148af804eee0b..b76e3962d2efbe 100644 --- a/config/telink/chip-module/Kconfig +++ b/config/telink/chip-module/Kconfig @@ -216,6 +216,10 @@ config CHIP_ENABLE_POWER_ON_FACTORY_RESET first 5 seconds after power on and this sequence repeated 5 times - factory reset will be involved. +config CHIP_TASK_STACK_SIZE + int + default 8192 + config CHIP_USE_MARS_SENSOR bool "Use Mars board sensor" depends on SOC_SERIES_RISCV_TELINK_B9X && (BOARD_TLSR9518ADK80D || BOARD_TLSR9518ADK80D_RETENTION) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index c4ccd625b9cda7..0a71d5a53feaba 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -211,7 +211,7 @@ config SETTINGS_NVS_SECTOR_SIZE_MULT # Set sector counter of NVS config SETTINGS_NVS_SECTOR_COUNT - default 10 + default 12 # Enable OpenThread @@ -329,4 +329,7 @@ config PWM_SHELL config OPENTHREAD_SHELL default n +config CHIP_TASK_STACK_SIZE + default 4864 if PM + endif diff --git a/docs/clusters.md b/docs/clusters.md index 28a817e0a044a9..eb3dfde53abb80 100644 --- a/docs/clusters.md +++ b/docs/clusters.md @@ -77,12 +77,14 @@ Generally regenerate using one of: | 114 | 0x72 | ActivatedCarbonFilterMonitoring | | 128 | 0x80 | BooleanStateConfiguration | | 129 | 0x81 | ValveConfigurationAndControl | +| 144 | 0x90 | ElectricalPowerMeasurement | | 145 | 0x91 | ElectricalEnergyMeasurement | | 150 | 0x96 | DemandResponseLoadControl | | 151 | 0x97 | Messages | | 152 | 0x98 | DeviceEnergyManagement | | 153 | 0x99 | EnergyEvse | | 155 | 0x9B | EnergyPreference | +| 156 | 0x9C | PowerTopology | | 157 | 0x9D | EnergyEvseMode | | 159 | 0x9F | DeviceEnergyManagementMode | | 257 | 0x101 | DoorLock | diff --git a/docs/guides/BUILDING.md b/docs/guides/BUILDING.md index 89e657f834a350..8e32d6dc4a3c66 100644 --- a/docs/guides/BUILDING.md +++ b/docs/guides/BUILDING.md @@ -94,6 +94,33 @@ Complete the following steps: 1. Reboot your Raspberry Pi after installing `pi-bluetooth`. +#### Enable experimental Bluetooth support in BlueZ + +The Matter application on Linux uses BlueZ to communicate with the Bluetooth +controller. The BlueZ version that comes with Ubuntu 22.04 does not support all +the features required by the Matter application by default. To enable these +features, you need to enable experimental Bluetooth support in BlueZ. + +1. Edit the `bluetooth.service` unit by running the following command: + + ```sh + sudo systemctl edit bluetooth.service + ``` + +1. Add the following content to the override file: + + ```ini + [Service] + ExecStart= + ExecStart=/usr/lib/bluetooth/bluetoothd -E + ``` + +1. Restart the Bluetooth service by running the following command: + + ```sh + sudo systemctl restart bluetooth.service + ``` + #### Configuring wpa_supplicant for storing permanent changes By default, wpa_supplicant is not allowed to update (overwrite) configuration. diff --git a/examples/air-purifier-app/air-purifier-common/README.md b/examples/air-purifier-app/air-purifier-common/README.md new file mode 100644 index 00000000000000..2ed26cacf9a229 --- /dev/null +++ b/examples/air-purifier-app/air-purifier-common/README.md @@ -0,0 +1,353 @@ +# CHIP Air Purifier Example + +This example implements the following PICS: + +``` +# Fan Control +FAN.S=1 +FAN.C=0 +FAN.S.F00=1 +FAN.S.F01=1 +FAN.S.F02=1 +FAN.S.F03=1 +FAN.S.F04=1 +FAN.S.F05=1 +FAN.S.A0000=1 +FAN.S.A0001=1 +FAN.S.A0002=1 +FAN.S.A0003=1 +FAN.S.A0004=1 +FAN.S.A0005=1 +FAN.S.A0006=1 +FAN.S.A0007=1 +FAN.S.A0008=1 +FAN.S.A0009=1 +FAN.S.A000A=1 +FAN.S.A000B=1 +FAN.S.C00.Rsp=1 + +# HEPA Filter Monitoring Cluster +HEPAFREMON.S=1 +HEPAFREMON.C=0 +HEPAFREMON.S.F00=1 +HEPAFREMON.S.F01=1 +HEPAFREMON.S.F02=1 +HEPAFREMON.S.A0000=1 +HEPAFREMON.S.A0001=1 +HEPAFREMON.S.A0002=1 +HEPAFREMON.S.A0003=1 +HEPAFREMON.S.A0004=1 +HEPAFREMON.S.A0005=1 +HEPAFREMON.S.C00.Rsp=1 + +# Activated Carbon Filter Monitoring Cluster +ACFREMON.S=1 +ACFREMON.C=0 +ACFREMON.S.F00=1 +ACFREMON.S.F01=1 +ACFREMON.S.F02=1 +ACFREMON.S.A0000=1 +ACFREMON.S.A0001=1 +ACFREMON.S.A0002=1 +ACFREMON.S.A0003=1 +ACFREMON.S.A0004=1 +ACFREMON.S.A0005=1 +ACFREMON.S.C00.Rsp=1 + +# Air Quality Cluster +AIRQUAL.C=0 +AIRQUAL.S=1 +AIRQUAL.S.F00=1 +AIRQUAL.S.F01=1 +AIRQUAL.S.F02=1 +AIRQUAL.S.F03=1 +AIRQUAL.S.A0000=1 +AIRQUAL.M.AirQualityChange=0 + +# Concentration Measurement CLusters +CDOCONC.C=0 +CDOCONC.S=1 +CDOCONC.S.F00=1 +CDOCONC.S.F01=1 +CDOCONC.S.F02=1 +CDOCONC.S.F03=1 +CDOCONC.S.F04=1 +CDOCONC.S.F05=1 +CDOCONC.S.A0000=1 +CDOCONC.S.A0001=1 +CDOCONC.S.A0002=1 +CDOCONC.S.A0003=1 +CDOCONC.S.A0004=1 +CDOCONC.S.A0005=1 +CDOCONC.S.A0006=1 +CDOCONC.S.A0007=1 +CDOCONC.S.A0008=1 +CDOCONC.S.A0009=1 +CDOCONC.S.A000a=1 + +CMOCONC.C=0 +CMOCONC.S=1 +CMOCONC.S.F00=1 +CMOCONC.S.F01=1 +CMOCONC.S.F02=1 +CMOCONC.S.F03=1 +CMOCONC.S.F04=1 +CMOCONC.S.F05=1 +CMOCONC.S.A0000=1 +CMOCONC.S.A0001=1 +CMOCONC.S.A0002=1 +CMOCONC.S.A0003=1 +CMOCONC.S.A0004=1 +CMOCONC.S.A0005=1 +CMOCONC.S.A0006=1 +CMOCONC.S.A0007=1 +CMOCONC.S.A0008=1 +CMOCONC.S.A0009=1 +CMOCONC.S.A000a=1 + +NDOCONC.C=0 +NDOCONC.S=1 +NDOCONC.S.F00=1 +NDOCONC.S.F01=1 +NDOCONC.S.F02=1 +NDOCONC.S.F03=1 +NDOCONC.S.F04=1 +NDOCONC.S.F05=1 +NDOCONC.S.A0000=1 +NDOCONC.S.A0001=1 +NDOCONC.S.A0002=1 +NDOCONC.S.A0003=1 +NDOCONC.S.A0004=1 +NDOCONC.S.A0005=1 +NDOCONC.S.A0006=1 +NDOCONC.S.A0007=1 +NDOCONC.S.A0008=1 +NDOCONC.S.A0009=1 +NDOCONC.S.A000a=1 + +OZCONC.C=0 +OZCONC.S=1 +OZCONC.S.F00=1 +OZCONC.S.F01=1 +OZCONC.S.F02=1 +OZCONC.S.F03=1 +OZCONC.S.F04=1 +OZCONC.S.F05=1 +OZCONC.S.A0000=1 +OZCONC.S.A0001=1 +OZCONC.S.A0002=1 +OZCONC.S.A0003=1 +OZCONC.S.A0004=1 +OZCONC.S.A0005=1 +OZCONC.S.A0006=1 +OZCONC.S.A0007=1 +OZCONC.S.A0008=1 +OZCONC.S.A0009=1 +OZCONC.S.A000a=1 + +PMICONC.C=0 +PMICONC.S=1 +PMICONC.S.F00=1 +PMICONC.S.F01=1 +PMICONC.S.F02=1 +PMICONC.S.F03=1 +PMICONC.S.F04=1 +PMICONC.S.F05=1 +PMICONC.S.A0000=1 +PMICONC.S.A0001=1 +PMICONC.S.A0002=1 +PMICONC.S.A0003=1 +PMICONC.S.A0004=1 +PMICONC.S.A0005=1 +PMICONC.S.A0006=1 +PMICONC.S.A0007=1 +PMICONC.S.A0008=1 +PMICONC.S.A0009=1 +PMICONC.S.A000a=1 + +FLDCONC.C=0 +FLDCONC.S=1 +FLDCONC.S.F00=1 +FLDCONC.S.F01=1 +FLDCONC.S.F02=1 +FLDCONC.S.F03=1 +FLDCONC.S.F04=1 +FLDCONC.S.F05=1 +FLDCONC.S.A0000=1 +FLDCONC.S.A0001=1 +FLDCONC.S.A0002=1 +FLDCONC.S.A0003=1 +FLDCONC.S.A0004=1 +FLDCONC.S.A0005=1 +FLDCONC.S.A0006=1 +FLDCONC.S.A0007=1 +FLDCONC.S.A0008=1 +FLDCONC.S.A0009=1 +FLDCONC.S.A000a=1 + +PMHCONC.C=0 +PMHCONC.S=1 +PMHCONC.S.F00=1 +PMHCONC.S.F01=1 +PMHCONC.S.F02=1 +PMHCONC.S.F03=1 +PMHCONC.S.F04=1 +PMHCONC.S.F05=1 +PMHCONC.S.A0000=1 +PMHCONC.S.A0001=1 +PMHCONC.S.A0002=1 +PMHCONC.S.A0003=1 +PMHCONC.S.A0004=1 +PMHCONC.S.A0005=1 +PMHCONC.S.A0006=1 +PMHCONC.S.A0007=1 +PMHCONC.S.A0008=1 +PMHCONC.S.A0009=1 +PMHCONC.S.A000a=1 + +PMKCONC.C=0 +PMKCONC.S=1 +PMKCONC.S.F00=1 +PMKCONC.S.F01=1 +PMKCONC.S.F02=1 +PMKCONC.S.F03=1 +PMKCONC.S.F04=1 +PMKCONC.S.F05=1 +PMKCONC.S.A0000=1 +PMKCONC.S.A0001=1 +PMKCONC.S.A0002=1 +PMKCONC.S.A0003=1 +PMKCONC.S.A0004=1 +PMKCONC.S.A0005=1 +PMKCONC.S.A0006=1 +PMKCONC.S.A0007=1 +PMKCONC.S.A0008=1 +PMKCONC.S.A0009=1 +PMKCONC.S.A000a=1 + +TVOCCONC.C=0 +TVOCCONC.S=1 +TVOCCONC.S.F00=1 +TVOCCONC.S.F01=1 +TVOCCONC.S.F02=1 +TVOCCONC.S.F03=1 +TVOCCONC.S.F04=1 +TVOCCONC.S.F05=1 +TVOCCONC.S.A0000=1 +TVOCCONC.S.A0001=1 +TVOCCONC.S.A0002=1 +TVOCCONC.S.A0003=1 +TVOCCONC.S.A0004=1 +TVOCCONC.S.A0005=1 +TVOCCONC.S.A0006=1 +TVOCCONC.S.A0007=1 +TVOCCONC.S.A0008=1 +TVOCCONC.S.A0009=1 +TVOCCONC.S.A000a=1 + +RNCONC.C=0 +RNCONC.S=1 +RNCONC.S.F00=1 +RNCONC.S.F01=1 +RNCONC.S.F02=1 +RNCONC.S.F03=1 +RNCONC.S.F04=1 +RNCONC.S.F05=1 +RNCONC.S.A0000=1 +RNCONC.S.A0001=1 +RNCONC.S.A0002=1 +RNCONC.S.A0003=1 +RNCONC.S.A0004=1 +RNCONC.S.A0005=1 +RNCONC.S.A0006=1 +RNCONC.S.A0007=1 +RNCONC.S.A0008=1 +RNCONC.S.A0009=1 +RNCONC.S.A000a=1 + +# Temperature Measurement Cluster +TMP.S=1 +TMP.S.A0000=1 +TMP.S.A0001=1 +TMP.S.A0002=1 +TMP.S.A0003=1 +TMP.M.ManuallyControlled=0 + +# Relative Humidity Cluster +RH.S=1 +RH.S.A0000=1 +RH.S.A0001=1 +RH.S.A0002=1 +RH.S.A0003=1 +RH.M.ManuallyControlled=0 + +# Thermostat Cluster +TSTAT.S = 1 +TSTAT.S.F00 = 1 +TSTAT.S.F01 = 0 +TSTAT.S.F02 = 0 +TSTAT.S.F03 = 0 +TSTAT.S.F04 = 0 +TSTAT.S.F05 = 0 +TSTAT.S.F06 = 0 + +TSTAT.S.A0000 = 1 +TSTAT.S.A0001 = 0 +TSTAT.S.A0002 = 0 +TSTAT.S.A0003 = 1 +TSTAT.S.A0004 = 1 +TSTAT.S.A0005 = 0 +TSTAT.S.A0006 = 0 +TSTAT.S.A0007 = 0 +TSTAT.S.A0008 = 0 +TSTAT.S.A0009 = 0 +TSTAT.S.A0010 = 0 +TSTAT.S.A0011 = 0 +TSTAT.S.A0012 = 1 +TSTAT.S.A0013 = 0 +TSTAT.S.A0014 = 0 +TSTAT.S.A0015 = 0 +TSTAT.S.A0016 = 0 +TSTAT.S.A0017 = 0 +TSTAT.S.A0018 = 0 +TSTAT.S.A0019 = 0 +TSTAT.S.A001a = 0 +TSTAT.S.A001b = 1 +TSTAT.S.A001c = 1 +TSTAT.S.A001d = 0 +TSTAT.S.A001e = 0 +TSTAT.S.A0020 = 0 +TSTAT.S.A0021 = 0 +TSTAT.S.A0022 = 0 +TSTAT.S.A0023 = 0 +TSTAT.S.A0024 = 0 +TSTAT.S.A0025 = 0 +TSTAT.S.A0029 = 1 +TSTAT.S.A0030 = 0 +TSTAT.S.A0031 = 0 +TSTAT.S.A0032 = 0 +TSTAT.S.A0034 = 0 +TSTAT.S.A0035 = 0 +TSTAT.S.A0036 = 0 +TSTAT.S.A0037 = 0 +TSTAT.S.A0038 = 0 +TSTAT.S.A0039 = 0 +TSTAT.S.A003a = 0 +TSTAT.S.A0040 = 0 +TSTAT.S.A0041 = 0 +TSTAT.S.A0042 = 0 +TSTAT.S.A0043 = 0 +TSTAT.S.A0044 = 0 +TSTAT.S.A0045 = 0 +TSTAT.S.A0046 = 0 +TSTAT.S.A0047 = 0 +TSTAT.S.M.MinSetpointDeadBandWritable = 0 +TSTAT.S.M.HVACSystemTypeConfigurationWritable = 0 + +# Server Commands +TSTAT.S.C00.Rsp = 1 +TSTAT.S.C01.Rsp = 0 +TSTAT.S.C02.Rsp = 0 +TSTAT.S.C03.Rsp = 0 +TSTAT.S.C04.Rsp = 0 +``` diff --git a/examples/air-purifier-app/air-purifier-common/air-purifier-app.matter b/examples/air-purifier-app/air-purifier-common/air-purifier-app.matter index 33de78383c41fc..a801aac5943356 100644 --- a/examples/air-purifier-app/air-purifier-common/air-purifier-app.matter +++ b/examples/air-purifier-app/air-purifier-common/air-purifier-app.matter @@ -759,6 +759,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -815,10 +819,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** Commands to trigger a Node to allow a new Administrator to commission it. */ @@ -1207,6 +1223,377 @@ cluster ActivatedCarbonFilterMonitoring = 114 { command ResetCondition(): DefaultSuccess = 0; } +/** An interface for configuring and controlling the functionality of a thermostat. */ +cluster Thermostat = 513 { + revision 6; + + enum ACCapacityFormatEnum : enum8 { + kBTUh = 0; + } + + enum ACCompressorTypeEnum : enum8 { + kUnknown = 0; + kT1 = 1; + kT2 = 2; + kT3 = 3; + } + + enum ACLouverPositionEnum : enum8 { + kClosed = 1; + kOpen = 2; + kQuarter = 3; + kHalf = 4; + kThreeQuarters = 5; + } + + enum ACRefrigerantTypeEnum : enum8 { + kUnknown = 0; + kR22 = 1; + kR410a = 2; + kR407c = 3; + } + + enum ACTypeEnum : enum8 { + kUnknown = 0; + kCoolingFixed = 1; + kHeatPumpFixed = 2; + kCoolingInverter = 3; + kHeatPumpInverter = 4; + } + + enum ControlSequenceOfOperationEnum : enum8 { + kCoolingOnly = 0; + kCoolingWithReheat = 1; + kHeatingOnly = 2; + kHeatingWithReheat = 3; + kCoolingAndHeating = 4; + kCoolingAndHeatingWithReheat = 5; + } + + enum PresetScenarioEnum : enum8 { + kUnspecified = 0; + kOccupied = 1; + kUnoccupied = 2; + kSleep = 3; + kWake = 4; + kVacation = 5; + kUserDefined = 6; + } + + enum SetpointChangeSourceEnum : enum8 { + kManual = 0; + kSchedule = 1; + kExternal = 2; + } + + enum SetpointRaiseLowerModeEnum : enum8 { + kHeat = 0; + kCool = 1; + kBoth = 2; + } + + enum StartOfWeekEnum : enum8 { + kSunday = 0; + kMonday = 1; + kTuesday = 2; + kWednesday = 3; + kThursday = 4; + kFriday = 5; + kSaturday = 6; + } + + enum SystemModeEnum : enum8 { + kOff = 0; + kAuto = 1; + kCool = 3; + kHeat = 4; + kEmergencyHeat = 5; + kPrecooling = 6; + kFanOnly = 7; + kDry = 8; + kSleep = 9; + } + + enum TemperatureSetpointHoldEnum : enum8 { + kSetpointHoldOff = 0; + kSetpointHoldOn = 1; + } + + enum ThermostatRunningModeEnum : enum8 { + kOff = 0; + kCool = 3; + kHeat = 4; + } + + bitmap ACErrorCodeBitmap : bitmap32 { + kCompressorFail = 0x1; + kRoomSensorFail = 0x2; + kOutdoorSensorFail = 0x4; + kCoilSensorFail = 0x8; + kFanFail = 0x10; + } + + bitmap Feature : bitmap32 { + kHeating = 0x1; + kCooling = 0x2; + kOccupancy = 0x4; + kScheduleConfiguration = 0x8; + kSetback = 0x10; + kAutoMode = 0x20; + kLocalTemperatureNotExposed = 0x40; + kMatterScheduleConfiguration = 0x80; + kPresets = 0x100; + kSetpoints = 0x200; + kQueuedPresetsSupported = 0x400; + } + + bitmap HVACSystemTypeBitmap : bitmap8 { + kCoolingStage = 0x3; + kHeatingStage = 0xC; + kHeatingIsHeatPump = 0x10; + kHeatingUsesFuel = 0x20; + } + + bitmap PresetTypeFeaturesBitmap : bitmap16 { + kAutomatic = 0x1; + kSupportsNames = 0x2; + } + + bitmap ProgrammingOperationModeBitmap : bitmap8 { + kScheduleActive = 0x1; + kAutoRecovery = 0x2; + kEconomy = 0x4; + } + + bitmap RelayStateBitmap : bitmap16 { + kHeat = 0x1; + kCool = 0x2; + kFan = 0x4; + kHeatStage2 = 0x8; + kCoolStage2 = 0x10; + kFanStage2 = 0x20; + kFanStage3 = 0x40; + } + + bitmap RemoteSensingBitmap : bitmap8 { + kLocalTemperature = 0x1; + kOutdoorTemperature = 0x2; + kOccupancy = 0x4; + } + + bitmap ScheduleDayOfWeekBitmap : bitmap8 { + kSunday = 0x1; + kMonday = 0x2; + kTuesday = 0x4; + kWednesday = 0x8; + kThursday = 0x10; + kFriday = 0x20; + kSaturday = 0x40; + kAway = 0x80; + } + + bitmap ScheduleModeBitmap : bitmap8 { + kHeatSetpointPresent = 0x1; + kCoolSetpointPresent = 0x2; + } + + bitmap ScheduleTypeFeaturesBitmap : bitmap16 { + kSupportsPresets = 0x1; + kSupportsSetpoints = 0x2; + kSupportsNames = 0x4; + kSupportsOff = 0x8; + } + + bitmap TemperatureSetpointHoldPolicyBitmap : bitmap8 { + kHoldDurationElapsed = 0x1; + kHoldDurationElapsedOrPresetChanged = 0x2; + } + + struct ScheduleTransitionStruct { + ScheduleDayOfWeekBitmap dayOfWeek = 0; + int16u transitionTime = 1; + optional octet_string<16> presetHandle = 2; + optional SystemModeEnum systemMode = 3; + optional temperature coolingSetpoint = 4; + optional temperature heatingSetpoint = 5; + } + + struct ScheduleStruct { + nullable octet_string<16> scheduleHandle = 0; + SystemModeEnum systemMode = 1; + optional char_string<64> name = 2; + optional octet_string<16> presetHandle = 3; + ScheduleTransitionStruct transitions[] = 4; + optional nullable boolean builtIn = 5; + } + + struct PresetStruct { + nullable octet_string<16> presetHandle = 0; + PresetScenarioEnum presetScenario = 1; + optional nullable char_string<64> name = 2; + optional temperature coolingSetpoint = 3; + optional temperature heatingSetpoint = 4; + nullable boolean builtIn = 5; + } + + struct PresetTypeStruct { + PresetScenarioEnum presetScenario = 0; + int8u numberOfPresets = 1; + PresetTypeFeaturesBitmap presetTypeFeatures = 2; + } + + struct QueuedPresetStruct { + nullable octet_string<16> presetHandle = 0; + nullable epoch_s transitionTimestamp = 1; + } + + struct ScheduleTypeStruct { + SystemModeEnum systemMode = 0; + int8u numberOfSchedules = 1; + ScheduleTypeFeaturesBitmap scheduleTypeFeatures = 2; + } + + struct WeeklyScheduleTransitionStruct { + int16u transitionTime = 0; + nullable temperature heatSetpoint = 1; + nullable temperature coolSetpoint = 2; + } + + readonly attribute nullable temperature localTemperature = 0; + readonly attribute optional nullable temperature outdoorTemperature = 1; + readonly attribute optional bitmap8 occupancy = 2; + readonly attribute optional temperature absMinHeatSetpointLimit = 3; + readonly attribute optional temperature absMaxHeatSetpointLimit = 4; + readonly attribute optional temperature absMinCoolSetpointLimit = 5; + readonly attribute optional temperature absMaxCoolSetpointLimit = 6; + readonly attribute optional int8u PICoolingDemand = 7; + readonly attribute optional int8u PIHeatingDemand = 8; + attribute access(write: manage) optional bitmap8 HVACSystemTypeConfiguration = 9; + attribute access(write: manage) optional int8s localTemperatureCalibration = 16; + attribute optional int16s occupiedCoolingSetpoint = 17; + attribute optional int16s occupiedHeatingSetpoint = 18; + attribute optional int16s unoccupiedCoolingSetpoint = 19; + attribute optional int16s unoccupiedHeatingSetpoint = 20; + attribute access(write: manage) optional int16s minHeatSetpointLimit = 21; + attribute access(write: manage) optional int16s maxHeatSetpointLimit = 22; + attribute access(write: manage) optional int16s minCoolSetpointLimit = 23; + attribute access(write: manage) optional int16s maxCoolSetpointLimit = 24; + attribute access(write: manage) optional int8s minSetpointDeadBand = 25; + attribute access(write: manage) optional RemoteSensingBitmap remoteSensing = 26; + attribute access(write: manage) ControlSequenceOfOperationEnum controlSequenceOfOperation = 27; + attribute access(write: manage) SystemModeEnum systemMode = 28; + readonly attribute optional ThermostatRunningModeEnum thermostatRunningMode = 30; + readonly attribute optional StartOfWeekEnum startOfWeek = 32; + readonly attribute optional int8u numberOfWeeklyTransitions = 33; + readonly attribute optional int8u numberOfDailyTransitions = 34; + attribute access(write: manage) optional TemperatureSetpointHoldEnum temperatureSetpointHold = 35; + attribute access(write: manage) optional nullable int16u temperatureSetpointHoldDuration = 36; + attribute access(write: manage) optional ProgrammingOperationModeBitmap thermostatProgrammingOperationMode = 37; + readonly attribute optional RelayStateBitmap thermostatRunningState = 41; + readonly attribute optional SetpointChangeSourceEnum setpointChangeSource = 48; + readonly attribute optional nullable int16s setpointChangeAmount = 49; + readonly attribute optional epoch_s setpointChangeSourceTimestamp = 50; + attribute access(write: manage) optional nullable int8u occupiedSetback = 52; + readonly attribute optional nullable int8u occupiedSetbackMin = 53; + readonly attribute optional nullable int8u occupiedSetbackMax = 54; + attribute access(write: manage) optional nullable int8u unoccupiedSetback = 55; + readonly attribute optional nullable int8u unoccupiedSetbackMin = 56; + readonly attribute optional nullable int8u unoccupiedSetbackMax = 57; + attribute access(write: manage) optional int8u emergencyHeatDelta = 58; + attribute access(write: manage) optional ACTypeEnum ACType = 64; + attribute access(write: manage) optional int16u ACCapacity = 65; + attribute access(write: manage) optional ACRefrigerantTypeEnum ACRefrigerantType = 66; + attribute access(write: manage) optional ACCompressorTypeEnum ACCompressorType = 67; + attribute access(write: manage) optional ACErrorCodeBitmap ACErrorCode = 68; + attribute access(write: manage) optional ACLouverPositionEnum ACLouverPosition = 69; + readonly attribute optional nullable temperature ACCoilTemperature = 70; + attribute access(write: manage) optional ACCapacityFormatEnum ACCapacityformat = 71; + readonly attribute optional PresetTypeStruct presetTypes[] = 72; + readonly attribute optional ScheduleTypeStruct scheduleTypes[] = 73; + readonly attribute optional int8u numberOfPresets = 74; + readonly attribute optional int8u numberOfSchedules = 75; + readonly attribute optional int8u numberOfScheduleTransitions = 76; + readonly attribute optional nullable int8u numberOfScheduleTransitionPerDay = 77; + readonly attribute optional nullable octet_string<16> activePresetHandle = 78; + readonly attribute optional nullable octet_string<16> activeScheduleHandle = 79; + attribute access(write: manage) optional PresetStruct presets[] = 80; + attribute access(write: manage) optional ScheduleStruct schedules[] = 81; + readonly attribute optional boolean presetsSchedulesEditable = 82; + readonly attribute optional TemperatureSetpointHoldPolicyBitmap temperatureSetpointHoldPolicy = 83; + readonly attribute optional nullable epoch_s setpointHoldExpiryTimestamp = 84; + readonly attribute optional nullable QueuedPresetStruct queuedPreset = 85; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct SetpointRaiseLowerRequest { + SetpointRaiseLowerModeEnum mode = 0; + int8s amount = 1; + } + + response struct GetWeeklyScheduleResponse = 0 { + int8u numberOfTransitionsForSequence = 0; + ScheduleDayOfWeekBitmap dayOfWeekForSequence = 1; + ScheduleModeBitmap modeForSequence = 2; + WeeklyScheduleTransitionStruct transitions[] = 3; + } + + request struct SetWeeklyScheduleRequest { + int8u numberOfTransitionsForSequence = 0; + ScheduleDayOfWeekBitmap dayOfWeekForSequence = 1; + ScheduleModeBitmap modeForSequence = 2; + WeeklyScheduleTransitionStruct transitions[] = 3; + } + + request struct GetWeeklyScheduleRequest { + ScheduleDayOfWeekBitmap daysToReturn = 0; + ScheduleModeBitmap modeToReturn = 1; + } + + request struct SetActiveScheduleRequestRequest { + octet_string<16> scheduleHandle = 0; + } + + request struct SetActivePresetRequestRequest { + octet_string<16> presetHandle = 0; + optional int16u delayMinutes = 1; + } + + request struct StartPresetsSchedulesEditRequestRequest { + int16u timeoutSeconds = 0; + } + + request struct SetTemperatureSetpointHoldPolicyRequest { + TemperatureSetpointHoldPolicyBitmap temperatureSetpointHoldPolicy = 0; + } + + /** Command description for SetpointRaiseLower */ + command SetpointRaiseLower(SetpointRaiseLowerRequest): DefaultSuccess = 0; + /** Command description for SetWeeklySchedule */ + command access(invoke: manage) SetWeeklySchedule(SetWeeklyScheduleRequest): DefaultSuccess = 1; + /** Command description for GetWeeklySchedule */ + command GetWeeklySchedule(GetWeeklyScheduleRequest): GetWeeklyScheduleResponse = 2; + /** This command is used to clear the weekly schedule. The ClearWeeklySchedule command has no payload. */ + command access(invoke: manage) ClearWeeklySchedule(): DefaultSuccess = 3; + /** This command is used to set the active schedule. */ + command SetActiveScheduleRequest(SetActiveScheduleRequestRequest): DefaultSuccess = 5; + /** This command is used to set the active preset. */ + command SetActivePresetRequest(SetActivePresetRequestRequest): DefaultSuccess = 6; + /** This command is used to start editing the presets and schedules. */ + command access(invoke: manage) StartPresetsSchedulesEditRequest(StartPresetsSchedulesEditRequestRequest): DefaultSuccess = 7; + /** This command is used to cancel editing presets and schedules. */ + command access(invoke: manage) CancelPresetsSchedulesEditRequest(): DefaultSuccess = 8; + /** This command is used to notify the server that all edits are done and should be committed. */ + command access(invoke: manage) CommitPresetsSchedulesRequest(): DefaultSuccess = 9; + /** This command is sent to cancel a queued preset. */ + command access(invoke: manage) CancelSetActivePresetRequest(): DefaultSuccess = 10; + /** This command sets the set point hold policy. */ + command SetTemperatureSetpointHoldPolicy(SetTemperatureSetpointHoldPolicyRequest): DefaultSuccess = 11; +} + /** An interface for controlling a fan in a heating/cooling system. */ provisional cluster FanControl = 514 { revision 4; @@ -2019,8 +2406,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; @@ -2407,7 +2794,7 @@ endpoint 2 { } } endpoint 3 { - device type ma_tempsensor = 770, version 1; + device type ma_tempsensor = 770, version 2; server cluster Identify { @@ -2451,7 +2838,7 @@ endpoint 3 { } } endpoint 4 { - device type ma_humiditysensor = 775, version 1; + device type ma_humiditysensor = 775, version 2; server cluster Identify { @@ -2494,5 +2881,54 @@ endpoint 4 { ram attribute clusterRevision default = 3; } } +endpoint 5 { + device type ma_thermostat = 769, version 2; + + + server cluster Identify { + ram attribute identifyTime default = 0x0; + ram attribute identifyType default = 0x00; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 4; + + handle command Identify; + handle command TriggerEffect; + } + + server cluster Descriptor { + callback attribute deviceTypeList; + callback attribute serverList; + callback attribute clientList; + callback attribute partsList; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + callback attribute featureMap; + callback attribute clusterRevision; + } + + server cluster Thermostat { + ram attribute localTemperature; + ram attribute absMinHeatSetpointLimit default = 1000; + ram attribute absMaxHeatSetpointLimit default = 3000; + ram attribute occupiedHeatingSetpoint default = 2000; + ram attribute controlSequenceOfOperation default = 2; + ram attribute systemMode default = 0; + ram attribute thermostatRunningState default = 0; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 1; + ram attribute clusterRevision default = 6; + + handle command SetpointRaiseLower; + } +} diff --git a/examples/air-purifier-app/air-purifier-common/air-purifier-app.zap b/examples/air-purifier-app/air-purifier-common/air-purifier-app.zap index d71c47a6d98758..b868916264f4ba 100644 --- a/examples/air-purifier-app/air-purifier-common/air-purifier-app.zap +++ b/examples/air-purifier-app/air-purifier-common/air-purifier-app.zap @@ -6514,7 +6514,7 @@ } ], "deviceVersions": [ - 1 + 2 ], "deviceIdentifiers": [ 770 @@ -7039,7 +7039,7 @@ } ], "deviceVersions": [ - 1 + 2 ], "deviceIdentifiers": [ 775 @@ -7545,43 +7545,634 @@ ] } ] - } - ], - "endpoints": [ - { - "endpointTypeName": "MA-rootdevice", - "endpointTypeIndex": 0, - "profileId": 259, - "endpointId": 0, - "networkId": 0 - }, - { - "endpointTypeName": "Anonymous Endpoint Type", - "endpointTypeIndex": 1, - "profileId": 259, - "endpointId": 1, - "networkId": 0 - }, - { - "endpointTypeName": "Anonymous Endpoint Type", - "endpointTypeIndex": 2, - "profileId": 259, - "endpointId": 2, - "networkId": 0 - }, - { - "endpointTypeName": "Anonymous Endpoint Type", - "endpointTypeIndex": 3, - "profileId": 259, - "endpointId": 3, - "networkId": 0 }, { - "endpointTypeName": "Anonymous Endpoint Type", - "endpointTypeIndex": 4, - "profileId": 259, - "endpointId": 4, - "networkId": 0 - } - ] + "id": 6, + "name": "Anonymous Endpoint Type", + "deviceTypeRef": { + "code": 769, + "profileId": 259, + "label": "MA-thermostat", + "name": "MA-thermostat" + }, + "deviceTypes": [ + { + "code": 769, + "profileId": 259, + "label": "MA-thermostat", + "name": "MA-thermostat" + } + ], + "deviceVersions": [ + 2 + ], + "deviceIdentifiers": [ + 769 + ], + "deviceTypeName": "MA-thermostat", + "deviceTypeCode": 769, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "Identify", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TriggerEffect", + "code": 64, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "IdentifyTime", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "IdentifyType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "IdentifyTypeEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "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": "4", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DeviceTypeList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ServerList", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClientList", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PartsList", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "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": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "2", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Thermostat", + "code": 513, + "mfgCode": null, + "define": "THERMOSTAT_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "SetpointRaiseLower", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "LocalTemperature", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "temperature", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AbsMinHeatSetpointLimit", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "temperature", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AbsMaxHeatSetpointLimit", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "temperature", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OccupiedHeatingSetpoint", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int16s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "2000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ControlSequenceOfOperation", + "code": 27, + "mfgCode": null, + "side": "server", + "type": "ControlSequenceOfOperationEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "2", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SystemMode", + "code": 28, + "mfgCode": null, + "side": "server", + "type": "SystemModeEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ThermostatRunningState", + "code": 41, + "mfgCode": null, + "side": "server", + "type": "RelayStateBitmap", + "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": 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": "1", + "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": "6", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + } + ] + } + ], + "endpoints": [ + { + "endpointTypeName": "MA-rootdevice", + "endpointTypeIndex": 0, + "profileId": 259, + "endpointId": 0, + "networkId": 0 + }, + { + "endpointTypeName": "Anonymous Endpoint Type", + "endpointTypeIndex": 1, + "profileId": 259, + "endpointId": 1, + "networkId": 0 + }, + { + "endpointTypeName": "Anonymous Endpoint Type", + "endpointTypeIndex": 2, + "profileId": 259, + "endpointId": 2, + "networkId": 0 + }, + { + "endpointTypeName": "Anonymous Endpoint Type", + "endpointTypeIndex": 3, + "profileId": 259, + "endpointId": 3, + "networkId": 0 + }, + { + "endpointTypeName": "Anonymous Endpoint Type", + "endpointTypeIndex": 4, + "profileId": 259, + "endpointId": 4, + "networkId": 0 + }, + { + "endpointTypeName": "Anonymous Endpoint Type", + "endpointTypeIndex": 5, + "profileId": 259, + "endpointId": 5, + "networkId": 0 + } + ], + "log": [] } \ No newline at end of file diff --git a/examples/air-purifier-app/air-purifier-common/include/air-purifier-manager.h b/examples/air-purifier-app/air-purifier-common/include/air-purifier-manager.h index 81565d532e4e7e..e50ccd09958283 100644 --- a/examples/air-purifier-app/air-purifier-common/include/air-purifier-manager.h +++ b/examples/air-purifier-app/air-purifier-common/include/air-purifier-manager.h @@ -22,6 +22,7 @@ #include #include #include +#include #pragma once @@ -52,12 +53,13 @@ class AirPurifierManager : public FanControl::Delegate, public DeviceManager::De AirPurifierManager & operator=(const AirPurifierManager &) = delete; static void InitInstance(EndpointId aEndpointId = 1, EndpointId aAirQualitySensorEndpointId = 2, - EndpointId aTemperatureSensorEndpointId = 3, EndpointId aHumiditySensorEndpointId = 4) + EndpointId aTemperatureSensorEndpointId = 3, EndpointId aHumiditySensorEndpointId = 4, + EndpointId aThermostatEndpointId = 5) { if (mInstance == nullptr) { mInstance = new AirPurifierManager(aEndpointId, aAirQualitySensorEndpointId, aTemperatureSensorEndpointId, - aHumiditySensorEndpointId); + aHumiditySensorEndpointId, aThermostatEndpointId); mInstance->Init(); } }; @@ -89,6 +91,11 @@ class AirPurifierManager : public FanControl::Delegate, public DeviceManager::De */ Protocols::InteractionModel::Status HandleStep(FanControl::StepDirectionEnum aDirection, bool aWrap, bool aLowestOff) override; + /** + * @brief Callback that thermostat manager calls when the heating state changes + */ + void HeatingCallback(); + private: inline static AirPurifierManager * mInstance; @@ -96,10 +103,13 @@ class AirPurifierManager : public FanControl::Delegate, public DeviceManager::De EndpointId mAirQualitySensorEndpointId; EndpointId mTemperatureSensorEndpointId; EndpointId mHumiditySensorEndpointId; + EndpointId mThermostatEndpointId; uint8_t percentCurrent; uint8_t speedCurrent; + bool fanWasStartedByUser = false; + // Set up for Activated Carbon Filter Monitoring ActivatedCarbonFilterMonitoringDelegate activatedCarbonFilterDelegate; ResourceMonitoring::Instance activatedCarbonFilterInstance; @@ -112,6 +122,7 @@ class AirPurifierManager : public FanControl::Delegate, public DeviceManager::De AirQualitySensorManager mAirQualitySensorManager; TemperatureSensorManager mTemperatureSensorManager; RelativeHumiditySensorManager mHumiditySensorManager; + ThermostatManager mThermostatManager; // Fan Mode Limits static constexpr int FAN_MODE_LOW_LOWER_BOUND = 1; @@ -129,7 +140,7 @@ class AirPurifierManager : public FanControl::Delegate, public DeviceManager::De * @param[in] aHumiditySensorEndpointId Endpoint that the humidity sensor is on */ AirPurifierManager(EndpointId aEndpointId, EndpointId aAirQualitySensorEndpointId, EndpointId aTemperatureSensorEndpointId, - EndpointId aHumiditySensorEndpointId) : + EndpointId aHumiditySensorEndpointId, EndpointId aThermostatEndpointId) : FanControl::Delegate(aEndpointId), mEndpointId(aEndpointId), activatedCarbonFilterInstance(&activatedCarbonFilterDelegate, mEndpointId, ActivatedCarbonFilterMonitoring::Id, @@ -139,7 +150,9 @@ class AirPurifierManager : public FanControl::Delegate, public DeviceManager::De static_cast(gHepaFilterFeatureMap.to_ulong()), ResourceMonitoring::DegradationDirectionEnum::kDown, true), mAirQualitySensorManager(aAirQualitySensorEndpointId), mTemperatureSensorManager(aTemperatureSensorEndpointId), - mHumiditySensorManager(aHumiditySensorEndpointId){}; + mHumiditySensorManager(aHumiditySensorEndpointId), + mThermostatManager(aThermostatEndpointId, [this]() { HeatingCallback(); }) + {} /** * @brief Handle attribute changes for the Fan Control Cluster @@ -155,6 +168,12 @@ class AirPurifierManager : public FanControl::Delegate, public DeviceManager::De void FanModeWriteCallback(FanControl::FanModeEnum aNewFanMode); void SetSpeedSetting(DataModel::Nullable aNewSpeedSetting); + DataModel::Nullable GetSpeedSetting(); + DataModel::Nullable GetPercentSetting(); + + void HandleThermostatAttributeChange(AttributeId attributeId, uint8_t type, uint16_t size, uint8_t * value); + void ThermostatHeatingSetpointWriteCallback(int16_t aNewHeatingSetpoint); + void ThermostatSystemModeWriteCallback(uint8_t aNewSystemMode); }; } // namespace Clusters diff --git a/examples/air-purifier-app/air-purifier-common/include/thermostat-manager.h b/examples/air-purifier-app/air-purifier-common/include/thermostat-manager.h new file mode 100644 index 00000000000000..f19e596f66991b --- /dev/null +++ b/examples/air-purifier-app/air-purifier-common/include/thermostat-manager.h @@ -0,0 +1,53 @@ +/* + * + * 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 + +namespace chip { +namespace app { +namespace Clusters { + +class ThermostatManager +{ +public: + using HeatingCallbackType = std::function; + + ThermostatManager(EndpointId aEndpointId, const HeatingCallbackType & callback) : + mEndpointId(aEndpointId), heatingCallback(callback) + {} + + void Init(); + + void HeatingSetpointWriteCallback(int16_t newValue); + void SystemModeWriteCallback(uint8_t newValue); + void OnLocalTemperatureChangeCallback(int16_t temperature); + void SetHeatMode(bool heat); + +private: + EndpointId mEndpointId; + + void SetHeating(bool isHeating); + HeatingCallbackType heatingCallback; +}; + +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/examples/air-purifier-app/air-purifier-common/src/air-purifier-manager.cpp b/examples/air-purifier-app/air-purifier-common/src/air-purifier-manager.cpp index 93e1e37a73dd77..7ce8ac5f338fcc 100644 --- a/examples/air-purifier-app/air-purifier-common/src/air-purifier-manager.cpp +++ b/examples/air-purifier-app/air-purifier-common/src/air-purifier-manager.cpp @@ -33,37 +33,31 @@ void AirPurifierManager::Init() mAirQualitySensorManager.Init(); mTemperatureSensorManager.Init(); mHumiditySensorManager.Init(); + mThermostatManager.Init(); - DataModel::Nullable percentSetting; - EmberAfStatus status = FanControl::Attributes::PercentSetting::Get(mEndpointId, percentSetting); - if (EMBER_ZCL_STATUS_SUCCESS == status) + DataModel::Nullable percentSetting = GetPercentSetting(); + if (percentSetting.IsNull()) { - if (percentSetting.IsNull()) - { - PercentSettingWriteCallback(0); - } - else - { - PercentSettingWriteCallback(percentSetting.Value()); - } + PercentSettingWriteCallback(0); + } + else + { + PercentSettingWriteCallback(percentSetting.Value()); } - DataModel::Nullable speedSetting; - status = FanControl::Attributes::SpeedSetting::Get(mEndpointId, speedSetting); - if (EMBER_ZCL_STATUS_SUCCESS == status) + DataModel::Nullable speedSetting = GetSpeedSetting(); + if (speedSetting.IsNull()) { - if (speedSetting.IsNull()) - { - SpeedSettingWriteCallback(0); - } - else - { - SpeedSettingWriteCallback(speedSetting.Value()); - } + SpeedSettingWriteCallback(0); + } + else + { + SpeedSettingWriteCallback(speedSetting.Value()); } // Set up some sane initial values for temperature and humidity - note these are fixed values for testing purposes only mTemperatureSensorManager.OnTemperatureChangeHandler(2000); + mThermostatManager.OnLocalTemperatureChangeCallback(2000); mHumiditySensorManager.OnHumidityChangeHandler(5000); } @@ -77,6 +71,11 @@ void AirPurifierManager::PostAttributeChangeCallback(EndpointId endpoint, Cluste break; } + case Thermostat::Id: { + HandleThermostatAttributeChange(attributeId, type, size, value); + break; + } + default: break; } @@ -92,8 +91,7 @@ Status AirPurifierManager::HandleStep(FanControl::StepDirectionEnum aDirection, uint8_t speedMax; FanControl::Attributes::SpeedMax::Get(mEndpointId, &speedMax); - DataModel::Nullable speedSetting; - FanControl::Attributes::SpeedSetting::Get(mEndpointId, speedSetting); + DataModel::Nullable speedSetting = GetSpeedSetting(); uint8_t newSpeedSetting = speedSetting.IsNull() ? 0 : speedSetting.Value(); @@ -309,3 +307,68 @@ void AirPurifierManager::SetSpeedSetting(DataModel::Nullable aNewSpeedS } } } + +DataModel::Nullable AirPurifierManager::GetSpeedSetting() +{ + DataModel::Nullable speedSetting; + EmberAfStatus status = FanControl::Attributes::SpeedSetting::Get(mEndpointId, speedSetting); + + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "AirPurifierManager::GetSpeedSetting: failed to get SpeedSetting attribute: %d", status); + } + + return speedSetting; +} + +DataModel::Nullable AirPurifierManager::GetPercentSetting() +{ + DataModel::Nullable percentSetting; + EmberAfStatus status = FanControl::Attributes::PercentSetting::Get(mEndpointId, percentSetting); + + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "AirPurifierManager::GetPercentSetting: failed to get PercentSetting attribute: %d", status); + } + + return percentSetting; +} + +void AirPurifierManager::HandleThermostatAttributeChange(AttributeId attributeId, uint8_t type, uint16_t size, uint8_t * value) +{ + switch (attributeId) + { + case Thermostat::Attributes::OccupiedHeatingSetpoint::Id: { + int16_t heatingSetpoint = static_cast(chip::Encoding::LittleEndian::Get16(value)); + ThermostatHeatingSetpointWriteCallback(heatingSetpoint); + break; + } + case Thermostat::Attributes::SystemMode::Id: { + uint8_t systemMode = static_cast(*value); + ThermostatSystemModeWriteCallback(systemMode); + break; + } + } +} + +void AirPurifierManager::ThermostatHeatingSetpointWriteCallback(int16_t aNewHeatingSetpoint) +{ + mThermostatManager.HeatingSetpointWriteCallback(aNewHeatingSetpoint); +} + +void AirPurifierManager::ThermostatSystemModeWriteCallback(uint8_t aNewSystemMode) +{ + mThermostatManager.SystemModeWriteCallback(aNewSystemMode); +} + +void AirPurifierManager::HeatingCallback() +{ + // Check if the Fan is off and if it is, turn it on to 50% speed + DataModel::Nullable speedSetting = GetSpeedSetting(); + + if (speedSetting.IsNull() || speedSetting.Value() == 0) + { + DataModel::Nullable newSpeedSetting(5); + SetSpeedSetting(newSpeedSetting); + } +} diff --git a/examples/air-purifier-app/air-purifier-common/src/thermostat-manager.cpp b/examples/air-purifier-app/air-purifier-common/src/thermostat-manager.cpp new file mode 100644 index 00000000000000..c2536e4d99e38b --- /dev/null +++ b/examples/air-purifier-app/air-purifier-common/src/thermostat-manager.cpp @@ -0,0 +1,135 @@ +/* + * + * Copyright (c) 2024 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 "thermostat-manager.h" + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters; + +void ThermostatManager::Init() +{ + BitMask FeatureMap; + FeatureMap.Set(Thermostat::Feature::kHeating); + EmberAfStatus status = Thermostat::Attributes::FeatureMap::Set(mEndpointId, FeatureMap.Raw()); + + status = Thermostat::Attributes::ControlSequenceOfOperation::Set(mEndpointId, + Thermostat::ControlSequenceOfOperationEnum::kHeatingOnly); + VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, + ChipLogError(NotSpecified, "Failed to set Thermostat ControlSequenceOfOperation attribute")); + + status = Thermostat::Attributes::AbsMinHeatSetpointLimit::Set(mEndpointId, 500); + VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, + ChipLogError(NotSpecified, "Failed to set Thermostat MinHeatSetpointLimit attribute")); + + status = Thermostat::Attributes::AbsMaxHeatSetpointLimit::Set(mEndpointId, 3000); + VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, + ChipLogError(NotSpecified, "Failed to set Thermostat MaxHeatSetpointLimit attribute")); +} + +void ThermostatManager::HeatingSetpointWriteCallback(int16_t newValue) +{ + ChipLogDetail(NotSpecified, "ThermostatManager::HeatingSetpointWriteCallback: %d", newValue); + Thermostat::SystemModeEnum systemMode; + EmberAfStatus status = Thermostat::Attributes::SystemMode::Get(mEndpointId, &systemMode); + VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(NotSpecified, "Failed to get Thermostat SystemMode attribute")); + + // A new setpoint has been set, so we shall infer that the we want to be in Heating mode + if (systemMode == Thermostat::SystemModeEnum::kOff) + { + SetHeatMode(true); + } + + // Check the current temperature and turn on the heater if needed + DataModel::Nullable localTemperature; + status = Thermostat::Attributes::LocalTemperature::Get(mEndpointId, localTemperature); + VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, + ChipLogError(NotSpecified, "Failed to get TemperatureMeasurement MeasuredValue attribute")); + + if (localTemperature.Value() < newValue) + { + SetHeating(true); + } + else + { + SetHeating(false); + } +} + +void ThermostatManager::SystemModeWriteCallback(uint8_t newValue) +{ + ChipLogDetail(NotSpecified, "ThermostatManager::SystemModeWriteCallback: %d", newValue); + if ((Thermostat::SystemModeEnum) newValue == Thermostat::SystemModeEnum::kOff) + { + SetHeating(false); + } + else if ((Thermostat::SystemModeEnum) newValue == Thermostat::SystemModeEnum::kHeat) + { + DataModel::Nullable localTemperature; + EmberAfStatus status = Thermostat::Attributes::LocalTemperature::Get(mEndpointId, localTemperature); + VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, + ChipLogError(NotSpecified, "Failed to get TemperatureMeasurement MeasuredValue attribute")); + + int16_t heatingSetpoint; + status = Thermostat::Attributes::OccupiedHeatingSetpoint::Get(mEndpointId, &heatingSetpoint); + VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, + ChipLogError(NotSpecified, "Failed to get Thermostat HeatingSetpoint attribute")); + + if (localTemperature.Value() < heatingSetpoint) + { + SetHeating(true); + } + } +} + +void ThermostatManager::OnLocalTemperatureChangeCallback(int16_t temperature) +{ + EmberAfStatus status = Thermostat::Attributes::LocalTemperature::Set(mEndpointId, temperature); + VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, + ChipLogError(NotSpecified, "Failed to set TemperatureMeasurement MeasuredValue attribute")); +} + +void ThermostatManager::SetHeating(bool isHeating) +{ + BitMask runningState; + + if (isHeating) + { + runningState.Set(Thermostat::RelayStateBitmap::kHeat); + + if (heatingCallback) + { + heatingCallback(); + } + } + else + { + runningState.Clear(Thermostat::RelayStateBitmap::kHeat); + } + + EmberAfStatus status = Thermostat::Attributes::ThermostatRunningState::Set(mEndpointId, runningState); + VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, + ChipLogError(NotSpecified, "Failed to set Thermostat RunningState attribute")); +} + +void ThermostatManager::SetHeatMode(bool heat) +{ + EmberAfStatus status = Thermostat::Attributes::SystemMode::Set( + mEndpointId, heat ? Thermostat::SystemModeEnum::kHeat : Thermostat::SystemModeEnum::kOff); + VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(NotSpecified, "Failed to set Thermostat SystemMode attribute")); +} diff --git a/examples/air-purifier-app/ameba/README.md b/examples/air-purifier-app/ameba/README.md index be11ad8d063210..ee2a451203cb7f 100644 --- a/examples/air-purifier-app/ameba/README.md +++ b/examples/air-purifier-app/ameba/README.md @@ -10,7 +10,7 @@ This example demonstrates the Matter air purifier application on Ameba platform. - [Commissioning](#commissioning) - [BLE mode](#ble-mode) - [IP mode](#ip-mode) - - [Cluster control](#cluster-control) + - [Cluster Control](#cluster-control) --- @@ -106,6 +106,7 @@ follows: - Air quality sensor on endpoint 2 - Temperature sensor on endpoint 3 - Relative humidity sensor on endpoint 4 +- Thermostat on endpoint 5 Example commands using the chip tool: diff --git a/examples/air-purifier-app/ameba/main/chipinterface.cpp b/examples/air-purifier-app/ameba/main/chipinterface.cpp index bcda329cdb8536..264ad532b513aa 100644 --- a/examples/air-purifier-app/ameba/main/chipinterface.cpp +++ b/examples/air-purifier-app/ameba/main/chipinterface.cpp @@ -48,6 +48,7 @@ #define AIR_QUALITY_SENSOR_ENDPOINT 2 #define TEMPERATURE_SENSOR_ENDPOINT 3 #define RELATIVE_HUMIDITY_SENSOR_ENDPOINT 4 +#define THERMOSTAT_ENDPOINT 5 using namespace ::chip; using namespace ::chip::app; @@ -116,11 +117,12 @@ static void InitAirPurifierManager(void) { Clusters::AirPurifierManager::InitInstance(EndpointId(AIR_PURIFIER_ENDPOINT), EndpointId(AIR_QUALITY_SENSOR_ENDPOINT), EndpointId(TEMPERATURE_SENSOR_ENDPOINT), - EndpointId(RELATIVE_HUMIDITY_SENSOR_ENDPOINT)); + EndpointId(RELATIVE_HUMIDITY_SENSOR_ENDPOINT), EndpointId(THERMOSTAT_ENDPOINT)); SetParentEndpointForEndpoint(AIR_QUALITY_SENSOR_ENDPOINT, AIR_PURIFIER_ENDPOINT); SetParentEndpointForEndpoint(TEMPERATURE_SENSOR_ENDPOINT, AIR_PURIFIER_ENDPOINT); SetParentEndpointForEndpoint(RELATIVE_HUMIDITY_SENSOR_ENDPOINT, AIR_PURIFIER_ENDPOINT); + SetParentEndpointForEndpoint(THERMOSTAT_ENDPOINT, AIR_PURIFIER_ENDPOINT); } static void InitServer(intptr_t context) diff --git a/examples/air-purifier-app/cc32xx/BUILD.gn b/examples/air-purifier-app/cc32xx/BUILD.gn index 51916cc32d646f..f79e76c82ce0d3 100755 --- a/examples/air-purifier-app/cc32xx/BUILD.gn +++ b/examples/air-purifier-app/cc32xx/BUILD.gn @@ -85,6 +85,7 @@ ti_simplelink_executable("air-purifier_app") { "${chip_root}/examples/air-purifier-app/air-purifier-common/src/air-purifier-manager.cpp", "${chip_root}/examples/air-purifier-app/air-purifier-common/src/air-quality-sensor-manager.cpp", "${chip_root}/examples/air-purifier-app/air-purifier-common/src/filter-delegates.cpp", + "${chip_root}/examples/air-purifier-app/air-purifier-common/src/thermostat-manager.cpp", "${project_dir}/main/AppTask.cpp", "${project_dir}/main/CHIPDeviceManager.cpp", "${project_dir}/main/CXXExceptionStubs.cpp", diff --git a/examples/air-purifier-app/cc32xx/main/AppTask.cpp b/examples/air-purifier-app/cc32xx/main/AppTask.cpp index e753e5ac4aed8f..0b284254b0c80f 100644 --- a/examples/air-purifier-app/cc32xx/main/AppTask.cpp +++ b/examples/air-purifier-app/cc32xx/main/AppTask.cpp @@ -64,6 +64,7 @@ extern void DisplayBanner(); #define AIR_QUALITY_SENSOR_ENDPOINT 2 #define TEMPERATURE_SENSOR_ENDPOINT 3 #define RELATIVE_HUMIDITY_SENSOR_ENDPOINT 4 +#define THERMOSTAT_ENDPOINT 5 // Added the below three for DNS Server Initialization using namespace ::chip; @@ -178,9 +179,11 @@ int AppTask::Init() SetParentEndpointForEndpoint(AIR_QUALITY_SENSOR_ENDPOINT, AIR_PURIFIER_ENDPOINT); SetParentEndpointForEndpoint(TEMPERATURE_SENSOR_ENDPOINT, AIR_PURIFIER_ENDPOINT); SetParentEndpointForEndpoint(RELATIVE_HUMIDITY_SENSOR_ENDPOINT, AIR_PURIFIER_ENDPOINT); + SetParentEndpointForEndpoint(THERMOSTAT_ENDPOINT, AIR_PURIFIER_ENDPOINT); AirPurifierManager::InitInstance(EndpointId(AIR_PURIFIER_ENDPOINT), EndpointId(AIR_QUALITY_SENSOR_ENDPOINT), - EndpointId(TEMPERATURE_SENSOR_ENDPOINT), EndpointId(RELATIVE_HUMIDITY_SENSOR_ENDPOINT)); + EndpointId(TEMPERATURE_SENSOR_ENDPOINT), EndpointId(RELATIVE_HUMIDITY_SENSOR_ENDPOINT), + EndpointId(THERMOSTAT_ENDPOINT)); ConfigurationMgr().LogDeviceConfig(); diff --git a/examples/air-purifier-app/linux/BUILD.gn b/examples/air-purifier-app/linux/BUILD.gn index 0a0f86cac16ec4..0f4d2a489dc18a 100644 --- a/examples/air-purifier-app/linux/BUILD.gn +++ b/examples/air-purifier-app/linux/BUILD.gn @@ -33,6 +33,7 @@ executable("chip-air-purifier-app") { "${chip_root}/examples/air-purifier-app/air-purifier-common/src/air-purifier-manager.cpp", "${chip_root}/examples/air-purifier-app/air-purifier-common/src/air-quality-sensor-manager.cpp", "${chip_root}/examples/air-purifier-app/air-purifier-common/src/filter-delegates.cpp", + "${chip_root}/examples/air-purifier-app/air-purifier-common/src/thermostat-manager.cpp", "include/CHIPProjectAppConfig.h", "main.cpp", ] diff --git a/examples/air-purifier-app/linux/README.md b/examples/air-purifier-app/linux/README.md index 88f5be738c926d..d2352bca201e1a 100644 --- a/examples/air-purifier-app/linux/README.md +++ b/examples/air-purifier-app/linux/README.md @@ -4,9 +4,10 @@ An example showing the use of CHIP on the Linux. The document will describe how to build and run CHIP Air Purifier Example on A Linux System. This doc is tested on **Ubuntu 20.04 LTS**. -The Air Purifier is a composed device with Endpoint 1 being the Air Purifier. -Endpoint 2 is an Air Quality Sensor, Endpoint 3 is a Relative Humidity Sensor -and endpoint 4 is a Temperature Sensor. +The Air Purifier example demonstrates a fully functional Matter Air Purifier +which is a composed device with Endpoint 1 being the Air Purifier. Endpoint 2 is +an Air Quality Sensor, Endpoint 3 is a Relative Humidity Sensor, Endpoint 4 is a +Temperature Sensor and Endpoint 5 is a Thermostat. To cross-compile this example on x64 host and run on **NXP i.MX 8M Mini** **EVK**, see the associated @@ -99,11 +100,11 @@ To cross-compile this example on x64 host and run on **NXP i.MX 8M Mini** RX bytes:8609495 acl:14 sco:0 events:217484 errors:0 TX bytes:92185 acl:20 sco:0 commands:5259 errors:0 - - Run Linux Lighting Example App + - Run Linux Air Purifier Example App - $ cd ~/connectedhomeip/examples/lighting-app/linux - $ sudo out/debug/chip-lighting-app --ble-device [bluetooth device number] + $ cd ~/connectedhomeip/examples/air-purifier-app/linux + $ sudo out/debug/chip-air-purifier-app --ble-device [bluetooth device number] # In this example, the device we want to use is hci1 - $ sudo out/debug/chip-lighting-app --ble-device 1 + $ sudo out/debug/chip-air-purifier-app --ble-device 1 - Test the device using ChipTool on your laptop / workstation etc. diff --git a/examples/air-purifier-app/linux/main.cpp b/examples/air-purifier-app/linux/main.cpp index 59ef9cf9595755..98d8d405cfadfb 100644 --- a/examples/air-purifier-app/linux/main.cpp +++ b/examples/air-purifier-app/linux/main.cpp @@ -27,7 +27,7 @@ #define AIR_QUALITY_SENSOR_ENDPOINT 2 #define TEMPERATURE_SENSOR_ENDPOINT 3 #define RELATIVE_HUMIDITY_SENSOR_ENDPOINT 4 -// TODO: Add support for the thermostat endpoint in future PR. +#define THERMOSTAT_ENDPOINT 5 using namespace chip; using namespace chip::app; @@ -48,11 +48,13 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & void ApplicationInit() { AirPurifierManager::InitInstance(EndpointId(AIR_PURIFIER_ENDPOINT), EndpointId(AIR_QUALITY_SENSOR_ENDPOINT), - EndpointId(TEMPERATURE_SENSOR_ENDPOINT), EndpointId(RELATIVE_HUMIDITY_SENSOR_ENDPOINT)); + EndpointId(TEMPERATURE_SENSOR_ENDPOINT), EndpointId(RELATIVE_HUMIDITY_SENSOR_ENDPOINT), + EndpointId(THERMOSTAT_ENDPOINT)); SetParentEndpointForEndpoint(AIR_QUALITY_SENSOR_ENDPOINT, AIR_PURIFIER_ENDPOINT); SetParentEndpointForEndpoint(TEMPERATURE_SENSOR_ENDPOINT, AIR_PURIFIER_ENDPOINT); SetParentEndpointForEndpoint(RELATIVE_HUMIDITY_SENSOR_ENDPOINT, AIR_PURIFIER_ENDPOINT); + SetParentEndpointForEndpoint(THERMOSTAT_ENDPOINT, AIR_PURIFIER_ENDPOINT); } void ApplicationShutdown() diff --git a/examples/air-quality-sensor-app/air-quality-sensor-common/air-quality-sensor-app.matter b/examples/air-quality-sensor-app/air-quality-sensor-common/air-quality-sensor-app.matter index 93807b60380b51..1f165eecdcc27a 100644 --- a/examples/air-quality-sensor-app/air-quality-sensor-common/air-quality-sensor-app.matter +++ b/examples/air-quality-sensor-app/air-quality-sensor-common/air-quality-sensor-app.matter @@ -712,6 +712,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -768,10 +772,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2103,8 +2119,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/air-quality-sensor-app/linux/README.md b/examples/air-quality-sensor-app/linux/README.md index 6641a3e2f07de5..73139ef4aeeacb 100644 --- a/examples/air-quality-sensor-app/linux/README.md +++ b/examples/air-quality-sensor-app/linux/README.md @@ -152,3 +152,16 @@ Generate event `CarbonDioxideConcentrationMeasurement`, to change the CO2 value. ``` $ echo '{"Name":"CarbonDioxideConcentrationMeasurement","NewValue":400}' > /tmp/chip_air_quality_fifo_ ``` + +Generate event `CarbonMonoxideConcentrationMeasurement`, to change the CO value. + +``` +$ echo '{"Name":"CarbonMonoxideConcentrationMeasurement","NewValue":1}' > /tmp/chip_air_quality_fifo_ +``` + +Generate event `NitrogenDioxideConcentrationMeasurement`, to change the NOâ‚‚ +value. + +``` +$ echo '{"Name":"NitrogenDioxideConcentrationMeasurement","NewValue":1}' > /tmp/chip_air_quality_fifo_ +``` 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 4d1ac5923ff553..0e24f102d7c8ed 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 @@ -1697,6 +1697,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1753,10 +1757,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -3859,6 +3875,111 @@ provisional cluster ValveConfigurationAndControl = 129 { command Close(): DefaultSuccess = 1; } +/** This cluster provides a mechanism for querying data about electrical power as measured by the server. */ +provisional cluster ElectricalPowerMeasurement = 144 { + revision 1; + + enum MeasurementTypeEnum : enum16 { + kUnspecified = 0; + kVoltage = 1; + kActiveCurrent = 2; + kReactiveCurrent = 3; + kApparentCurrent = 4; + kActivePower = 5; + kReactivePower = 6; + kApparentPower = 7; + kRMSVoltage = 8; + kRMSCurrent = 9; + kRMSPower = 10; + kFrequency = 11; + kPowerFactor = 12; + kNeutralCurrent = 13; + kElectricalEnergy = 14; + } + + enum PowerModeEnum : enum8 { + kUnknown = 0; + kDC = 1; + kAC = 2; + } + + bitmap Feature : bitmap32 { + kDirectCurrent = 0x1; + kAlternatingCurrent = 0x2; + kPolyphasePower = 0x4; + kHarmonics = 0x8; + kPowerQuality = 0x10; + } + + struct MeasurementAccuracyRangeStruct { + int64s rangeMin = 0; + int64s rangeMax = 1; + optional percent100ths percentMax = 2; + optional percent100ths percentMin = 3; + optional percent100ths percentTypical = 4; + optional int64u fixedMax = 5; + optional int64u fixedMin = 6; + optional int64u fixedTypical = 7; + } + + struct MeasurementAccuracyStruct { + MeasurementTypeEnum measurementType = 0; + boolean measured = 1; + int64s minMeasuredValue = 2; + int64s maxMeasuredValue = 3; + MeasurementAccuracyRangeStruct accuracyRanges[] = 4; + } + + struct HarmonicMeasurementStruct { + int8u order = 0; + nullable int64s measurement = 1; + } + + struct MeasurementRangeStruct { + MeasurementTypeEnum measurementType = 0; + int64s min = 1; + int64s max = 2; + optional epoch_s startTimestamp = 3; + optional epoch_s endTimestamp = 4; + optional epoch_s minTimestamp = 5; + optional epoch_s maxTimestamp = 6; + optional systime_ms startSystime = 7; + optional systime_ms endSystime = 8; + optional systime_ms minSystime = 9; + optional systime_ms maxSystime = 10; + } + + info event MeasurementPeriodRanges = 0 { + MeasurementRangeStruct ranges[] = 0; + } + + readonly attribute PowerModeEnum powerMode = 0; + readonly attribute int8u numberOfMeasurementTypes = 1; + readonly attribute MeasurementAccuracyStruct accuracy[] = 2; + readonly attribute optional MeasurementRangeStruct ranges[] = 3; + readonly attribute optional nullable voltage_mv voltage = 4; + readonly attribute optional nullable amperage_ma activeCurrent = 5; + readonly attribute optional nullable amperage_ma reactiveCurrent = 6; + readonly attribute optional nullable amperage_ma apparentCurrent = 7; + readonly attribute nullable power_mw activePower = 8; + readonly attribute optional nullable power_mw reactivePower = 9; + readonly attribute optional nullable power_mw apparentPower = 10; + readonly attribute optional nullable voltage_mv RMSVoltage = 11; + readonly attribute optional nullable amperage_ma RMSCurrent = 12; + readonly attribute optional nullable power_mw RMSPower = 13; + readonly attribute optional nullable int64s frequency = 14; + readonly attribute optional nullable HarmonicMeasurementStruct harmonicCurrents[] = 15; + readonly attribute optional nullable HarmonicMeasurementStruct harmonicPhases[] = 16; + readonly attribute optional nullable int64s powerFactor = 17; + readonly attribute optional nullable amperage_ma neutralCurrent = 18; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + /** This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. */ provisional cluster ElectricalEnergyMeasurement = 145 { revision 1; @@ -3907,8 +4028,15 @@ provisional cluster ElectricalEnergyMeasurement = 145 { MeasurementAccuracyRangeStruct accuracyRanges[] = 4; } + struct CumulativeEnergyResetStruct { + optional nullable epoch_s importedResetTimestamp = 0; + optional nullable epoch_s exportedResetTimestamp = 1; + optional nullable systime_ms importedResetSystime = 2; + optional nullable systime_ms exportedResetSystime = 3; + } + struct EnergyMeasurementStruct { - int64s energy = 0; + energy_mwh energy = 0; optional epoch_s startTimestamp = 1; optional epoch_s endTimestamp = 2; optional systime_ms startSystime = 3; @@ -3930,6 +4058,7 @@ provisional cluster ElectricalEnergyMeasurement = 145 { readonly attribute optional nullable EnergyMeasurementStruct cumulativeEnergyExported = 2; readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyImported = 3; readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyExported = 4; + readonly attribute optional nullable CumulativeEnergyResetStruct cumulativeEnergyReset = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -7267,12 +7396,14 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; handle command TimeSnapshotResponse; + handle command PayloadTestRequest; + handle command PayloadTestResponse; } server cluster SoftwareDiagnostics { @@ -8083,6 +8214,35 @@ endpoint 1 { handle command Close; } + server cluster ElectricalPowerMeasurement { + emits event MeasurementPeriodRanges; + callback attribute powerMode; + callback attribute numberOfMeasurementTypes; + callback attribute accuracy; + callback attribute ranges; + callback attribute voltage; + callback attribute activeCurrent; + callback attribute reactiveCurrent; + callback attribute apparentCurrent; + callback attribute activePower; + callback attribute reactivePower; + callback attribute apparentPower; + callback attribute RMSVoltage; + callback attribute RMSCurrent; + callback attribute RMSPower; + callback attribute frequency; + callback attribute harmonicCurrents; + callback attribute harmonicPhases; + callback attribute powerFactor; + callback attribute neutralCurrent; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + callback attribute featureMap; + ram attribute clusterRevision default = 1; + } + server cluster ElectricalEnergyMeasurement { emits event CumulativeEnergyMeasured; emits event PeriodicEnergyMeasured; @@ -8091,11 +8251,12 @@ endpoint 1 { callback attribute cumulativeEnergyExported; callback attribute periodicEnergyImported; callback attribute periodicEnergyExported; + callback attribute cumulativeEnergyReset; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0x000F; + callback attribute featureMap; ram attribute clusterRevision default = 1; } 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 b06c93baae9358..cb3e8ec2930b5e 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 @@ -17,12 +17,6 @@ } ], "package": [ - { - "pathRelativity": "relativeToZap", - "path": "../../../src/app/zap-templates/app-templates.json", - "type": "gen-templates-json", - "version": "chip-v1" - }, { "pathRelativity": "relativeToZap", "path": "../../../src/app/zap-templates/zcl/zcl-with-test-extensions.json", @@ -30,6 +24,12 @@ "category": "matter", "version": 1, "description": "Matter SDK ZCL data with some extensions" + }, + { + "pathRelativity": "relativeToZap", + "path": "../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" } ], "endpointTypes": [ @@ -2863,6 +2863,22 @@ "source": "server", "isIncoming": 0, "isEnabled": 1 + }, + { + "name": "PayloadTestRequest", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "PayloadTestResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 } ], "attributes": [ @@ -9511,7 +9527,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -9667,7 +9683,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -11363,7 +11379,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -12690,6 +12706,426 @@ } ] }, + { + "name": "Electrical Power Measurement", + "code": 144, + "mfgCode": null, + "define": "ELECTRICAL_POWER_MEASUREMENT_CLUSTER", + "side": "server", + "enabled": 1, + "apiMaturity": "provisional", + "attributes": [ + { + "name": "PowerMode", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "PowerModeEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "NumberOfMeasurementTypes", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Accuracy", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Ranges", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Voltage", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "voltage_mv", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveCurrent", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "amperage_ma", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ReactiveCurrent", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "amperage_ma", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ApparentCurrent", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "amperage_ma", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActivePower", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "power_mw", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ReactivePower", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "power_mw", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ApparentPower", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "power_mw", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "RMSVoltage", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "voltage_mv", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "RMSCurrent", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "amperage_ma", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "RMSPower", + "code": 13, + "mfgCode": null, + "side": "server", + "type": "power_mw", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Frequency", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "int64s", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "HarmonicCurrents", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "HarmonicPhases", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PowerFactor", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int64s", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "NeutralCurrent", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "amperage_ma", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "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": null, + "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": null, + "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": null, + "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": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "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": "MeasurementPeriodRanges", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, { "name": "Electrical Energy Measurement", "code": 145, @@ -12779,6 +13215,22 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "CumulativeEnergyReset", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "CumulativeEnergyResetStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "GeneratedCommandList", "code": 65528, @@ -12850,10 +13302,10 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x000F", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/examples/all-clusters-app/all-clusters-common/src/electrical-energy-measurement-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/electrical-energy-measurement-stub.cpp new file mode 100644 index 00000000000000..41716d3033022b --- /dev/null +++ b/examples/all-clusters-app/all-clusters-common/src/electrical-energy-measurement-stub.cpp @@ -0,0 +1,42 @@ +/* + * + * 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 + +using namespace chip; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::ElectricalEnergyMeasurement; +using namespace chip::app::Clusters::ElectricalEnergyMeasurement::Structs; + +static std::unique_ptr gAttrAccess; + +void emberAfElectricalEnergyMeasurementClusterInitCallback(chip::EndpointId endpointId) +{ + VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1. + VerifyOrDie(!gAttrAccess); + + gAttrAccess = std::make_unique( + BitMask(Feature::kImportedEnergy, Feature::kExportedEnergy, Feature::kCumulativeEnergy, + Feature::kPeriodicEnergy), + BitMask(OptionalAttributes::kOptionalAttributeCumulativeEnergyReset)); + + if (gAttrAccess) + { + gAttrAccess->Init(); + } +} diff --git a/examples/all-clusters-app/all-clusters-common/src/electrical-power-measurement-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/electrical-power-measurement-stub.cpp new file mode 100644 index 00000000000000..bac73dd0441634 --- /dev/null +++ b/examples/all-clusters-app/all-clusters-common/src/electrical-power-measurement-stub.cpp @@ -0,0 +1,265 @@ +/* + * + * 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 + +using namespace chip; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::ElectricalPowerMeasurement; +using namespace chip::app::Clusters::ElectricalPowerMeasurement::Structs; + +namespace chip { +namespace app { +namespace Clusters { +namespace ElectricalPowerMeasurement { + +static MeasurementAccuracyRangeStruct::Type activeCurrentAccuracyRanges[] = { { .rangeMin = 500, .rangeMax = 1000 } }; + +class StubAccuracyIterator : public Delegate::AccuracyIterator +{ +public: + size_t Count() override; + bool Next(MeasurementAccuracyStruct::Type & output) override; + void Release() override; + +private: + uint8_t mIndex; +}; + +size_t StubAccuracyIterator::Count() +{ + return 1; +} + +bool StubAccuracyIterator::Next(MeasurementAccuracyStruct::Type & output) +{ + if (mIndex >= 1) + { + return false; + } + output.measurementType = MeasurementTypeEnum::kActiveCurrent; + output.measured = true; + output.minMeasuredValue = -10000000; + output.maxMeasuredValue = 10000000; + output.accuracyRanges = DataModel::List(activeCurrentAccuracyRanges); + mIndex++; + return true; +} + +void StubAccuracyIterator::Release() +{ + mIndex = 0; +} + +class StubRangeIterator : public Delegate::RangeIterator +{ +public: + size_t Count() override; + bool Next(MeasurementRangeStruct::Type & output) override; + void Release() override; +}; + +size_t StubRangeIterator::Count() +{ + return 0; +} + +bool StubRangeIterator::Next(MeasurementRangeStruct::Type & output) +{ + return false; +} + +void StubRangeIterator::Release() {} + +class StubHarmonicMeasurementIterator : public Delegate::HarmonicMeasurementIterator +{ +public: + size_t Count() override; + bool Next(HarmonicMeasurementStruct::Type & output) override; + void Release() override; +}; + +size_t StubHarmonicMeasurementIterator::Count() +{ + return 0; +} + +bool StubHarmonicMeasurementIterator::Next(HarmonicMeasurementStruct::Type & output) +{ + return false; +} + +void StubHarmonicMeasurementIterator::Release() {} + +static StubAccuracyIterator accuracyIterator; +static StubRangeIterator rangeIterator; +static StubHarmonicMeasurementIterator harmonicMeasurementIterator; + +class ElectricalPowerMeasurementDelegate : public Delegate +{ +public: + PowerModeEnum GetPowerMode() override; + uint8_t GetNumberOfMeasurementTypes() override; + AccuracyIterator * IterateAccuracy() override; + RangeIterator * IterateRanges() override; + DataModel::Nullable GetVoltage() override; + DataModel::Nullable GetActiveCurrent() override; + DataModel::Nullable GetReactiveCurrent() override; + DataModel::Nullable GetApparentCurrent() override; + DataModel::Nullable GetActivePower() override; + DataModel::Nullable GetReactivePower() override; + DataModel::Nullable GetApparentPower() override; + DataModel::Nullable GetRMSVoltage() override; + DataModel::Nullable GetRMSCurrent() override; + DataModel::Nullable GetRMSPower() override; + DataModel::Nullable GetFrequency() override; + HarmonicMeasurementIterator * IterateHarmonicCurrents() override; + HarmonicMeasurementIterator * IterateHarmonicPhases() override; + DataModel::Nullable GetPowerFactor() override; + DataModel::Nullable GetNeutralCurrent() override; + + ~ElectricalPowerMeasurementDelegate() = default; +}; + +PowerModeEnum ElectricalPowerMeasurementDelegate::GetPowerMode() +{ + return PowerModeEnum::kAc; +} + +uint8_t ElectricalPowerMeasurementDelegate::GetNumberOfMeasurementTypes() +{ + return 1; +} + +Delegate::AccuracyIterator * ElectricalPowerMeasurementDelegate::IterateAccuracy() +{ + return &accuracyIterator; +} + +Delegate::RangeIterator * ElectricalPowerMeasurementDelegate::IterateRanges() +{ + return &rangeIterator; +} + +DataModel::Nullable ElectricalPowerMeasurementDelegate::GetVoltage() +{ + return {}; +} + +DataModel::Nullable ElectricalPowerMeasurementDelegate::GetActiveCurrent() +{ + return {}; +} + +DataModel::Nullable ElectricalPowerMeasurementDelegate::GetReactiveCurrent() +{ + return {}; +} + +DataModel::Nullable ElectricalPowerMeasurementDelegate::GetApparentCurrent() +{ + return {}; +} + +DataModel::Nullable ElectricalPowerMeasurementDelegate::GetActivePower() +{ + return DataModel::Nullable(10000); +} + +DataModel::Nullable ElectricalPowerMeasurementDelegate::GetReactivePower() +{ + return {}; +} + +DataModel::Nullable ElectricalPowerMeasurementDelegate::GetApparentPower() +{ + return {}; +} + +DataModel::Nullable ElectricalPowerMeasurementDelegate::GetRMSVoltage() +{ + return {}; +} + +DataModel::Nullable ElectricalPowerMeasurementDelegate::GetRMSCurrent() +{ + return {}; +} + +DataModel::Nullable ElectricalPowerMeasurementDelegate::GetRMSPower() +{ + return {}; +} + +DataModel::Nullable ElectricalPowerMeasurementDelegate::GetFrequency() +{ + return {}; +} + +Delegate::HarmonicMeasurementIterator * ElectricalPowerMeasurementDelegate::IterateHarmonicCurrents() +{ + return &harmonicMeasurementIterator; +} + +Delegate::HarmonicMeasurementIterator * ElectricalPowerMeasurementDelegate::IterateHarmonicPhases() +{ + return &harmonicMeasurementIterator; +} + +DataModel::Nullable ElectricalPowerMeasurementDelegate::GetPowerFactor() +{ + return {}; +} + +DataModel::Nullable ElectricalPowerMeasurementDelegate::GetNeutralCurrent() +{ + return {}; +} + +} // namespace ElectricalPowerMeasurement +} // namespace Clusters +} // namespace app +} // namespace chip + +static std::unique_ptr gDelegate; +static std::unique_ptr gInstance; + +void emberAfElectricalPowerMeasurementClusterInitCallback(chip::EndpointId endpointId) +{ + VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1. + VerifyOrDie(!gInstance); + + gDelegate = std::make_unique(); + if (gDelegate) + { + gInstance = std::make_unique( + endpointId, *gDelegate, + BitMask(Feature::kDirectCurrent, Feature::kAlternatingCurrent, Feature::kPolyphasePower, + Feature::kHarmonics, Feature::kPowerQuality), + BitMask( + OptionalAttributes::kOptionalAttributeRanges, OptionalAttributes::kOptionalAttributeVoltage, + OptionalAttributes::kOptionalAttributeActiveCurrent, OptionalAttributes::kOptionalAttributeReactiveCurrent, + OptionalAttributes::kOptionalAttributeApparentCurrent, OptionalAttributes::kOptionalAttributeReactivePower, + OptionalAttributes::kOptionalAttributeApparentPower, OptionalAttributes::kOptionalAttributeRMSVoltage, + OptionalAttributes::kOptionalAttributeRMSCurrent, OptionalAttributes::kOptionalAttributeRMSPower, + OptionalAttributes::kOptionalAttributeFrequency, OptionalAttributes::kOptionalAttributePowerFactor, + OptionalAttributes::kOptionalAttributeNeutralCurrent)); + + gInstance->Init(); + } +} diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index b47def73690bf8..641cbca7b55af0 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -98,6 +98,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-washer-controls-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-dryer-controls-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/electrical-energy-measurement-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/electrical-power-measurement-server" ) diff --git a/examples/all-clusters-app/linux/BUILD.gn b/examples/all-clusters-app/linux/BUILD.gn index 20dd248abf2a1a..799c9ab3f1f451 100644 --- a/examples/all-clusters-app/linux/BUILD.gn +++ b/examples/all-clusters-app/linux/BUILD.gn @@ -29,6 +29,8 @@ source_set("chip-all-clusters-common") { "${chip_root}/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/dishwasher-alarm-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/dishwasher-mode.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/electrical-energy-measurement-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/electrical-power-measurement-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-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/laundry-dryer-controls-delegate-impl.cpp", diff --git a/examples/all-clusters-app/tizen/BUILD.gn b/examples/all-clusters-app/tizen/BUILD.gn index e9bb7f56e4bfaa..23a045a7532429 100644 --- a/examples/all-clusters-app/tizen/BUILD.gn +++ b/examples/all-clusters-app/tizen/BUILD.gn @@ -28,6 +28,8 @@ source_set("chip-all-clusters-common") { "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/electrical-energy-measurement-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/electrical-power-measurement-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-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/oven-modes.cpp", diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index 7794726e68dcd7..69c7e8d7ddb8eb 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -1577,6 +1577,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1633,10 +1637,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -6071,12 +6087,14 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; handle command TimeSnapshotResponse; + handle command PayloadTestRequest; + handle command PayloadTestResponse; } server cluster SoftwareDiagnostics { diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap index 2f7a83ee7362de..2d64015215a5ce 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap @@ -2464,6 +2464,22 @@ "source": "server", "isIncoming": 0, "isEnabled": 1 + }, + { + "name": "PayloadTestRequest", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "PayloadTestResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 } ], "attributes": [ diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/AddressCommissioningFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/AddressCommissioningFragment.kt index 8f95c2d0b00a22..64bd9b31c55a66 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/AddressCommissioningFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/AddressCommissioningFragment.kt @@ -51,6 +51,7 @@ class AddressCommissioningFragment : Fragment() { val address = binding.addressEditText.text.toString() val discriminator = binding.discriminatorEditText.text.toString() val pincode = binding.pincodeEditText.text.toString() + val port = binding.portEditText.text.toString() if (address.isEmpty() || discriminator.isEmpty() || pincode.isEmpty()) { Log.e(TAG, "Address, discriminator, or pincode was empty: $address $discriminator $pincode") @@ -62,7 +63,8 @@ class AddressCommissioningFragment : Fragment() { CHIPDeviceInfo( discriminator = discriminator.toInt(), setupPinCode = pincode.toLong(), - ipAddress = address + ipAddress = address, + port = port.toInt() ) ) } @@ -169,7 +171,7 @@ class AddressCommissioningFragment : Fragment() { val deviceController = ChipClient.getDeviceController(requireContext()) for (i in 0..10) { val device = deviceController.getDiscoveredDevice(i) ?: break - ipAddressList.add("${device.ipAddress}, ${device.discriminator}") + ipAddressList.add("${device.ipAddress}, ${device.discriminator}, ${device.port}") } requireActivity().runOnUiThread { binding.discoverListSpinner.adapter = @@ -179,9 +181,11 @@ class AddressCommissioningFragment : Fragment() { override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) { val address = ipAddressList[position].split(",")[0].trim() val discriminator = ipAddressList[position].split(",")[1].trim() + val port = ipAddressList[position].split(",")[2].trim() binding.addressEditText.setText(address) binding.discriminatorEditText.setText(discriminator) + binding.portEditText.setText(port) } override fun onNothingSelected(parent: AdapterView<*>) {} diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/DeviceProvisioningFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/DeviceProvisioningFragment.kt index 991a1f58311e55..aa3488248b81a3 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/DeviceProvisioningFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/DeviceProvisioningFragment.kt @@ -160,7 +160,6 @@ class DeviceProvisioningFragment : Fragment() { private fun pairDeviceWithAddress() { // IANA CHIP port - val port = 5540 val id = DeviceIdUtil.getNextAvailableId(requireContext()) DeviceIdUtil.setNextAvailableId(requireContext(), id + 1) @@ -171,7 +170,7 @@ class DeviceProvisioningFragment : Fragment() { deviceController.pairDeviceWithAddress( id, deviceInfo.ipAddress, - port, + deviceInfo.port, deviceInfo.discriminator, deviceInfo.setupPinCode, null diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/setuppayloadscanner/CHIPDeviceInfo.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/setuppayloadscanner/CHIPDeviceInfo.kt index cbeb3746665b6f..d8fb51bbb3d844 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/setuppayloadscanner/CHIPDeviceInfo.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/setuppayloadscanner/CHIPDeviceInfo.kt @@ -36,6 +36,7 @@ data class CHIPDeviceInfo( val discoveryCapabilities: MutableSet = mutableSetOf(), val isShortDiscriminator: Boolean = false, val ipAddress: String? = null, + val port: Int = 5540 ) : Parcelable { companion object { diff --git a/examples/android/CHIPTool/app/src/main/res/layout/address_commissioning_fragment.xml b/examples/android/CHIPTool/app/src/main/res/layout/address_commissioning_fragment.xml index b82df0400a7a45..e2ad4c58cf4d7a 100644 --- a/examples/android/CHIPTool/app/src/main/res/layout/address_commissioning_fragment.xml +++ b/examples/android/CHIPTool/app/src/main/res/layout/address_commissioning_fragment.xml @@ -19,7 +19,7 @@ android:id="@+id/address_commissioning_fragment_flow" android:layout_width="0dp" android:layout_height="wrap_content" - app:constraint_referenced_ids="addressLabel,addressEditText,discriminatorLabel,discriminatorEditText,pincodeLabel,pincodeEditText" + app:constraint_referenced_ids="addressLabel,addressEditText,discriminatorLabel,discriminatorEditText,pincodeLabel,pincodeEditText,portLabel,portEditText" app:flow_horizontalStyle="packed" app:flow_wrapMode="aligned" app:flow_maxElementsWrap="2" @@ -75,6 +75,22 @@ android:inputType="number" android:text="@string/default_pincode" /> + + + + Commission with IP address 3840 20202021 + 5540 Device address Discriminator Pincode + Port Commission Discover Wi-Fi Scan diff --git a/examples/bridge-app/bridge-common/bridge-app.matter b/examples/bridge-app/bridge-common/bridge-app.matter index 55712fe444589c..a8b3e69a88e610 100644 --- a/examples/bridge-app/bridge-common/bridge-app.matter +++ b/examples/bridge-app/bridge-common/bridge-app.matter @@ -1162,6 +1162,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1218,10 +1222,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2049,8 +2065,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter b/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter index bb412cca740ea1..2dce5e89dda11d 100644 --- a/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter +++ b/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter @@ -935,6 +935,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -991,10 +995,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1753,8 +1769,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_airpurifier_73a6fe2651.matter b/examples/chef/devices/rootnode_airpurifier_73a6fe2651.matter index d26348310ca696..554cdfa7e42e23 100644 --- a/examples/chef/devices/rootnode_airpurifier_73a6fe2651.matter +++ b/examples/chef/devices/rootnode_airpurifier_73a6fe2651.matter @@ -759,6 +759,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -815,10 +819,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1443,8 +1459,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.matter b/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.matter index a06d523bd40cf3..734ed039932a9f 100644 --- a/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.matter +++ b/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.matter @@ -682,6 +682,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -738,10 +742,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** Commands to trigger a Node to allow a new Administrator to commission it. */ @@ -2298,8 +2314,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.matter b/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.matter index ebfb6e54b28213..00938a44bbfa77 100644 --- a/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.matter +++ b/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.matter @@ -820,6 +820,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -876,10 +880,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1965,8 +1981,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.matter b/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.matter index c2c74d4a969059..c5c71d597ebe74 100644 --- a/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.matter +++ b/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.matter @@ -842,6 +842,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -898,10 +902,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1992,8 +2008,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter index dfb0d2c30da30f..8bdb0183370199 100644 --- a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter +++ b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter @@ -1033,6 +1033,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1089,10 +1093,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1834,8 +1850,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter b/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter index 51dec4bd2d148c..a578cc06a5d79f 100644 --- a/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter +++ b/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter @@ -1018,6 +1018,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1074,10 +1078,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2020,8 +2036,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter index 65e16fc68d08b4..f49d0a1e6e03b1 100644 --- a/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter +++ b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter @@ -918,6 +918,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -974,10 +978,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1450,8 +1466,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter index 76e54a5ccdc84a..2878ac5634ae72 100644 --- a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter +++ b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter @@ -1115,6 +1115,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1171,10 +1175,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1673,8 +1689,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_dishwasher_cc105034fe.matter b/examples/chef/devices/rootnode_dishwasher_cc105034fe.matter index 2803433e108d20..69c30f0de726db 100644 --- a/examples/chef/devices/rootnode_dishwasher_cc105034fe.matter +++ b/examples/chef/devices/rootnode_dishwasher_cc105034fe.matter @@ -645,6 +645,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -701,10 +705,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Wi-Fi Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1269,8 +1285,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter index 99b8356ecdf6aa..5819641c778086 100644 --- a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter +++ b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter @@ -918,6 +918,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -974,10 +978,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2084,8 +2100,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter index 062f3d8421a83c..9f4fdb2ae9bb15 100644 --- a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter +++ b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter @@ -1115,6 +1115,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1171,10 +1175,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1950,8 +1966,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter b/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter index af697266d1b2f6..71d511aedcc508 100644 --- a/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter +++ b/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter @@ -897,6 +897,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -953,10 +957,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1495,8 +1511,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter index 798bbaf3c50af3..0b312b4b418f7d 100644 --- a/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter +++ b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter @@ -918,6 +918,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -974,10 +978,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1449,8 +1465,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_genericswitch_9866e35d0b.matter b/examples/chef/devices/rootnode_genericswitch_9866e35d0b.matter index d343385b18d5da..8e2d0166cc44a9 100644 --- a/examples/chef/devices/rootnode_genericswitch_9866e35d0b.matter +++ b/examples/chef/devices/rootnode_genericswitch_9866e35d0b.matter @@ -605,6 +605,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -661,10 +665,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** This cluster exposes interactions with a switch device, for the purpose of using those interactions by other devices. @@ -1089,8 +1105,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter index bf73232fd78f06..d1aee2ea4e8135 100644 --- a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter +++ b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter @@ -1115,6 +1115,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1171,10 +1175,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2083,8 +2099,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter index 6453623a943ebe..5dc16ab06089c9 100644 --- a/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter +++ b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter @@ -918,6 +918,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -974,10 +978,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1449,8 +1465,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_laundrywasher_fb10d238c8.matter b/examples/chef/devices/rootnode_laundrywasher_fb10d238c8.matter index 372b79a19f8c6a..b9c7cc84adc95b 100644 --- a/examples/chef/devices/rootnode_laundrywasher_fb10d238c8.matter +++ b/examples/chef/devices/rootnode_laundrywasher_fb10d238c8.matter @@ -645,6 +645,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -701,10 +705,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Wi-Fi Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1269,8 +1285,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter index 71923d22279635..9990e621f31f14 100644 --- a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter +++ b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter @@ -918,6 +918,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -974,10 +978,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1455,8 +1471,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter index 73e4c3ce1d1bee..bb7f9870460ff9 100644 --- a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter +++ b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter @@ -918,6 +918,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -974,10 +978,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1474,8 +1490,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter b/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter index 098de3b8bc0c04..0dc109e61cbc92 100644 --- a/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter +++ b/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter @@ -1115,6 +1115,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1171,10 +1175,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1630,8 +1646,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_onofflight_samplemei.matter b/examples/chef/devices/rootnode_onofflight_samplemei.matter index 792908dc70e8a1..d4bbc6d33e3de9 100644 --- a/examples/chef/devices/rootnode_onofflight_samplemei.matter +++ b/examples/chef/devices/rootnode_onofflight_samplemei.matter @@ -1115,6 +1115,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1171,10 +1175,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1662,8 +1678,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter index aa6867dc6dd7b5..255cd7f38ab0cb 100644 --- a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter +++ b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter @@ -1062,6 +1062,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1118,10 +1122,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1577,8 +1593,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter index a1ef7be5a8875b..969cfb05c1cf8d 100644 --- a/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter +++ b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter @@ -990,6 +990,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1046,10 +1050,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1505,8 +1521,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter index 6a64f874178e92..c3c621998dbe3b 100644 --- a/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter +++ b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter @@ -918,6 +918,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -974,10 +978,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1476,8 +1492,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_pump_5f904818cc.matter b/examples/chef/devices/rootnode_pump_5f904818cc.matter index 2d0689d5f25371..bf325a7a91f11d 100644 --- a/examples/chef/devices/rootnode_pump_5f904818cc.matter +++ b/examples/chef/devices/rootnode_pump_5f904818cc.matter @@ -717,6 +717,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -773,10 +777,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** Commands to trigger a Node to allow a new Administrator to commission it. */ @@ -1346,8 +1362,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_pump_a811bb33a0.matter b/examples/chef/devices/rootnode_pump_a811bb33a0.matter index 4c2184dff0c73e..1b80123fe173c8 100644 --- a/examples/chef/devices/rootnode_pump_a811bb33a0.matter +++ b/examples/chef/devices/rootnode_pump_a811bb33a0.matter @@ -717,6 +717,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -773,10 +777,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** Commands to trigger a Node to allow a new Administrator to commission it. */ @@ -1289,8 +1305,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_refrigerator_temperaturecontrolledcabinet_temperaturecontrolledcabinet_ffdb696680.matter b/examples/chef/devices/rootnode_refrigerator_temperaturecontrolledcabinet_temperaturecontrolledcabinet_ffdb696680.matter index aa021d9050990d..9564a21d3a62e5 100644 --- a/examples/chef/devices/rootnode_refrigerator_temperaturecontrolledcabinet_temperaturecontrolledcabinet_ffdb696680.matter +++ b/examples/chef/devices/rootnode_refrigerator_temperaturecontrolledcabinet_temperaturecontrolledcabinet_ffdb696680.matter @@ -645,6 +645,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -701,10 +705,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Wi-Fi Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1235,8 +1251,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_roboticvacuumcleaner_1807ff0c49.matter b/examples/chef/devices/rootnode_roboticvacuumcleaner_1807ff0c49.matter index dc190ad05ecd31..f2ab0c354ca1cf 100644 --- a/examples/chef/devices/rootnode_roboticvacuumcleaner_1807ff0c49.matter +++ b/examples/chef/devices/rootnode_roboticvacuumcleaner_1807ff0c49.matter @@ -682,6 +682,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -738,10 +742,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** Commands to trigger a Node to allow a new Administrator to commission it. */ @@ -1289,8 +1305,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.matter b/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.matter index c41e4fcc03b29b..de4a1c961cd506 100644 --- a/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.matter +++ b/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.matter @@ -754,6 +754,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -810,10 +814,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** Commands to trigger a Node to allow a new Administrator to commission it. */ @@ -1670,8 +1686,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_smokecoalarm_686fe0dcb8.matter b/examples/chef/devices/rootnode_smokecoalarm_686fe0dcb8.matter index af7c3a340cf24d..49b97d52aa338b 100644 --- a/examples/chef/devices/rootnode_smokecoalarm_686fe0dcb8.matter +++ b/examples/chef/devices/rootnode_smokecoalarm_686fe0dcb8.matter @@ -941,6 +941,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -997,10 +1001,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** Commands to trigger a Node to allow a new Administrator to commission it. */ @@ -1482,8 +1498,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter index 2862703d045d1d..dbe6c0a49eb1dd 100644 --- a/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter +++ b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter @@ -1038,6 +1038,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1094,10 +1098,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1553,8 +1569,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter index 6993a6fa5e9a6f..c7b567c011442e 100644 --- a/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter +++ b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter @@ -918,6 +918,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -974,10 +978,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1449,8 +1465,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter index 4ab01b329d34aa..fdefbfc5c9dbee 100644 --- a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter +++ b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter @@ -918,6 +918,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -974,10 +978,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1993,8 +2009,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter index 20fa873418127e..a4f8f2da0e440c 100644 --- a/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter +++ b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter @@ -918,6 +918,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -974,10 +978,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1586,8 +1602,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h index 4fd49ac72b6c5e..3b7f83e49fc201 100644 --- a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h +++ b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h @@ -195,7 +195,8 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi template >::value, int> = 0> static const char * GetAttributeValuesDescription() { - return "Comma-separated list of attribute values to write. Each value is represented as follows, depending on the type:\n" + return "Semicolon-separated list of attribute values to write. Each value is represented as follows, depending on the " + "type:\n" " * struct: a JSON-encoded object, with field ids as keys.\n" " * list: a JSON-encoded array of values.\n" " * null: A literal null.\n" @@ -213,7 +214,9 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi " a) The number directly, if it's not an integer.\n" " b) A string starting with \"d:\" followed by the number.\n" " * octet string: A string starting with \"hex:\" followed by the hex encoding of the bytes.\n" - " * string: A string with the characters."; + " * string: A string with the characters.\n" + "\n" + " Example values: '10;20', '10;\"u:20\"', '\"hex:aabbcc\";\"hello\"'."; } static const char * GetTypedAttributeValuesDescription() { return "Comma-separated list of attribute values to write."; } diff --git a/examples/chip-tool/py_matter_chip_tool_adapter/matter_chip_tool_adapter/decoder.py b/examples/chip-tool/py_matter_chip_tool_adapter/matter_chip_tool_adapter/decoder.py index a7dd32b7d43a85..cd77147fff40d6 100644 --- a/examples/chip-tool/py_matter_chip_tool_adapter/matter_chip_tool_adapter/decoder.py +++ b/examples/chip-tool/py_matter_chip_tool_adapter/matter_chip_tool_adapter/decoder.py @@ -322,7 +322,7 @@ def run(self, specs, value, cluster_name: str, typename: str, array: bool): provided_field_name = provided_field_name[0].lower( ) + provided_field_name[1:] - if provided_field_name in value: + if provided_field_name in value and provided_field_name != field_name: value[field_name] = self.run( specs, value[provided_field_name], diff --git a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter index 4372e568a2927d..64e96b45fa5983 100644 --- a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter +++ b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter @@ -897,6 +897,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -953,10 +957,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1790,8 +1806,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/darwin-framework-tool/BUILD.gn b/examples/darwin-framework-tool/BUILD.gn index e31acadec076b6..9dcbddbbfd8cbf 100644 --- a/examples/darwin-framework-tool/BUILD.gn +++ b/examples/darwin-framework-tool/BUILD.gn @@ -30,15 +30,13 @@ assert(chip_build_tools) declare_args() { chip_codesign = current_os == "ios" - # When config_enable_yaml_tests is false, the Matter SDK options are not available. - if (!config_enable_yaml_tests) { - chip_inet_config_enable_ipv4 = true - if (!defined(chip_config_network_layer_ble)) { - chip_config_network_layer_ble = true - } - if (!defined(is_clang)) { - is_clang = false - } + chip_inet_config_enable_ipv4 = true + + if (!defined(chip_config_network_layer_ble)) { + chip_config_network_layer_ble = true + } + if (!defined(is_clang)) { + is_clang = false } enable_provisional_features = config_enable_yaml_tests @@ -125,12 +123,17 @@ action("build-darwin-framework") { output_name = "Matter.framework" outputs = [ "${root_out_dir}/macos_framework_output/Build/Products/${output_sdk_type}/${output_name}", + "${root_out_dir}/macos_framework_output/Build/Intermediates.noindex/Matter.build/${output_sdk_type}/Matter.build/out/gen/include", "${root_build_dir}/darwin_framework_build.log", "${root_out_dir}/macos_framework_output/ModuleCache.noindex/", "${root_out_dir}/macos_framework_output/Logs", "${root_out_dir}/macos_framework_output/Index", "${root_out_dir}/macos_framework_output/Build", ] + + if (sdk == "macosx") { + outputs += [ "${root_out_dir}/macos_framework_output/Build/Intermediates.noindex/Matter.build/${output_sdk_type}/Matter.build/out/lib/libCHIP.a" ] + } } config("config") { @@ -150,7 +153,7 @@ config("config") { ] defines = [ - "CONFIG_ENABLE_YAML_TESTS=${config_enable_yaml_tests}", + "CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=", "CONFIG_USE_INTERACTIVE_MODE=${config_use_interactive_mode}", # Disable availability annotations in Matter.framework headers because we @@ -171,6 +174,8 @@ executable("darwin-framework-tool") { "${chip_root}/examples/chip-tool/commands/common/Commands.cpp", "${chip_root}/examples/chip-tool/commands/common/Commands.h", "${chip_root}/examples/chip-tool/commands/common/HexConversion.h", + "${chip_root}/examples/common/websocket-server/WebSocketServer.cpp", + "${chip_root}/examples/common/websocket-server/WebSocketServer.h", "${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp", "commands/bdx/Commands.h", "commands/bdx/DownloadLogCommand.mm", @@ -214,17 +219,14 @@ executable("darwin-framework-tool") { deps = [ ":build-darwin-framework", + "${chip_root}/third_party/libwebsockets", jsoncpp_root, ] if (config_use_interactive_mode) { sources += [ "commands/interactive/InteractiveCommands.mm" ] - deps += [ - "${chip_root}/examples/common/websocket-server", - "${chip_root}/src/platform/logging:headers", - "${editline_root}:editline", - ] + deps += [ "${editline_root}:editline" ] } ldflags = [ @@ -237,63 +239,35 @@ executable("darwin-framework-tool") { "Security.framework", ] - # When config_enable_yaml_tests=true the Matter SDK is pulled in as a dependency because the code of the test suite - # uses some helpers from the Matter SDK. As a result, the SDK is built twice. Once because of this dependency and once - # when the Matter.framework is built. - # It may results in different versions of the Matter SDK between the output binary and the linked Matter.framework. - # - # When config_enable_yaml_tests=false the Matter SDK is built once when the Matter.framework is built and the resulting - # libCHIP.a library is linked statically to the output binary. - if (config_enable_yaml_tests) { - deps += [ - "${chip_root}/src/app/tests/suites/commands/delay", - - # IM is needed for MTRError - "${chip_root}/src/app/tests/suites/commands/interaction_model", - - # Log is needed by tests UserPrompt and Log - "${chip_root}/src/app/tests/suites/commands/log", - - # System is needed by tests FactoryReset etc.. - "${chip_root}/src/app/tests/suites/commands/system", - - # pics is needed by tests - "${chip_root}/src/app/tests/suites/pics", - "${chip_root}/src/protocols/interaction_model", - ] - - defines = [] - } else { - include_dirs = [ - "${chip_root}/config/standalone/", - "${chip_root}/src/", - "${chip_root}/src/include/", - "${chip_root}/src/protocols/", - "${chip_root}/src/protocols/interaction_model", - "${chip_root}/third_party/nlassert/repo/include/", - "${chip_root}/third_party/nlio/repo/include/", - "${chip_root}/zzz_generated/app-common/", - "${root_gen_dir}/include", - "${root_out_dir}/macos_framework_output/Build/Intermediates.noindex/Matter.build/${output_sdk_type}/Matter.build/out/gen/include", - ] + include_dirs = [ + "${chip_root}/config/standalone/", + "${chip_root}/src/", + "${chip_root}/src/include/", + "${chip_root}/src/protocols/", + "${chip_root}/src/protocols/interaction_model", + "${chip_root}/third_party/nlassert/repo/include/", + "${chip_root}/third_party/nlio/repo/include/", + "${chip_root}/zzz_generated/app-common/", + "${root_gen_dir}/include", + "${root_out_dir}/macos_framework_output/Build/Intermediates.noindex/Matter.build/${output_sdk_type}/Matter.build/out/gen/include", + ] - defines = [ - "CHIP_HAVE_CONFIG_H=1", - "CHIP_SYSTEM_CONFIG_USE_SOCKETS=1", - ] + defines = [ + "CHIP_HAVE_CONFIG_H=1", + "CHIP_SYSTEM_CONFIG_USE_SOCKETS=1", + ] - frameworks += [ - "CoreFoundation.framework", - "Foundation.framework", - "CoreBluetooth.framework", - "Network.framework", - ] + frameworks += [ + "CoreFoundation.framework", + "Foundation.framework", + "CoreBluetooth.framework", + "Network.framework", + ] - # Other SDKs are linked statically to Matter.framework but the macosx SDK is linked dynamically but needs some symbols that are - # not exposed by the dylib. - if (sdk == "macosx") { - libs = [ "${root_out_dir}/macos_framework_output/Build/Intermediates.noindex/Matter.build/${output_sdk_type}/Matter.build/out/lib/libCHIP.a" ] - } + # Other SDKs are linked statically to Matter.framework but the macosx SDK is linked dynamically but needs some symbols that are + # not exposed by the dylib. + if (sdk == "macosx") { + libs = [ "${root_out_dir}/macos_framework_output/Build/Intermediates.noindex/Matter.build/${output_sdk_type}/Matter.build/out/lib/libCHIP.a" ] } if (enable_provisional_features) { diff --git a/examples/darwin-framework-tool/args.gni b/examples/darwin-framework-tool/args.gni index 8308b2a9bcffaa..6f0f1010a05f5d 100644 --- a/examples/darwin-framework-tool/args.gni +++ b/examples/darwin-framework-tool/args.gni @@ -16,15 +16,13 @@ import("//build_overrides/chip.gni") import("${chip_root}/config/standalone/args.gni") -import("${chip_root}/examples/chip-tool/chip-tool.gni") - chip_crypto = "boringssl" -if (config_enable_yaml_tests) { - chip_device_project_config_include = "" - chip_project_config_include = "" +chip_device_project_config_include = + "${chip_root}/examples/darwin-framework-tool/include/CHIPProjectAppConfig.h" +chip_project_config_include = + "${chip_root}/examples/darwin-framework-tool/include/CHIPProjectAppConfig.h" - chip_project_config_include_dirs = - [ "${chip_root}/examples/darwin-framework-tool/include" ] - chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] -} +chip_project_config_include_dirs = + [ "${chip_root}/examples/darwin-framework-tool/include" ] +chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] diff --git a/examples/darwin-framework-tool/main.mm b/examples/darwin-framework-tool/main.mm index 070ae3188407d4..0ba2d1553e9c88 100644 --- a/examples/darwin-framework-tool/main.mm +++ b/examples/darwin-framework-tool/main.mm @@ -31,7 +31,6 @@ #include "commands/storage/Commands.h" #include -#include int main(int argc, const char * argv[]) { @@ -47,7 +46,6 @@ int main(int argc, const char * argv[]) registerCommandsPayload(commands); registerClusterOtaSoftwareUpdateProviderInteractive(commands); registerCommandsStorage(commands); - registerCommandsTests(commands); registerClusters(commands); return commands.Run(argc, (char **) argv); } diff --git a/examples/darwin-framework-tool/templates/tests/ciTests.json b/examples/darwin-framework-tool/templates/tests/ciTests.json deleted file mode 100644 index 66886c7d769ff5..00000000000000 --- a/examples/darwin-framework-tool/templates/tests/ciTests.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "include": "../../../../src/app/tests/suites/ciTests.json", - "disable": [ - "Test_TC_SC_4_1", - "Test_TC_SC_5_2", - "TestBasicInformation disabled because codegen test don't support writing readonly attributes", - "TestBasicInformation", - "TestClusterComplexTypes", - "TestEvents", - "TestDiscovery", - "TestGroupMessaging", - "Test_TC_BRBINFO_2_1", - "Test_TC_DGTHREAD_2_1", - "Test_TC_DGTHREAD_2_2", - "Test_TC_DGTHREAD_2_3", - "Test_TC_DGTHREAD_2_4", - "Test_TC_CC_7_2", - "Test_TC_CC_6_2", - "Test_TC_CC_6_3", - "Test_TC_CC_8_1", - "Test_TC_APPLAUNCHER_3_7", - "Test_TC_APPLAUNCHER_3_8", - "Test_TC_APPLAUNCHER_3_9", - "Test_TC_BINFO_2_1", - "Test_TC_SWTCH_2_1", - "Test_TC_G_2_1", - "Test_TC_FLABEL_2_1", - "Test_TC_TSTAT_2_1", - "Test_TC_TSTAT_2_2", - "Test_TC_ACL_2_4", - "Test_TC_ACL_2_7", - "Test_TC_ACL_2_8", - "Test_TC_ACL_2_9", - "Test_TC_ACL_2_10", - "Disabled due to GetCommissionerRootCertificate command not being supported", - "Test_TC_OPCREDS_3_7", - "DL_LockUnlock", - "Disabled due to Events verification not supported", - "Test_TC_BINFO_2_2", - "Test_TC_ACL_2_5", - "Test_TC_ACL_2_6", - "Test_TC_SMOKECO_2_2", - "Test_TC_SMOKECO_2_3", - "Test_TC_SMOKECO_2_4", - "Test_TC_SMOKECO_2_5", - "Test_TC_DGGEN_2_1", - "Test_TC_OPSTATE_2_4", - "Disabled due to undefined properties", - "Test_TC_SMOKECO_2_6", - "Disabled because the power source configuration cluster is now deprecated and not present in all-clusters", - "Test_TC_PSCFG_1_1", - "Test_TC_PSCFG_2_1", - "Test_TC_PSCFG_2_2", - "Disabled because darwin-framework-tool does not support GetCommissionerRootCertificate", - "Test_AddNewFabricFromExistingFabric", - "Disabled because darwin-framework-tool does not support EqualityCommands pseudo-cluster", - "Test_TC_S_2_2", - "Test_TC_TCCM_3_1", - "Test_TC_TCCM_3_2", - "Test_TC_TCCM_3_3", - "Test_TC_RVCRUNM_3_1", - "Test_TC_TCTL_2_1", - "Test_TC_LWM_3_1", - "Test_TC_LWM_3_2", - "Test_TC_LWM_3_3", - "Test_TC_OTCCM_2_1", - "Test_TC_OTCCM_3_1", - "Test_TC_OTCCM_3_2", - "Test_TC_OTCCM_3_3", - "Disabled because darwin-framework-tool does not support constraints arithmetic operations", - "Test_TC_FLW_2_1", - "Test_TC_RH_2_1", - "Disabled because darwin-framework-tool does not handle substraction in parameters", - "Test_TC_S_2_3", - "TestScenesMultiFabric", - "TestScenesFabricSceneInfo", - "#30759: Darwin chip-tool does not support ICD registration during commissioning", - "TestIcdManagementCluster" - ] -} diff --git a/examples/darwin-framework-tool/templates/tests/commands.zapt b/examples/darwin-framework-tool/templates/tests/commands.zapt deleted file mode 100644 index 526e33f5edd497..00000000000000 --- a/examples/darwin-framework-tool/templates/tests/commands.zapt +++ /dev/null @@ -1,63 +0,0 @@ -{{> header}} - -#pragma once - -#if CONFIG_ENABLE_YAML_TESTS - -#include -#include -#include -#include - -#include // For INFINITY - -typedef void (^ResponseHandler)(id _Nullable value, NSError * _Nullable error); - -class TestList : public Command -{ -public: - TestList() : Command("list") {}; - CHIP_ERROR Run() override - { - {{#chip_tests "ciTests.json" includeAllClusters=true}}printf("{{filename}}\n");{{/chip_tests}} - - return CHIP_NO_ERROR; - } -}; - -class ManualTestList : public Command -{ -public: - ManualTestList() : Command("list-manual") {}; - CHIP_ERROR Run() override - { - {{#chip_tests "manualTests.json" includeAllClusters=true}}printf("{{filename}}\n");{{/chip_tests}} - - return CHIP_NO_ERROR; - } -}; - -{{>test_cluster tests="ciTests.json" credsIssuerConfigArg=false}} -{{>test_cluster tests="manualTests.json" credsIssuerConfigArg=false}} - -#endif // CONFIG_ENABLE_YAML_TESTS - -void registerCommandsTests(Commands & commands) -{ - const char * clusterName = "Tests"; - - commands_list clusterCommands = { -#if CONFIG_ENABLE_YAML_TESTS - make_unique(), - make_unique(), - {{#chip_tests "ciTests.json" includeAllClusters=true}} - make_unique<{{filename}}>(), - {{/chip_tests}} - {{#chip_tests "manualTests.json" includeAllClusters=true}} - make_unique<{{filename}}>(), - {{/chip_tests}} -#endif // CONFIG_ENABLE_YAML_TESTS - }; - - commands.RegisterCommandSet(clusterName, clusterCommands, "Commands for running YAML tests."); -} diff --git a/examples/darwin-framework-tool/templates/tests/manualTests.json b/examples/darwin-framework-tool/templates/tests/manualTests.json deleted file mode 100644 index 167f6d2a59e00c..00000000000000 --- a/examples/darwin-framework-tool/templates/tests/manualTests.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "collection": [] -} diff --git a/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt b/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt deleted file mode 100644 index 94bc916cf4fbe2..00000000000000 --- a/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt +++ /dev/null @@ -1,56 +0,0 @@ -{{#if isOptional}} - {{! This just means we expect a non-nil value. Go ahead and check the value, - stripping the optionality off. }} - {{>check_test_value actual=actual expected=expected cluster=cluster isOptional=false}} -{{else if isNullable}} - {{#if (isLiteralNull expected)}} - VerifyOrReturn(CheckValueNull("{{label}}", {{actual}})); - {{else}} - {{#if (chip_tests_variables_has expected)}} - {{! Expected value is also a nullable. }} - if ({{expected}} == nil) { - VerifyOrReturn(CheckValueNull("{{label}}", {{actual}})); - } else { - {{/if}} - VerifyOrReturn(CheckValueNonNull("{{label}}", {{actual}})); - {{>check_test_value actual=actual expected=expected cluster=cluster isNullable=false}} - {{#if (chip_tests_variables_has expected)}} - } - {{/if}} - {{/if}} -{{else if isArray}} - VerifyOrReturn(CheckValue("{{label}}", [{{actual}} count], static_cast({{expected.length}}))); - {{#each expected}} - {{>check_test_value actual=(concat ../actual "[" @index "]") expected=this cluster=../cluster isArray=false type=../type parent=../parent}} - {{/each}} -{{else}} - {{#if_is_struct type}} - {{! Iterate over the actual types in the struct, so we pick up the right - type/optionality/nullability information for them for our recursive - call. }} - {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} - {{#if (hasProperty ../expected label)}} - {{>check_test_value actual=(concat "((MTR" (asUpperCamelCase ../cluster preserveAcronyms=true) "Cluster" (asUpperCamelCase ../type preserveAcronyms=true) " *)" ../actual ")." (asStructPropertyName label)) expected=(lookup ../expected label) cluster=../cluster}} - {{/if}} - {{/zcl_struct_items_by_struct_and_cluster_name}} - {{! Maybe we should add a check for properties in the expected object (other - than "global") that are not present in the struct ? }} - {{else}} - VerifyOrReturn(CheckValue{{#if (isString type)}}AsString{{/if}}("{{label}}", {{actual}}, - {{~#if (chip_tests_variables_has expected)}}{{expected}} - {{~else if (chip_tests_config_has expected)}} - m{{asUpperCamelCase expected}}.HasValue() ? - {{#if (isCharString type)}} - [[NSString alloc] initWithBytes:m{{asUpperCamelCase expected}}.Value().data() length:m{{asUpperCamelCase expected}}.Value().size() encoding:NSUTF8StringEncoding] : @"{{chip_tests_config_get_default_value expected}}" - {{else if (isOctetString type)}} - [NSData dataWithBytes:m{{asUpperCamelCase expected}}.Value().data() length:m{{asUpperCamelCase expected}}.Value().size()] : {{> octetStringValue value=(chip_tests_config_get_default_value expected)}} - {{else}} - m{{asUpperCamelCase expected}}.Value() : {{asTypedExpressionFromObjectiveC (chip_tests_config_get_default_value expected) type}} - {{/if}} - {{~else if (isOctetString type)}} - {{> octetStringValue value=expected}} - {{~else if (isCharString type)}}@"{{expected}}" - {{~else}}{{asTypedExpressionFromObjectiveC expected type}} - {{~/if}})); - {{/if_is_struct}} -{{/if}} diff --git a/examples/darwin-framework-tool/templates/tests/partials/checks/maybeCheckExpectedConstraints.zapt b/examples/darwin-framework-tool/templates/tests/partials/checks/maybeCheckExpectedConstraints.zapt deleted file mode 100644 index 26293b6314d470..00000000000000 --- a/examples/darwin-framework-tool/templates/tests/partials/checks/maybeCheckExpectedConstraints.zapt +++ /dev/null @@ -1,62 +0,0 @@ -{{#if hasExpectedConstraints}} - {{~#*inline "item"}}{{asLowerCamelCase name}}{{/inline}} - - {{~#if isOptional}} - {{~#if (hasProperty expectedConstraints "hasValue")}}VerifyOrReturn(CheckConstraintHasValue("{{>item}}", {{>actualValue}}, {{expectedConstraints.hasValue}}));{{/if}} - if ({{>actualValue}} != nil) { - {{else if isNullable}} - if ({{>actualValue}} != nil) { - {{/if}} - - {{#if (hasProperty expectedConstraints "type")}}VerifyOrReturn(CheckConstraintType("{{>item}}", "{{asTestType type isArray}}", "{{expectedConstraints.type}}"));{{/if}} - - {{~#if (hasProperty expectedConstraints "format")}}VerifyOrReturn(CheckConstraintFormat("{{>item}}", "", "{{expectedConstraints.format}}"));{{/if}} - - {{~#if (hasProperty expectedConstraints "startsWith")}}VerifyOrReturn(CheckConstraintStartsWith("{{>item}}", {{>actualValue}}, "{{expectedConstraints.startsWith}}"));{{/if}} - - {{~#if (hasProperty expectedConstraints "endsWith")}}VerifyOrReturn(CheckConstraintEndsWith("{{>item}}", {{>actualValue}}, "{{expectedConstraints.endsWith}}"));{{/if}} - - {{~#if (hasProperty expectedConstraints "isUpperCase")}}VerifyOrReturn(CheckConstraintIsUpperCase("{{>item}}", {{>actualValue}}, {{expectedConstraints.isUpperCase}}));{{/if}} - - {{~#if (hasProperty expectedConstraints "isLowerCase")}}VerifyOrReturn(CheckConstraintIsLowerCase("{{>item}}", {{>actualValue}}, {{expectedConstraints.isLowerCase}}));{{/if}} - - {{~#if (hasProperty expectedConstraints "isHexString")}}VerifyOrReturn(CheckConstraintIsHexString("{{>item}}", {{>actualValue}}, {{expectedConstraints.isHexString}}));{{/if}} - - {{~#if (hasProperty expectedConstraints "minLength")}}VerifyOrReturn(CheckConstraintMinLength("{{>item}}", {{>actualValue}}, {{expectedConstraints.minLength}}));{{/if}} - - {{~#if (hasProperty expectedConstraints "maxLength")}}VerifyOrReturn(CheckConstraintMaxLength("{{>item}}", {{>actualValue}}, {{expectedConstraints.maxLength}}));{{/if}} - - {{~#if (hasProperty expectedConstraints "minValue")}} - VerifyOrReturn(CheckConstraintMinValue<{{chipType}}>("{{>item}}", [{{>actualValue}} {{asObjectiveCNumberType "" type true}}Value], {{asTypedLiteral expectedConstraints.minValue type}})); - {{/if}} - - {{~#if (hasProperty expectedConstraints "maxValue")}} - VerifyOrReturn(CheckConstraintMaxValue<{{chipType}}>("{{>item}}", [{{>actualValue}} {{asObjectiveCNumberType "" type true}}Value], {{asTypedLiteral expectedConstraints.maxValue type}})); - {{/if}} - - {{~#if (hasProperty expectedConstraints "contains")}} - {{#chip_tests_iterate_expected_list expectedConstraints.contains}} - VerifyOrReturn(CheckConstraintContains("{{asLowerCamelCase name}}", {{>actualValue}}, {{asTypedLiteral value type}})); - {{/chip_tests_iterate_expected_list}} - {{/if}} - - {{~#if (hasProperty expectedConstraints "excludes")}} - {{#chip_tests_iterate_expected_list expectedConstraints.excludes}} - VerifyOrReturn(CheckConstraintExcludes("{{asLowerCamelCase name}}", {{>actualValue}}, {{asTypedLiteral value type}})); - {{/chip_tests_iterate_expected_list}} - {{/if}} - - {{~#if isOptional}} - } - {{else if isNullable}} - } - {{/if}} - - {{~#if (hasProperty expectedConstraints "notValue")}} - {{#if (isLiteralNull expectedConstraints.notValue)}} - VerifyOrReturn(CheckValueNonNull("{{>item}}", {{>actualValue}})); - {{else}} - VerifyOrReturn(CheckConstraintNotValue("{{>item}}", {{>actualValue}}, {{asTypedLiteral expectedConstraints.notValue type}})); - {{/if}} - {{/if}} -{{/if}} diff --git a/examples/darwin-framework-tool/templates/tests/partials/octet_string_value.zapt b/examples/darwin-framework-tool/templates/tests/partials/octet_string_value.zapt deleted file mode 100644 index 98e26af00b8655..00000000000000 --- a/examples/darwin-framework-tool/templates/tests/partials/octet_string_value.zapt +++ /dev/null @@ -1,5 +0,0 @@ -{{~#if (isHexString value)}} -[[NSData alloc] initWithBytes:"{{octetStringFromHexString value}}" length:{{octetStringLengthFromHexString value}}] -{{else}} -[[NSData alloc] initWithBytes:"{{octetStringEscapedForCLiteral value}}" length:{{value.length}}] -{{/if}} diff --git a/examples/darwin-framework-tool/templates/tests/partials/test_cluster.zapt b/examples/darwin-framework-tool/templates/tests/partials/test_cluster.zapt deleted file mode 100644 index 6863b933f4131c..00000000000000 --- a/examples/darwin-framework-tool/templates/tests/partials/test_cluster.zapt +++ /dev/null @@ -1,279 +0,0 @@ -{{#chip_tests tests useSynthesizeWaitForReport=true includeAllClusters=true}} -class {{filename}}: public TestCommandBridge -{ - public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - {{#if ../credsIssuerConfigArg}} - {{filename}}(CredentialIssuerCommands * credsIssuerConfig): TestCommand("{{filename}}", credsIssuerConfig), mTestIndex(0) - {{else}} - {{filename}}(): TestCommandBridge("{{filename}}"), mTestIndex(0) - {{/if}} - { - {{#chip_tests_config}} - {{#if (isString type)}} - AddArgument("{{name}}", &m{{asUpperCamelCase name}}); - {{else}} - AddArgument("{{name}}", {{as_type_min_value type language='c++'}}, {{as_type_max_value type language='c++'}}, &m{{asUpperCamelCase name}}); - {{/if}} - {{/chip_tests_config}} - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~{{filename}}() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Start: {{filename}}\n"); - } - - if (mTestCount == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Complete: {{filename}}\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) - { - {{#chip_tests_items}} - case {{index}}: - ChipLogProgress(chipTool, " ***** Test Step {{index}} : {{label}}\n"); - {{#if PICS}} - if (ShouldSkip("{{PICS}}")) - { - NextTest(); - return; - } - {{/if}} - {{! EventList marked provisional for now }} - {{#if (and isReadAttribute - (isStrEqual (asUpperCamelCase (or attribute "") preserveAcronyms=true) "EventList"))}} - NextTest(); - return; - {{else}} - err = Test{{asUpperCamelCase label}}_{{index}}(); - break; - {{/if}} - {{/chip_tests_items}} - } - - if (CHIP_NO_ERROR != err) - { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) - { - {{#chip_tests_items}} - case {{index}}: - {{! No support for expectMultipleResponses yet }} - {{#chip_tests_item_responses}} - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), {{error}})); - {{#if error}} - {{#if clusterError}} - VerifyOrReturn(CheckValue("clusterStatus present", status.mClusterStatus.HasValue(), true)); - VerifyOrReturn(CheckValue("clusterStatus value", status.mClusterStatus.Value(), {{clusterError}})); - {{/if}} - {{/if}} - {{/chip_tests_item_responses}} - break; - {{/chip_tests_items}} - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr({{chip_tests_config_get_default_value "timeout"}})); } - - private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = {{totalTests}}; - - {{#chip_tests_config}} - chip::Optional<{{chipType}}> m{{asUpperCamelCase name}}; - {{/chip_tests_config}} - - {{#chip_tests_items}} - {{! EventList marked provisional for now }} - {{#unless (and isReadAttribute - (isStrEqual (asUpperCamelCase (or attribute "") preserveAcronyms=true) "EventList"))}} - {{#if async}} - bool testSendCluster{{parent.filename}}_{{index}}_{{asUpperCamelCase command}}_Fulfilled = false; - {{/if}} - {{#chip_tests_item_responses}} - {{#chip_tests_item_response_parameters}} - {{#if saveAs}} - {{asObjectiveCType type ../cluster}} {{saveAs}}; - {{/if}} - {{/chip_tests_item_response_parameters}} - {{/chip_tests_item_responses}} - - {{~#*inline "subscribeDataCallback"}} - test_{{parent.filename}}_{{attribute}}_Reported - {{/inline}} - {{#if allocateSubscribeDataCallback}} - ResponseHandler _Nullable {{> subscribeDataCallback}} = nil; - {{/if~}} - - {{#*inline "testCommand"}}Test{{asUpperCamelCase label}}_{{index}}{{/inline}} - CHIP_ERROR {{>testCommand}}() - { - {{#*inline "cluster"}}{{asUpperCamelCase cluster preserveAcronyms=true}}{{/inline}} - {{#*inline "attribute"}}{{asUpperCamelCase attribute preserveAcronyms=true}}{{/inline}} - {{#if (isTestOnlyCluster cluster)}} - {{asEncodableType}} value; - {{#chip_tests_item_parameters}} - {{>commandValue ns=parent.cluster container=(asPropertyValue dontUnwrapValue=true) definedValue=definedValue depth=0}} - {{/chip_tests_item_parameters}} - {{#if (and (isStrEqual cluster "CommissionerCommands") (isStrEqual command "GetCommissionerNodeId"))}} - return {{command}}("{{identity}}", value, ^(const chip::{{command}}Response & values) { - {{#chip_tests_item_responses}} - {{#chip_tests_item_response_parameters}} - {{#if hasExpectedValue}} - { - id actualValue = values.{{asStructPropertyName name}} - {{>check_test_value actual="actualValue" expected=expectedValue cluster=../cluster}} - } - {{/if}} - {{>maybeCheckExpectedConstraints}} - {{#if saveAs}} - { - {{saveAs}} = [[NSNumber alloc] initWithUnsignedLongLong:values.{{asStructPropertyName name}}]; - } - {{/if}} - {{/chip_tests_item_response_parameters}} - {{/chip_tests_item_responses}} - NextTest(); - }); - {{else}} - return {{command}}("{{identity}}", value); - {{/if}} - {{else}} - MTRBaseDevice * device = GetDevice("{{identity}}"); - __auto_type * cluster = [[MTRBaseCluster{{>cluster}} alloc] initWithDevice:device endpointID:@({{endpoint}}) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - {{#if isCommand}} - {{#if commandObject.arguments.length}} - __auto_type * params = [[MTR{{>cluster}}Cluster{{asUpperCamelCase command preserveAcronyms=true}}Params alloc] init]; - {{/if}} - {{#chip_tests_item_parameters}} - {{>test_value target=(concat "params." (asStructPropertyName label)) definedValue=definedValue cluster=parent.cluster depth=0}} - {{/chip_tests_item_parameters}} - [cluster {{asLowerCamelCase command}}With{{#if commandObject.arguments.length}}Params:params completion{{else}}Completion{{/if}}: - {{#if commandObject.hasSpecificResponse}} - ^(MTR{{>cluster}}Cluster{{asUpperCamelCase commandObject.responseName}}Params * _Nullable values, NSError * _Nullable err) { - {{else}} - ^(NSError * _Nullable err) { - {{/if}} - {{else if isSubscribeAttribute}} - {{#chip_tests_item_parameters}} - {{asObjectiveCBasicType type}} {{asLowerCamelCase name}}Argument = {{asTypedLiteral definedValue type}}; - {{/chip_tests_item_parameters}} - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = {{#if fabricFiltered}}true{{else}}false{{/if}}; - params.replaceExistingSubscriptions = {{#if keepSubscriptions}}false{{else}}true{{/if}}; - [cluster subscribeAttribute{{>attribute}}WithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendCluster{{parent.filename}}_{{waitForReport.index}}_{{asUpperCamelCase waitForReport.command}}_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^({{asObjectiveCClass attributeObject.type cluster forceList=attributeObject.isArray}} * _Nullable value, NSError * _Nullable err) { - {{else if isWaitForReport}} - {{> subscribeDataCallback }} = ^({{asObjectiveCClass attributeObject.type cluster forceList=attributeObject.isArray}} * _Nullable value, NSError * _Nullable err) { - {{else if isReadAttribute}} - {{#if_is_fabric_scoped_struct attributeObject.type}} - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = {{fabricFiltered}}; - {{/if_is_fabric_scoped_struct}} - [cluster readAttribute{{>attribute}}With - {{~#if_is_fabric_scoped_struct attributeObject.type~}} - Params:params completion: - {{~else~}} - Completion: - {{~/if_is_fabric_scoped_struct~}} - ^({{asObjectiveCClass attributeObject.type cluster forceList=attributeObject.isArray}} * _Nullable value, NSError * _Nullable err) { - {{else if isWriteAttribute}} - {{#chip_tests_item_parameters}} - id {{asLowerCamelCase name}}Argument; - {{>test_value target=(concat (asLowerCamelCase name) "Argument") definedValue=definedValue cluster=parent.cluster depth=0}} - {{/chip_tests_item_parameters}} - [cluster writeAttribute{{>attribute}}WithValue:{{#chip_tests_item_parameters}}{{asLowerCamelCase name}}Argument{{/chip_tests_item_parameters}} completion:^(NSError * _Nullable err) { - {{/if}} - if (err != nil) { - NSLog(@"{{label}}: Error: %@", err); - } else { - NSLog(@"{{label}}: Success"); - } - - {{#chip_tests_item_responses}} - {{#if error}} - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, {{error}})); - NextTest(); - {{else}} - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - {{#unless isSubscribeAttribute}} - - {{#chip_tests_item_response_parameters}} - {{#*inline "actualValue"}}value{{#unless parent.isAttribute}}s.{{asStructPropertyName name}}{{/unless}}{{/inline}} - {{#if hasExpectedValue}} - { - id actualValue = {{> actualValue}}; - {{>check_test_value actual="actualValue" expected=expectedValue cluster=../cluster}} - } - {{/if}} - {{>maybeCheckExpectedConstraints}} - {{#if saveAs}} - { - {{saveAs}} = {{>actualValue}}; - } - {{/if}} - {{/chip_tests_item_response_parameters}} - - {{#unless async}} - NextTest(); - {{else}} - testSendCluster{{parent.filename}}_{{../index}}_{{asUpperCamelCase command}}_Fulfilled = true; - {{/unless}} - {{else}} - {{! We're a subscription }} - if ({{> subscribeDataCallback}} != nil) { - ResponseHandler callback = {{> subscribeDataCallback}}; - {{> subscribeDataCallback}} = nil; - callback(value, err); - } - {{/unless}} - {{/if}} - {{/chip_tests_item_responses}} - }{{#unless isWaitForReport}}]{{/unless}}; - - {{#if async}} - NextTest(); - {{/if}} - return CHIP_NO_ERROR; - {{/if}} - } - {{/unless}} - {{/chip_tests_items}} - -}; - -{{/chip_tests}} diff --git a/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt b/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt deleted file mode 100644 index 30c342cecb809d..00000000000000 --- a/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt +++ /dev/null @@ -1,55 +0,0 @@ -{{#if isOptional}} - {{! Just go ahead and assign to the value, stripping the optionality bit off. }} - {{>test_value target=target definedValue=definedValue cluster=cluster isOptional=false depth=(incrementDepth depth)}} -{{else if isNullable}} - {{#if (isLiteralNull definedValue)}} - {{target}} = nil; - {{else}} - {{>test_value target=target definedValue=definedValue cluster=cluster isNullable=false depth=(incrementDepth depth)}} - {{/if}} -{{else if isArray}} - {{ensureIsArray definedValue~}} - { - NSMutableArray * temp_{{depth}} = [[NSMutableArray alloc] init]; - {{#each definedValue}} - {{>test_value target=(concat "temp_" ../depth "[" @index "]") definedValue=this cluster=../cluster depth=(incrementDepth ../depth) type=../type isArray=false parent=../parent}} - {{/each}} - {{target}} = temp_{{depth}}; - } -{{else}} - {{#if_is_struct type}} - {{target}} = [[MTR{{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}} alloc] init]; - {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} - {{#if_include_struct_item_value ../definedValue name}} - {{! target may be some place where we lost type information (e.g. an - id), so add explicit cast when trying to assign to our - properties. }} - {{>test_value target=(concat "((MTR" (asUpperCamelCase ../cluster) "Cluster" (asUpperCamelCase ../type) " *)" ../target ")." (asStructPropertyName label)) definedValue=(lookup ../definedValue name) cluster=../cluster depth=(incrementDepth ../depth)}} - {{/if_include_struct_item_value}} - {{/zcl_struct_items_by_struct_and_cluster_name}} - - {{else}} - {{target}} = - {{#if (chip_tests_variables_has definedValue)}} - [{{definedValue}} copy]; - {{else if (chip_tests_config_has definedValue)}} - m{{asUpperCamelCase definedValue}}.HasValue() ? - {{#if (isCharString type)}} - [[NSString alloc] initWithBytes:m{{asUpperCamelCase definedValue}}.Value().data() length:m{{asUpperCamelCase definedValue}}.Value().size() encoding:NSUTF8StringEncoding] : @"{{chip_tests_config_get_default_value definedValue}}"; - {{else if (isOctetString type)}} - [NSData dataWithBytes:m{{asUpperCamelCase definedValue}}.Value().data() length:m{{asUpperCamelCase definedValue}}.Value().size()] : {{> octetStringValue value=(chip_tests_config_get_default_value definedValue)}}; - {{else}} - [NSNumber numberWith{{asObjectiveCNumberType definedValue type false}}:m{{asUpperCamelCase definedValue}}.Value()] : - [NSNumber numberWith{{asObjectiveCNumberType definedValue type false}}:{{asTypedExpressionFromObjectiveC (chip_tests_config_get_default_value definedValue) type}}]; - {{/if}} - {{else}} - {{#if (isCharString type)}} - @"{{definedValue}}"; - {{else if (isOctetString type)}} - {{> octetStringValue value=definedValue}}; - {{else}} - [NSNumber numberWith{{asObjectiveCNumberType definedValue type false}}:{{asTypedExpressionFromObjectiveC definedValue type}}]; - {{/if}} - {{/if}} - {{/if_is_struct}} -{{/if}} diff --git a/examples/darwin-framework-tool/templates/tests/templates.json b/examples/darwin-framework-tool/templates/tests/templates.json deleted file mode 100644 index 9ca4d2e533c183..00000000000000 --- a/examples/darwin-framework-tool/templates/tests/templates.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "CHIP Tool Tests templates", - "version": "chip-v1", - "helpers": [ - "chip-tool/templates/helper.js", - "chip-tool/templates/tests/helper.js", - "partials/helper.js", - "common/StringHelper.js", - "templates/app/helper.js", - "templates/chip/helper.js", - "common/ClusterTestGeneration.js", - "darwin/Framework/CHIP/templates/helper.js", - "darwin-framework-tool/templates/helper.js" - ], - "resources": { - "pics-metafile": "../../../../src/app/tests/suites/certification/PICS.yaml", - "certification-metadir": "../../../../src/app/tests/suites/certification", - "test-metadir": "../../../../src/app/tests/suites" - }, - "override": "../../../../src/app/zap-templates/common/override.js", - "partials": [ - { - "name": "header", - "path": "../../../../src/app/zap-templates/partials/header.zapt" - }, - { - "name": "encode_value", - "path": "../../../../src/darwin/Framework/CHIP/templates/partials/encode_value.zapt" - }, - { - "name": "commandValue", - "path": "../../../../examples/chip-tool/templates/tests/partials/command_value.zapt" - }, - { - "name": "test_cluster", - "path": "partials/test_cluster.zapt" - }, - { - "name": "test_value", - "path": "partials/test_value.zapt" - }, - { - "name": "check_test_value", - "path": "partials/check_test_value.zapt" - }, - { - "name": "octetStringValue", - "path": "partials/octet_string_value.zapt" - }, - { - "name": "maybeCheckExpectedConstraints", - "path": "partials/checks/maybeCheckExpectedConstraints.zapt" - } - ], - "templates": [ - { - "path": "commands.zapt", - "name": "Tests Commands header", - "output": "test/Commands.h" - } - ] -} diff --git a/examples/dishwasher-app/dishwasher-common/dishwasher-app.matter b/examples/dishwasher-app/dishwasher-common/dishwasher-app.matter index 3359107957e727..6c52cbcf144ce2 100644 --- a/examples/dishwasher-app/dishwasher-common/dishwasher-app.matter +++ b/examples/dishwasher-app/dishwasher-common/dishwasher-app.matter @@ -743,6 +743,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -799,10 +803,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Wi-Fi Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1384,8 +1400,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/energy-management-app/energy-management-common/energy-management-app.matter b/examples/energy-management-app/energy-management-common/energy-management-app.matter index dae189309d4dbb..f593b52d3ab71e 100644 --- a/examples/energy-management-app/energy-management-common/energy-management-app.matter +++ b/examples/energy-management-app/energy-management-common/energy-management-app.matter @@ -256,6 +256,67 @@ cluster BasicInformation = 40 { command MfgSpecificPing(): DefaultSuccess = 0; } +/** Nodes should be expected to be deployed to any and all regions of the world. These global regions + may have differing common languages, units of measurements, and numerical formatting + standards. As such, Nodes that visually or audibly convey information need a mechanism by which + they can be configured to use a user’s preferred language, units, etc */ +cluster LocalizationConfiguration = 43 { + revision 1; // NOTE: Default/not specifically set + + attribute access(write: manage) char_string<35> activeLocale = 0; + readonly attribute char_string supportedLocales[] = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** Nodes should be expected to be deployed to any and all regions of the world. These global regions + may have differing preferences for how dates and times are conveyed. As such, Nodes that visually + or audibly convey time information need a mechanism by which they can be configured to use a + user’s preferred format. */ +cluster TimeFormatLocalization = 44 { + revision 1; // NOTE: Default/not specifically set + + enum CalendarTypeEnum : enum8 { + kBuddhist = 0; + kChinese = 1; + kCoptic = 2; + kEthiopian = 3; + kGregorian = 4; + kHebrew = 5; + kIndian = 6; + kIslamic = 7; + kJapanese = 8; + kKorean = 9; + kPersian = 10; + kTaiwanese = 11; + kUseActiveLocale = 255; + } + + enum HourFormatEnum : enum8 { + k12hr = 0; + k24hr = 1; + kUseActiveLocale = 255; + } + + bitmap Feature : bitmap32 { + kCalendarFormat = 0x1; + } + + attribute access(write: manage) HourFormatEnum hourFormat = 0; + attribute access(write: manage) optional CalendarTypeEnum activeCalendarType = 1; + readonly attribute optional CalendarTypeEnum supportedCalendarTypes[] = 2; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + /** Nodes should be expected to be deployed to any and all regions of the world. These global regions may have differing preferences for the units in which values are conveyed in communication to a user. As such, Nodes that visually or audibly convey measurable values to the user need a @@ -584,6 +645,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -640,10 +705,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** Commands to trigger a Node to allow a new Administrator to commission it. */ @@ -900,6 +977,111 @@ cluster GroupKeyManagement = 63 { fabric command access(invoke: administer) KeySetReadAllIndices(): KeySetReadAllIndicesResponse = 4; } +/** This cluster provides a mechanism for querying data about electrical power as measured by the server. */ +provisional cluster ElectricalPowerMeasurement = 144 { + revision 1; + + enum MeasurementTypeEnum : enum16 { + kUnspecified = 0; + kVoltage = 1; + kActiveCurrent = 2; + kReactiveCurrent = 3; + kApparentCurrent = 4; + kActivePower = 5; + kReactivePower = 6; + kApparentPower = 7; + kRMSVoltage = 8; + kRMSCurrent = 9; + kRMSPower = 10; + kFrequency = 11; + kPowerFactor = 12; + kNeutralCurrent = 13; + kElectricalEnergy = 14; + } + + enum PowerModeEnum : enum8 { + kUnknown = 0; + kDC = 1; + kAC = 2; + } + + bitmap Feature : bitmap32 { + kDirectCurrent = 0x1; + kAlternatingCurrent = 0x2; + kPolyphasePower = 0x4; + kHarmonics = 0x8; + kPowerQuality = 0x10; + } + + struct MeasurementAccuracyRangeStruct { + int64s rangeMin = 0; + int64s rangeMax = 1; + optional percent100ths percentMax = 2; + optional percent100ths percentMin = 3; + optional percent100ths percentTypical = 4; + optional int64u fixedMax = 5; + optional int64u fixedMin = 6; + optional int64u fixedTypical = 7; + } + + struct MeasurementAccuracyStruct { + MeasurementTypeEnum measurementType = 0; + boolean measured = 1; + int64s minMeasuredValue = 2; + int64s maxMeasuredValue = 3; + MeasurementAccuracyRangeStruct accuracyRanges[] = 4; + } + + struct HarmonicMeasurementStruct { + int8u order = 0; + nullable int64s measurement = 1; + } + + struct MeasurementRangeStruct { + MeasurementTypeEnum measurementType = 0; + int64s min = 1; + int64s max = 2; + optional epoch_s startTimestamp = 3; + optional epoch_s endTimestamp = 4; + optional epoch_s minTimestamp = 5; + optional epoch_s maxTimestamp = 6; + optional systime_ms startSystime = 7; + optional systime_ms endSystime = 8; + optional systime_ms minSystime = 9; + optional systime_ms maxSystime = 10; + } + + info event MeasurementPeriodRanges = 0 { + MeasurementRangeStruct ranges[] = 0; + } + + readonly attribute PowerModeEnum powerMode = 0; + readonly attribute int8u numberOfMeasurementTypes = 1; + readonly attribute MeasurementAccuracyStruct accuracy[] = 2; + readonly attribute optional MeasurementRangeStruct ranges[] = 3; + readonly attribute optional nullable voltage_mv voltage = 4; + readonly attribute optional nullable amperage_ma activeCurrent = 5; + readonly attribute optional nullable amperage_ma reactiveCurrent = 6; + readonly attribute optional nullable amperage_ma apparentCurrent = 7; + readonly attribute nullable power_mw activePower = 8; + readonly attribute optional nullable power_mw reactivePower = 9; + readonly attribute optional nullable power_mw apparentPower = 10; + readonly attribute optional nullable voltage_mv RMSVoltage = 11; + readonly attribute optional nullable amperage_ma RMSCurrent = 12; + readonly attribute optional nullable power_mw RMSPower = 13; + readonly attribute optional nullable int64s frequency = 14; + readonly attribute optional nullable HarmonicMeasurementStruct harmonicCurrents[] = 15; + readonly attribute optional nullable HarmonicMeasurementStruct harmonicPhases[] = 16; + readonly attribute optional nullable int64s powerFactor = 17; + readonly attribute optional nullable amperage_ma neutralCurrent = 18; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + /** This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. */ provisional cluster ElectricalEnergyMeasurement = 145 { revision 1; @@ -948,8 +1130,15 @@ provisional cluster ElectricalEnergyMeasurement = 145 { MeasurementAccuracyRangeStruct accuracyRanges[] = 4; } + struct CumulativeEnergyResetStruct { + optional nullable epoch_s importedResetTimestamp = 0; + optional nullable epoch_s exportedResetTimestamp = 1; + optional nullable systime_ms importedResetSystime = 2; + optional nullable systime_ms exportedResetSystime = 3; + } + struct EnergyMeasurementStruct { - int64s energy = 0; + energy_mwh energy = 0; optional epoch_s startTimestamp = 1; optional epoch_s endTimestamp = 2; optional systime_ms startSystime = 3; @@ -971,6 +1160,7 @@ provisional cluster ElectricalEnergyMeasurement = 145 { readonly attribute optional nullable EnergyMeasurementStruct cumulativeEnergyExported = 2; readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyImported = 3; readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyExported = 4; + readonly attribute optional nullable CumulativeEnergyResetStruct cumulativeEnergyReset = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1522,6 +1712,27 @@ endpoint 0 { ram attribute clusterRevision default = 3; } + server cluster LocalizationConfiguration { + ram attribute activeLocale; + callback attribute supportedLocales; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + + server cluster TimeFormatLocalization { + ram attribute hourFormat; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + server cluster UnitLocalization { callback attribute generatedCommandList; callback attribute acceptedCommandList; @@ -1570,13 +1781,14 @@ endpoint 0 { server cluster GeneralDiagnostics { callback attribute networkInterfaces; callback attribute rebootCount; + callback attribute upTime; ram attribute testEventTriggersEnabled; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; @@ -1647,7 +1859,7 @@ endpoint 0 { } } endpoint 1 { - device type ma_lightsensor = 262, version 1; + device type energy_evse = 1292, version 1; server cluster Identify { @@ -1677,6 +1889,19 @@ endpoint 1 { callback attribute clusterRevision; } + server cluster ElectricalPowerMeasurement { + callback attribute powerMode; + callback attribute numberOfMeasurementTypes; + callback attribute accuracy; + callback attribute activePower; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + callback attribute featureMap; + ram attribute clusterRevision default = 1; + } + server cluster ElectricalEnergyMeasurement { emits event CumulativeEnergyMeasured; callback attribute accuracy; @@ -1685,7 +1910,7 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 5; + callback attribute featureMap; ram attribute clusterRevision default = 1; } diff --git a/examples/energy-management-app/energy-management-common/energy-management-app.zap b/examples/energy-management-app/energy-management-common/energy-management-app.zap index 0e1f15b808317d..ed18c81d0738e5 100644 --- a/examples/energy-management-app/energy-management-common/energy-management-app.zap +++ b/examples/energy-management-app/energy-management-common/energy-management-app.zap @@ -746,6 +746,266 @@ } ] }, + { + "name": "Localization Configuration", + "code": 43, + "mfgCode": null, + "define": "LOCALIZATION_CONFIGURATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "ActiveLocale", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedLocales", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "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": null, + "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": null, + "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": null, + "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": null, + "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 + } + ] + }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "HourFormat", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "HourFormatEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "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": null, + "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": null, + "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": null, + "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 + } + ] + }, { "name": "Unit Localization", "code": 45, @@ -1356,6 +1616,22 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "UpTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "TestEventTriggersEnabled", "code": 8, @@ -2168,27 +2444,27 @@ "id": 2, "name": "Anonymous Endpoint Type", "deviceTypeRef": { - "code": 262, + "code": 1292, "profileId": 259, - "label": "MA-lightsensor", - "name": "MA-lightsensor" + "label": "Energy EVSE", + "name": "Energy EVSE" }, "deviceTypes": [ { - "code": 262, + "code": 1292, "profileId": 259, - "label": "MA-lightsensor", - "name": "MA-lightsensor" + "label": "Energy EVSE", + "name": "Energy EVSE" } ], "deviceVersions": [ 1 ], "deviceIdentifiers": [ - 262 + 1292 ], - "deviceTypeName": "MA-lightsensor", - "deviceTypeCode": 262, + "deviceTypeName": "Energy EVSE", + "deviceTypeCode": 1292, "deviceTypeProfileId": 259, "clusters": [ { @@ -2517,6 +2793,177 @@ } ] }, + { + "name": "Electrical Power Measurement", + "code": 144, + "mfgCode": null, + "define": "ELECTRICAL_POWER_MEASUREMENT_CLUSTER", + "side": "server", + "enabled": 1, + "apiMaturity": "provisional", + "attributes": [ + { + "name": "PowerMode", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "PowerModeEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "NumberOfMeasurementTypes", + "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": "Accuracy", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActivePower", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "power_mw", + "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": "External", + "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 + } + ] + }, { "name": "Electrical Energy Measurement", "code": 145, @@ -2629,10 +3076,10 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "5", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.matter b/examples/light-switch-app/light-switch-common/light-switch-app.matter index 2a5819e69cf915..90e60581be27da 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.matter +++ b/examples/light-switch-app/light-switch-common/light-switch-app.matter @@ -1040,6 +1040,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1096,10 +1100,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2621,8 +2637,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; @@ -2789,7 +2805,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; handle command OpenCommissioningWindow; - handle command OpenBasicCommissioningWindow; handle command RevokeCommissioning; } diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.zap b/examples/light-switch-app/light-switch-common/light-switch-app.zap index 58f5c72eb4578a..3d15cf009086d8 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.zap +++ b/examples/light-switch-app/light-switch-common/light-switch-app.zap @@ -3879,14 +3879,6 @@ "isIncoming": 1, "isEnabled": 1 }, - { - "name": "OpenBasicCommissioningWindow", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, { "name": "RevokeCommissioning", "code": 2, diff --git a/examples/light-switch-app/qpg/zap/switch.matter b/examples/light-switch-app/qpg/zap/switch.matter index 035913b5487922..b7f217d7221b27 100644 --- a/examples/light-switch-app/qpg/zap/switch.matter +++ b/examples/light-switch-app/qpg/zap/switch.matter @@ -1104,6 +1104,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1160,10 +1164,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2430,8 +2446,8 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 2; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; } diff --git a/examples/light-switch-app/silabs/openthread.gni b/examples/light-switch-app/silabs/openthread.gni index 19b09c05a8f4b6..2ea7cd471c2b8a 100644 --- a/examples/light-switch-app/silabs/openthread.gni +++ b/examples/light-switch-app/silabs/openthread.gni @@ -31,7 +31,7 @@ chip_subscription_timeout_resumption = false sl_use_subscription_synching = true # Openthread Configuration flags -sl_ot_idle_interval_ms = 30000 # 30s Idle Intervals +sl_ot_idle_interval_ms = 15000 # 15s Idle Intervals sl_ot_active_interval_ms = 500 # 500ms Active Intervals # ICD Matter Configuration flags diff --git a/examples/light-switch-app/silabs/src/AppTask.cpp b/examples/light-switch-app/silabs/src/AppTask.cpp index 2f8d01275863be..c9759d24118fdd 100644 --- a/examples/light-switch-app/silabs/src/AppTask.cpp +++ b/examples/light-switch-app/silabs/src/AppTask.cpp @@ -25,29 +25,24 @@ #include "AppConfig.h" #include "AppEvent.h" #include "BindingHandler.h" - #include "LEDWidget.h" - #include "LightSwitchMgr.h" - #ifdef DISPLAY_ENABLED #include "lcd.h" #ifdef QR_CODE_ENABLED #include "qrcodegen.h" #endif // QR_CODE_ENABLED #endif // DISPLAY_ENABLED - #include #include #include #include #include #include +#include #include #include -#include - /********************************************************** * Defines and Constants *********************************************************/ diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-ethernet.matter b/examples/lighting-app/bouffalolab/data_model/lighting-app-ethernet.matter index ad6f111938127d..626d1bce2be886 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-ethernet.matter +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-ethernet.matter @@ -1094,6 +1094,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1150,10 +1154,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1983,8 +1999,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter index 78048d0b457bbf..392e08c39bf977 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter @@ -1094,6 +1094,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1150,10 +1154,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2116,8 +2132,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter index 5b77ecb961222f..4bc07365ff7564 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter @@ -1094,6 +1094,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1150,10 +1154,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2027,8 +2043,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/lighting-app/lighting-common/lighting-app.matter b/examples/lighting-app/lighting-common/lighting-app.matter index f8996d1353ca8a..f43bdcbb6bb0b1 100644 --- a/examples/lighting-app/lighting-common/lighting-app.matter +++ b/examples/lighting-app/lighting-common/lighting-app.matter @@ -1094,6 +1094,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1150,10 +1154,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2480,8 +2496,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/lighting-app/nxp/zap/lighting-on-off.matter b/examples/lighting-app/nxp/zap/lighting-on-off.matter index 048b8f4748d326..9f4e9c51e5e5c3 100644 --- a/examples/lighting-app/nxp/zap/lighting-on-off.matter +++ b/examples/lighting-app/nxp/zap/lighting-on-off.matter @@ -986,6 +986,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1042,10 +1046,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1612,8 +1628,8 @@ endpoint 0 { callback attribute rebootCount; callback attribute upTime; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/lighting-app/qpg/zap/light.matter b/examples/lighting-app/qpg/zap/light.matter index bef48495ad23e8..fb5dcbb3cc851f 100644 --- a/examples/lighting-app/qpg/zap/light.matter +++ b/examples/lighting-app/qpg/zap/light.matter @@ -1033,6 +1033,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1089,10 +1093,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2062,8 +2078,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/lighting-app/silabs/data_model/lighting-thread-app.matter b/examples/lighting-app/silabs/data_model/lighting-thread-app.matter index 86db7ac353c727..6803904ba5e560 100644 --- a/examples/lighting-app/silabs/data_model/lighting-thread-app.matter +++ b/examples/lighting-app/silabs/data_model/lighting-thread-app.matter @@ -1353,6 +1353,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1409,10 +1413,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2517,8 +2533,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; @@ -2615,7 +2631,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; handle command OpenCommissioningWindow; - handle command OpenBasicCommissioningWindow; handle command RevokeCommissioning; } diff --git a/examples/lighting-app/silabs/data_model/lighting-thread-app.zap b/examples/lighting-app/silabs/data_model/lighting-thread-app.zap index 55b06213c5794b..eb3e958009ace5 100644 --- a/examples/lighting-app/silabs/data_model/lighting-thread-app.zap +++ b/examples/lighting-app/silabs/data_model/lighting-thread-app.zap @@ -2968,14 +2968,6 @@ "isIncoming": 1, "isEnabled": 1 }, - { - "name": "OpenBasicCommissioningWindow", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, { "name": "RevokeCommissioning", "code": 2, diff --git a/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter b/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter index b52944de7a3f8c..90083596d9cf24 100644 --- a/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter +++ b/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter @@ -1353,6 +1353,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1409,10 +1413,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2427,8 +2443,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; @@ -2475,7 +2491,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; handle command OpenCommissioningWindow; - handle command OpenBasicCommissioningWindow; handle command RevokeCommissioning; } diff --git a/examples/lighting-app/silabs/data_model/lighting-wifi-app.zap b/examples/lighting-app/silabs/data_model/lighting-wifi-app.zap index 3cf074afc1b0b6..c99d5e4716fcc9 100644 --- a/examples/lighting-app/silabs/data_model/lighting-wifi-app.zap +++ b/examples/lighting-app/silabs/data_model/lighting-wifi-app.zap @@ -2152,14 +2152,6 @@ "isIncoming": 1, "isEnabled": 1 }, - { - "name": "OpenBasicCommissioningWindow", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, { "name": "RevokeCommissioning", "code": 2, diff --git a/examples/lighting-app/telink/prj.conf b/examples/lighting-app/telink/prj.conf index 87a5c03720bbf4..f4b2a44e1c672c 100644 --- a/examples/lighting-app/telink/prj.conf +++ b/examples/lighting-app/telink/prj.conf @@ -51,5 +51,8 @@ CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n +#Enable PWM +CONFIG_PWM=y + # Enable Power Management CONFIG_PM=n diff --git a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter index 17d36e26ceeff5..9089068f442f22 100644 --- a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter +++ b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter @@ -738,6 +738,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -794,10 +798,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Thread Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems */ @@ -1608,8 +1624,8 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 2; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/lock-app/esp32/main/AppTask.cpp b/examples/lock-app/esp32/main/AppTask.cpp index 52650e5c2d2652..e6a8519b782c18 100644 --- a/examples/lock-app/esp32/main/AppTask.cpp +++ b/examples/lock-app/esp32/main/AppTask.cpp @@ -322,7 +322,7 @@ void AppTask::FunctionHandler(AppEvent * aEvent) } else { - // If the button was released before factory reset got initiated, start BLE advertissement in fast mode + // If the button was released before factory reset got initiated, start BLE advertisement in fast mode if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartBleAdv) { sAppTask.CancelTimer(); @@ -336,7 +336,7 @@ void AppTask::FunctionHandler(AppEvent * aEvent) } else { - ESP_LOGI(TAG, "Network is already provisioned, Ble advertissement not enabled"); + ESP_LOGI(TAG, "Network is already provisioned, Ble advertisement not enabled"); } } else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_FactoryReset) diff --git a/examples/lock-app/lock-common/include/LockEndpoint.h b/examples/lock-app/lock-common/include/LockEndpoint.h index 63af4f46b0de30..bd193d388db02b 100644 --- a/examples/lock-app/lock-common/include/LockEndpoint.h +++ b/examples/lock-app/lock-common/include/LockEndpoint.h @@ -106,8 +106,16 @@ class LockEndpoint OperationSourceEnum opSource = OperationSourceEnum::kUnspecified); const char * lockStateToString(DlLockState lockState) const; - bool weekDayScheduleInAction(uint16_t userIndex) const; - bool yearDayScheduleInAction(uint16_t userIndex) const; + // Returns true if week day schedules should apply to the user, there are + // schedules defined for the user, and access is not currently allowed by + // those schedules. The outparam indicates whether there were in fact any + // year day schedules defined for the user. + bool weekDayScheduleForbidsAccess(uint16_t userIndex, bool * haveSchedule) const; + // Returns true if year day schedules should apply to the user, there are + // schedules defined for the user, and access is not currently allowed by + // those schedules. The outparam indicates whether there were in fact any + // year day schedules defined for the user. + bool yearDayScheduleForbidsAccess(uint16_t userIndex, bool * haveSchedule) const; static void OnLockActionCompleteCallback(chip::System::Layer *, void * callbackContext); diff --git a/examples/lock-app/lock-common/lock-app.matter b/examples/lock-app/lock-common/lock-app.matter index 6a3aad2cf8e382..f07b85cfe6de45 100644 --- a/examples/lock-app/lock-common/lock-app.matter +++ b/examples/lock-app/lock-common/lock-app.matter @@ -1061,6 +1061,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1117,10 +1121,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2663,8 +2679,8 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/lock-app/lock-common/src/LockEndpoint.cpp b/examples/lock-app/lock-common/src/LockEndpoint.cpp index 2beb010d1523c9..bda27f18ba2c8c 100644 --- a/examples/lock-app/lock-common/src/LockEndpoint.cpp +++ b/examples/lock-app/lock-common/src/LockEndpoint.cpp @@ -488,19 +488,20 @@ bool LockEndpoint::setLockState(const Nullable & fabricIdx, c auto userIndex = static_cast(user - mLockUsers.begin()); // Check if schedules affect the user - if ((user->userType == UserTypeEnum::kScheduleRestrictedUser || user->userType == UserTypeEnum::kWeekDayScheduleUser) && - !weekDayScheduleInAction(userIndex)) + bool haveWeekDaySchedules = false; + bool haveYearDaySchedules = false; + if (weekDayScheduleForbidsAccess(userIndex, &haveWeekDaySchedules) || + yearDayScheduleForbidsAccess(userIndex, &haveYearDaySchedules) || + // Also disallow access for a user that's supposed to have _some_ + // schedule but doesn't have any + (user->userType == UserTypeEnum::kScheduleRestrictedUser && !haveWeekDaySchedules && !haveYearDaySchedules)) { - if ((user->userType == UserTypeEnum::kScheduleRestrictedUser || user->userType == UserTypeEnum::kYearDayScheduleUser) && - !yearDayScheduleInAction(userIndex)) - { - ChipLogDetail(Zcl, - "Lock App: associated user is not allowed to operate the lock due to schedules" - "[endpointId=%d,userIndex=%u]", - mEndpointId, userIndex); - err = OperationErrorEnum::kRestricted; - return false; - } + ChipLogDetail(Zcl, + "Lock App: associated user is not allowed to operate the lock due to schedules" + "[endpointId=%d,userIndex=%u]", + mEndpointId, userIndex); + err = OperationErrorEnum::kRestricted; + return false; } ChipLogProgress( Zcl, @@ -561,12 +562,23 @@ void LockEndpoint::OnLockActionCompleteCallback(chip::System::Layer *, void * ca } } -bool LockEndpoint::weekDayScheduleInAction(uint16_t userIndex) const +bool LockEndpoint::weekDayScheduleForbidsAccess(uint16_t userIndex, bool * haveSchedule) const { + *haveSchedule = std::any_of(mWeekDaySchedules[userIndex].begin(), mWeekDaySchedules[userIndex].end(), + [](const WeekDaysScheduleInfo & s) { return s.status == DlScheduleStatus::kOccupied; }); + const auto & user = mLockUsers[userIndex]; if (user.userType != UserTypeEnum::kScheduleRestrictedUser && user.userType != UserTypeEnum::kWeekDayScheduleUser) { - return true; + // Weekday schedules don't apply to this user. + return false; + } + + if (user.userType == UserTypeEnum::kScheduleRestrictedUser && !*haveSchedule) + { + // It's valid to not have any schedules of a given type; on its own this + // does not prevent access. + return false; } chip::System::Clock::Milliseconds64 cTMs; @@ -575,7 +587,7 @@ bool LockEndpoint::weekDayScheduleInAction(uint16_t userIndex) const { ChipLogError(Zcl, "Lock App: unable to get current time to check user schedules [endpointId=%d,error=%d (%s)]", mEndpointId, chipError.AsInteger(), chipError.AsString()); - return false; + return true; } time_t unixEpoch = std::chrono::duration_cast(cTMs).count(); @@ -585,8 +597,9 @@ bool LockEndpoint::weekDayScheduleInAction(uint16_t userIndex) const auto currentTime = calendarTime.tm_hour * chip::kSecondsPerHour + calendarTime.tm_min * chip::kSecondsPerMinute + calendarTime.tm_sec; - // Second, check the week day schedules. - return std::any_of( + // Now check whether any schedule allows the current time. If it does, + // access is not forbidden. + return !std::any_of( mWeekDaySchedules[userIndex].begin(), mWeekDaySchedules[userIndex].end(), [currentTime, calendarTime](const WeekDaysScheduleInfo & s) { auto startTime = s.schedule.startHour * chip::kSecondsPerHour + s.schedule.startMinute * chip::kSecondsPerMinute; @@ -596,12 +609,22 @@ bool LockEndpoint::weekDayScheduleInAction(uint16_t userIndex) const }); } -bool LockEndpoint::yearDayScheduleInAction(uint16_t userIndex) const +bool LockEndpoint::yearDayScheduleForbidsAccess(uint16_t userIndex, bool * haveSchedule) const { + *haveSchedule = std::any_of(mYearDaySchedules[userIndex].begin(), mYearDaySchedules[userIndex].end(), + [](const YearDayScheduleInfo & sch) { return sch.status == DlScheduleStatus::kOccupied; }); + const auto & user = mLockUsers[userIndex]; if (user.userType != UserTypeEnum::kScheduleRestrictedUser && user.userType != UserTypeEnum::kYearDayScheduleUser) { - return true; + return false; + } + + if (user.userType == UserTypeEnum::kScheduleRestrictedUser && !*haveSchedule) + { + // It's valid to not have any schedules of a given type; on its own this + // does not prevent access. + return false; } chip::System::Clock::Milliseconds64 cTMs; @@ -610,7 +633,7 @@ bool LockEndpoint::yearDayScheduleInAction(uint16_t userIndex) const { ChipLogError(Zcl, "Lock App: unable to get current time to check user schedules [endpointId=%d,error=%d (%s)]", mEndpointId, chipError.AsInteger(), chipError.AsString()); - return false; + return true; } auto unixEpoch = std::chrono::duration_cast(cTMs).count(); uint32_t chipEpoch = 0; @@ -623,11 +646,11 @@ bool LockEndpoint::yearDayScheduleInAction(uint16_t userIndex) const return false; } - return std::any_of(mYearDaySchedules[userIndex].begin(), mYearDaySchedules[userIndex].end(), - [chipEpoch](const YearDayScheduleInfo & sch) { - return sch.status == DlScheduleStatus::kOccupied && sch.schedule.localStartTime <= chipEpoch && - chipEpoch <= sch.schedule.localEndTime; - }); + return !std::any_of(mYearDaySchedules[userIndex].begin(), mYearDaySchedules[userIndex].end(), + [chipEpoch](const YearDayScheduleInfo & sch) { + return sch.status == DlScheduleStatus::kOccupied && sch.schedule.localStartTime <= chipEpoch && + chipEpoch <= sch.schedule.localEndTime; + }); } const char * LockEndpoint::lockStateToString(DlLockState lockState) const diff --git a/examples/lock-app/nxp/zap/lock-app.matter b/examples/lock-app/nxp/zap/lock-app.matter index add41c8ba65225..9c3fb965dfc2e7 100644 --- a/examples/lock-app/nxp/zap/lock-app.matter +++ b/examples/lock-app/nxp/zap/lock-app.matter @@ -558,6 +558,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -614,10 +618,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1820,8 +1836,8 @@ endpoint 0 { callback attribute rebootCount; callback attribute upTime; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/lock-app/qpg/zap/lock.matter b/examples/lock-app/qpg/zap/lock.matter index e5546521e7343b..91ff76970813f1 100644 --- a/examples/lock-app/qpg/zap/lock.matter +++ b/examples/lock-app/qpg/zap/lock.matter @@ -836,6 +836,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -892,10 +896,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2281,8 +2297,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/lock-app/telink/Kconfig b/examples/lock-app/telink/Kconfig index 5238b4423a4196..640a54e73d45a4 100644 --- a/examples/lock-app/telink/Kconfig +++ b/examples/lock-app/telink/Kconfig @@ -15,5 +15,16 @@ # mainmenu "Matter Telink Lock Example Application" +if BOARD_TLSR9528A_RETENTION || BOARD_TLSR9518ADK80D_RETENTION +config COMMON_LIBC_MALLOC_ARENA_SIZE + default 9216 +endif + +config SETTINGS_NVS_NAME_CACHE + default y + +config SETTINGS_NVS_NAME_CACHE_SIZE + default 256 + rsource "../../../config/telink/chip-module/Kconfig.defaults" source "Kconfig.zephyr" diff --git a/examples/lock-app/telink/boards/tlsr9518adk80d.overlay b/examples/lock-app/telink/boards/tlsr9518adk80d.overlay new file mode 100644 index 00000000000000..47b56fd18a0718 --- /dev/null +++ b/examples/lock-app/telink/boards/tlsr9518adk80d.overlay @@ -0,0 +1,16 @@ +/ { + keys { + compatible = "gpio-keys"; + key_5: button_5 { + gpios = <&gpioe 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + }; + key_6: button_6 { + gpios = <&gpioe 1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + }; + }; +}; + +&gpioe { + interrupts = <38 1>; + status = "okay"; +}; \ No newline at end of file diff --git a/examples/lock-app/telink/boards/tlsr9528a.overlay b/examples/lock-app/telink/boards/tlsr9528a.overlay new file mode 100644 index 00000000000000..ebcb0aec07bc67 --- /dev/null +++ b/examples/lock-app/telink/boards/tlsr9528a.overlay @@ -0,0 +1,16 @@ +/ { + keys { + compatible = "gpio-keys"; + key_5: button_5 { + gpios = <&gpiob 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + }; + key_6: button_6 { + gpios = <&gpiob 7 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + }; + }; +}; + +&gpiob { + interrupts = <39 1>; + status = "okay"; +}; \ No newline at end of file diff --git a/examples/lock-app/telink/boards/tlsr9528a_retention.overlay b/examples/lock-app/telink/boards/tlsr9528a_retention.overlay new file mode 100644 index 00000000000000..9b728f8b4d9e10 --- /dev/null +++ b/examples/lock-app/telink/boards/tlsr9528a_retention.overlay @@ -0,0 +1,16 @@ +/ { + keys { + compatible = "gpio-keys"; + key_5: button_5 { + gpios = <&gpiob 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + }; + key_6: button_6 { + gpios = <&gpiob 7 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + }; + }; +}; + +&gpiob { + interrupts = <39 1>; + status = "okay"; +}; diff --git a/examples/lock-app/telink/include/AppConfig.h b/examples/lock-app/telink/include/AppConfig.h index 05bbd6afa79d46..cb4b0c2b488d86 100644 --- a/examples/lock-app/telink/include/AppConfig.h +++ b/examples/lock-app/telink/include/AppConfig.h @@ -23,6 +23,14 @@ #define LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE 1 #define LOCK_MANAGER_ACTUATOR_MOVEMENT_TIME_MS 2000 +#define APP_MAX_USERS 10 +#define APP_MAX_CREDENTIAL 10 +#define APP_MAX_WEEKDAY_SCHEDULE_PER_USER 10 +#define APP_MAX_YEARDAY_SCHEDULE_PER_USER 10 +#define APP_MAX_HOLYDAY_SCHEDULE_PER_USER 10 + +#define APP_MAX_SCHEDULES_TOTAL 100 + #define APP_DEFAULT_USERS_COUNT 5 #define APP_DEFAULT_CREDENTIAL_COUNT 5 #define APP_DEFAULT_WEEKDAY_SCHEDULE_PER_USER_COUNT 5 diff --git a/examples/lock-app/telink/include/AppTask.h b/examples/lock-app/telink/include/AppTask.h index d5244bb7b7728f..fb0f4113d4af9f 100644 --- a/examples/lock-app/telink/include/AppTask.h +++ b/examples/lock-app/telink/include/AppTask.h @@ -40,6 +40,10 @@ class AppTask : public AppTaskCommon static void LockActionEventHandler(AppEvent * event); static void LockStateChanged(LockManager::State_t state); + static void LockJammedEventHandler(void); + static void LockJammedActionHandler(AppEvent * aEvent); + static void LockStateEventHandler(void); + static void LockStateActionHandler(AppEvent * aEvent); static AppTask sAppTask; }; diff --git a/examples/lock-app/telink/include/LockManager.h b/examples/lock-app/telink/include/LockManager.h index 72fbcc648216cd..4420b4789562ec 100644 --- a/examples/lock-app/telink/include/LockManager.h +++ b/examples/lock-app/telink/include/LockManager.h @@ -30,34 +30,27 @@ struct WeekDaysScheduleInfo { - DlScheduleStatus status; + DlScheduleStatus status = DlScheduleStatus::kAvailable; EmberAfPluginDoorLockWeekDaySchedule schedule; }; struct YearDayScheduleInfo { - DlScheduleStatus status; + DlScheduleStatus status = DlScheduleStatus::kAvailable; EmberAfPluginDoorLockYearDaySchedule schedule; }; struct HolidayScheduleInfo { - DlScheduleStatus status; + DlScheduleStatus status = DlScheduleStatus::kAvailable; EmberAfPluginDoorLockHolidaySchedule schedule; }; namespace TelinkDoorLock { namespace ResourceRanges { // Used to size arrays -static constexpr uint16_t kMaxUsers = 10; -static constexpr uint8_t kMaxCredentialsPerUser = 10; -static constexpr uint8_t kMaxWeekdaySchedulesPerUser = 10; -static constexpr uint8_t kMaxYeardaySchedulesPerUser = 10; -static constexpr uint8_t kMaxHolidaySchedules = 10; -static constexpr uint8_t kMaxCredentialSize = 20; -static constexpr uint8_t kNumCredentialTypes = 6; - -static constexpr uint8_t kMaxCredentials = kMaxUsers * kMaxCredentialsPerUser; +static constexpr uint8_t kMaxCredentialSize = 20; +static constexpr uint8_t kNumCredentialTypes = 6; } // namespace ResourceRanges @@ -197,10 +190,6 @@ class LockManager OperationSource mActuatorOperationSource = OperationSource::kButton; k_timer mActuatorTimer = {}; -#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE - bool ReadConfigValues(); -#endif - bool setLockState(chip::EndpointId endpointId, DlLockState lockState, OperationSource source, OperationErrorEnum & err, const Nullable & fabricIdx, const Nullable & nodeId, const Optional & pin); @@ -208,15 +197,17 @@ class LockManager static void ActuatorTimerEventHandler(k_timer * timer); static void ActuatorAppEventHandler(const AppEvent & event); - EmberAfPluginDoorLockUserInfo mLockUsers[kMaxUsers]; - EmberAfPluginDoorLockCredentialInfo mLockCredentials[kNumCredentialTypes][kMaxCredentials]; - WeekDaysScheduleInfo mWeekdaySchedule[kMaxUsers][kMaxWeekdaySchedulesPerUser]; - YearDayScheduleInfo mYeardaySchedule[kMaxUsers][kMaxYeardaySchedulesPerUser]; - HolidayScheduleInfo mHolidaySchedule[kMaxHolidaySchedules]; +#if !LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE + EmberAfPluginDoorLockUserInfo mLockUsers[APP_MAX_USERS]; + EmberAfPluginDoorLockCredentialInfo mLockCredentials[kNumCredentialTypes][APP_MAX_CREDENTIAL]; + WeekDaysScheduleInfo mWeekdaySchedule[APP_MAX_USERS][APP_MAX_WEEKDAY_SCHEDULE_PER_USER]; + YearDayScheduleInfo mYeardaySchedule[APP_MAX_USERS][APP_MAX_YEARDAY_SCHEDULE_PER_USER]; + HolidayScheduleInfo mHolidaySchedule[APP_MAX_HOLYDAY_SCHEDULE_PER_USER]; char mUserNames[ArraySize(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; - uint8_t mCredentialData[kNumCredentialTypes][kMaxCredentials][kMaxCredentialSize]; - CredentialStruct mCredentials[kMaxUsers][kMaxCredentials]; + uint8_t mCredentialData[kNumCredentialTypes][APP_MAX_CREDENTIAL][kMaxCredentialSize]; + CredentialStruct mCredentials[APP_MAX_USERS][APP_MAX_CREDENTIAL]; +#endif static LockManager sLock; TelinkDoorLock::LockInitParams::LockParam LockParams; diff --git a/examples/lock-app/telink/include/LockSettingsStorage.h b/examples/lock-app/telink/include/LockSettingsStorage.h index fd2c7939139327..b33629f3fc73ff 100644 --- a/examples/lock-app/telink/include/LockSettingsStorage.h +++ b/examples/lock-app/telink/include/LockSettingsStorage.h @@ -28,14 +28,25 @@ namespace Internal { class LockSettingsStorage : ZephyrConfig { public: - static const ZephyrConfig::Key kConfigKey_LockUser; - static const ZephyrConfig::Key kConfigKey_LockUserName; - static const ZephyrConfig::Key kConfigKey_UserCredentials; - static const ZephyrConfig::Key kConfigKey_WeekDaySchedules; - static const ZephyrConfig::Key kConfigKey_YearDaySchedules; - static const ZephyrConfig::Key kConfigKey_HolidaySchedules; - static const char * kConfigKey_Credential[kNumCredentialTypes]; - static const char * kConfigKey_CredentialData[kNumCredentialTypes]; + static const char * kConfigKey_LockUser[APP_MAX_USERS]; + static const char * kConfigKey_LockUserName[APP_MAX_USERS]; + static const char * kConfigKey_UserCredentials[APP_MAX_CREDENTIAL]; + static const char * kConfigKey_WeekDaySchedules[APP_MAX_USERS][APP_MAX_WEEKDAY_SCHEDULE_PER_USER]; + static const char * kConfigKey_YearDaySchedules[APP_MAX_USERS][APP_MAX_YEARDAY_SCHEDULE_PER_USER]; + static const char * kConfigKey_HolidaySchedules[APP_MAX_HOLYDAY_SCHEDULE_PER_USER]; + + static const char * kConfigKey_CredentialPin[APP_MAX_CREDENTIAL]; + static const char * kConfigKey_CredentialFace[APP_MAX_CREDENTIAL]; + static const char * kConfigKey_CredentialFingerprint[APP_MAX_CREDENTIAL]; + static const char * kConfigKey_CredentialFingervein[APP_MAX_CREDENTIAL]; + static const char * kConfigKey_CredentialRfid[APP_MAX_CREDENTIAL]; + + static const char * kConfigKey_CredentialData[APP_MAX_CREDENTIAL]; + static const char * kConfigKey_CredentialDataPin[APP_MAX_CREDENTIAL]; + static const char * kConfigKey_CredentialDataFace[APP_MAX_CREDENTIAL]; + static const char * kConfigKey_CredentialDataFingerprint[APP_MAX_CREDENTIAL]; + static const char * kConfigKey_CredentialDataFingerVein[APP_MAX_CREDENTIAL]; + static const char * kConfigKey_CredentialDataRfid[APP_MAX_CREDENTIAL]; }; } // namespace Internal } // namespace DeviceLayer diff --git a/examples/lock-app/telink/src/AppTask.cpp b/examples/lock-app/telink/src/AppTask.cpp index 11f8499bd5bd41..19748544f8d15d 100644 --- a/examples/lock-app/telink/src/AppTask.cpp +++ b/examples/lock-app/telink/src/AppTask.cpp @@ -17,6 +17,7 @@ */ #include "AppTask.h" +#include "ButtonManager.h" #include #include #include @@ -39,12 +40,20 @@ LEDWidget sLockLED; } // namespace AppTask AppTask::sAppTask; +static const struct gpio_dt_spec sLockJammedInputDt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_5), gpios); +static const struct gpio_dt_spec sLockStatusInputDt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_6), gpios); +Button sLockJammedAction; +Button sLockStatusChangedAction; CHIP_ERROR AppTask::Init(void) { #if APP_USE_EXAMPLE_START_BUTTON SetExampleButtonCallbacks(LockActionEventHandler); #endif + sLockJammedAction.Configure(&sLockJammedInputDt, LockJammedEventHandler); + sLockStatusChangedAction.Configure(&sLockStatusInputDt, LockStateEventHandler); + ButtonManagerInst().AddButton(sLockJammedAction); + ButtonManagerInst().AddButton(sLockStatusChangedAction); InitCommonParts(); #if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED @@ -200,3 +209,51 @@ void AppTask::LockStateChanged(LockManager::State_t state) break; } } + +void AppTask::LockJammedEventHandler(void) +{ + AppEvent event; + + event.Type = AppEvent::kEventType_Button; + event.ButtonEvent.Action = kButtonPushEvent; + event.Handler = LockJammedActionHandler; + GetAppTask().PostEvent(&event); +} + +void AppTask::LockJammedActionHandler(AppEvent * aEvent) +{ + LOG_INF("Sending a lock jammed event"); + + /* Generating Door Lock Jammed event */ + DoorLockServer::Instance().SendLockAlarmEvent(kExampleEndpointId, AlarmCodeEnum::kLockJammed); +} + +void AppTask::LockStateEventHandler(void) +{ + AppEvent event; + + event.Type = AppEvent::kEventType_Button; + event.ButtonEvent.Action = kButtonPushEvent; + event.Handler = LockStateActionHandler; + GetAppTask().PostEvent(&event); +} + +void AppTask::LockStateActionHandler(AppEvent * aEvent) +{ + LOG_INF("Sending a lock state event"); + + // This code was written for testing purpose only + // For real door status the level detection may be used instead of pulse + static DoorStateEnum mDoorState = DoorStateEnum::kDoorOpen; + if (mDoorState == DoorStateEnum::kDoorOpen) + { + mDoorState = DoorStateEnum::kDoorClosed; + } + else + { + mDoorState = DoorStateEnum::kDoorOpen; + } + + /* Generating Door Lock Status event */ + DoorLockServer::Instance().SetDoorState(kExampleEndpointId, mDoorState); +} diff --git a/examples/lock-app/telink/src/LockManager.cpp b/examples/lock-app/telink/src/LockManager.cpp index 529e1aa557fa7c..070503a1a144c9 100644 --- a/examples/lock-app/telink/src/LockManager.cpp +++ b/examples/lock-app/telink/src/LockManager.cpp @@ -32,61 +32,68 @@ LockManager LockManager::sLock; using namespace ::chip::DeviceLayer::Internal; using namespace TelinkDoorLock::LockInitParams; +#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE +__attribute__((section(".data"))) EmberAfPluginDoorLockUserInfo mCurrentLockUsers; + +__attribute__((section(".data"))) char mCurrentUserNames[DOOR_LOCK_MAX_USER_NAME_SIZE]; +__attribute__((section(".data"))) uint8_t mCurrentCredentialData[kMaxCredentialSize]; +__attribute__((section(".data"))) CredentialStruct mCurrentCredentials[APP_MAX_CREDENTIAL]; +__attribute__((section(".data"))) HolidayScheduleInfo mHolidaySchedule; +__attribute__((section(".data"))) WeekDaysScheduleInfo mWeekdaySchedule; +__attribute__((section(".data"))) YearDayScheduleInfo mYeardaySchedule; +#endif + CHIP_ERROR LockManager::Init(chip::app::DataModel::Nullable state, LockParam lockParam, StateChangeCallback callback) { LockParams = lockParam; mStateChangeCallback = callback; - if (LockParams.numberOfUsers > kMaxUsers) + if (LockParams.numberOfUsers > APP_MAX_USERS) { ChipLogError(Zcl, "Max number of users %d is greater than %d, the maximum amount of users currently supported on this platform", - LockParams.numberOfUsers, kMaxUsers); + LockParams.numberOfUsers, APP_MAX_USERS); return APP_ERROR_ALLOCATION_FAILED; } - if (LockParams.numberOfCredentialsPerUser > kMaxCredentialsPerUser) + if (LockParams.numberOfCredentialsPerUser > APP_MAX_CREDENTIAL) { ChipLogError( Zcl, "Max number of credentials per user %d is greater than %d, the maximum amount of users currently supported on this " "platform", - LockParams.numberOfCredentialsPerUser, kMaxCredentialsPerUser); + LockParams.numberOfCredentialsPerUser, APP_MAX_CREDENTIAL); return APP_ERROR_ALLOCATION_FAILED; } - if (LockParams.numberOfWeekdaySchedulesPerUser > kMaxWeekdaySchedulesPerUser) + if (LockParams.numberOfWeekdaySchedulesPerUser > APP_MAX_WEEKDAY_SCHEDULE_PER_USER) { ChipLogError( Zcl, "Max number of schedules %d is greater than %d, the maximum amount of schedules currently supported on this platform", - LockParams.numberOfWeekdaySchedulesPerUser, kMaxWeekdaySchedulesPerUser); + LockParams.numberOfWeekdaySchedulesPerUser, APP_MAX_WEEKDAY_SCHEDULE_PER_USER); return APP_ERROR_ALLOCATION_FAILED; } - if (LockParams.numberOfYeardaySchedulesPerUser > kMaxYeardaySchedulesPerUser) + if (LockParams.numberOfYeardaySchedulesPerUser > APP_MAX_YEARDAY_SCHEDULE_PER_USER) { ChipLogError( Zcl, "Max number of schedules %d is greater than %d, the maximum amount of schedules currently supported on this platform", - LockParams.numberOfYeardaySchedulesPerUser, kMaxYeardaySchedulesPerUser); + LockParams.numberOfYeardaySchedulesPerUser, APP_MAX_YEARDAY_SCHEDULE_PER_USER); return APP_ERROR_ALLOCATION_FAILED; } - if (LockParams.numberOfHolidaySchedules > kMaxHolidaySchedules) + if (LockParams.numberOfHolidaySchedules > APP_MAX_HOLYDAY_SCHEDULE_PER_USER) { ChipLogError( Zcl, "Max number of schedules %d is greater than %d, the maximum amount of schedules currently supported on this platform", - LockParams.numberOfHolidaySchedules, kMaxHolidaySchedules); + LockParams.numberOfHolidaySchedules, APP_MAX_HOLYDAY_SCHEDULE_PER_USER); return APP_ERROR_ALLOCATION_FAILED; } -#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE - ReadConfigValues(); -#endif - k_timer_init(&mActuatorTimer, &LockManager::ActuatorTimerEventHandler, nullptr); k_timer_user_data_set(&mActuatorTimer, this); @@ -393,7 +400,7 @@ void LockManager::ActuatorAppEventHandler(const AppEvent & event) bool LockManager::IsValidUserIndex(uint16_t userIndex) { - return (userIndex < kMaxUsers); + return (userIndex < APP_MAX_USERS); } bool LockManager::IsValidCredentialIndex(uint16_t credentialIndex, CredentialTypeEnum type) @@ -402,7 +409,7 @@ bool LockManager::IsValidCredentialIndex(uint16_t credentialIndex, CredentialTyp { return (0 == credentialIndex); // 0 is required index for Programming PIN } - return (credentialIndex < kMaxCredentialsPerUser); + return (credentialIndex < APP_MAX_CREDENTIAL); } bool LockManager::IsValidCredentialType(CredentialTypeEnum type) @@ -412,73 +419,61 @@ bool LockManager::IsValidCredentialType(CredentialTypeEnum type) bool LockManager::IsValidWeekdayScheduleIndex(uint8_t scheduleIndex) { - return (scheduleIndex < kMaxWeekdaySchedulesPerUser); + return (scheduleIndex < APP_MAX_WEEKDAY_SCHEDULE_PER_USER); } bool LockManager::IsValidYeardayScheduleIndex(uint8_t scheduleIndex) { - return (scheduleIndex < kMaxYeardaySchedulesPerUser); + return (scheduleIndex < APP_MAX_YEARDAY_SCHEDULE_PER_USER); } bool LockManager::IsValidHolidayScheduleIndex(uint8_t scheduleIndex) { - return (scheduleIndex < kMaxHolidaySchedules); + return (scheduleIndex < APP_MAX_HOLYDAY_SCHEDULE_PER_USER); } -#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE -bool LockManager::ReadConfigValues() +bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) { - size_t outLen; - ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), - sizeof(EmberAfPluginDoorLockUserInfo) * ArraySize(mLockUsers), outLen); + VerifyOrReturnValue(userIndex > 0, false); // indices are one-indexed - ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_LockUserName, reinterpret_cast(mUserNames), - sizeof(mUserNames), outLen); + userIndex--; - ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_UserCredentials, reinterpret_cast(mCredentials), - sizeof(CredentialStruct) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser, - outLen); + VerifyOrReturnValue(IsValidUserIndex(userIndex), false); - ZephyrConfig::ReadConfigValueBin( - LockSettingsStorage::kConfigKey_WeekDaySchedules, reinterpret_cast(mWeekdaySchedule), - sizeof(EmberAfPluginDoorLockWeekDaySchedule) * LockParams.numberOfWeekdaySchedulesPerUser * LockParams.numberOfUsers, - outLen); + ChipLogProgress(Zcl, "Door Lock App: LockManager::GetUser [endpoint=%d,userIndex=%hu]", endpointId, userIndex); + +#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE + size_t outLen; - ZephyrConfig::ReadConfigValueBin( - LockSettingsStorage::kConfigKey_YearDaySchedules, reinterpret_cast(mYeardaySchedule), - sizeof(EmberAfPluginDoorLockYearDaySchedule) * LockParams.numberOfYeardaySchedulesPerUser * LockParams.numberOfUsers, - outLen); + auto & userInDb = mCurrentLockUsers; + auto & credentialsInStorage = mCurrentCredentials; + EmberAfPluginDoorLockUserInfo lockUser; + char userNames[DOOR_LOCK_MAX_USER_NAME_SIZE]; - ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_HolidaySchedules, - reinterpret_cast(&(mHolidaySchedule)), - sizeof(EmberAfPluginDoorLockHolidaySchedule) * LockParams.numberOfHolidaySchedules, outLen); + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_LockUser[userIndex], reinterpret_cast(&lockUser), + sizeof(EmberAfPluginDoorLockUserInfo), outLen); + userInDb = lockUser; - for (uint8_t i = 0; i < kNumCredentialTypes; i++) + CredentialStruct credentialsUsers[APP_MAX_CREDENTIAL]; + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_UserCredentials[userIndex], + reinterpret_cast(credentialsUsers), + sizeof(CredentialStruct) * LockParams.numberOfCredentialsPerUser, outLen); + for (size_t i = 0; i < userInDb.credentials.size(); ++i) { - ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_Credential[i], - reinterpret_cast(&mLockCredentials[i]), - sizeof(EmberAfPluginDoorLockCredentialInfo) * kMaxCredentials, outLen); - - ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialData[i], - reinterpret_cast(mCredentialData[i]), kMaxCredentials * kMaxCredentialSize, - outLen); + credentialsInStorage[i] = credentialsUsers[i]; } + userInDb.credentials = chip::Span(credentialsInStorage, userInDb.credentials.size()); - return true; -} -#endif + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_LockUserName[userIndex], + reinterpret_cast(userNames), sizeof(userNames), outLen); -bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) -{ - VerifyOrReturnValue(userIndex > 0, false); // indices are one-indexed - - userIndex--; + chip::Platform::CopyString(mCurrentUserNames, userNames); + userInDb.userName = chip::CharSpan(mCurrentUserNames, userInDb.userName.size()); - VerifyOrReturnValue(IsValidUserIndex(userIndex), false); - - ChipLogProgress(Zcl, "Door Lock App: LockManager::GetUser [endpoint=%d,userIndex=%hu]", endpointId, userIndex); - - const auto & userInDb = mLockUsers[userIndex]; +#else + const auto & userInDb = mLockUsers[userIndex]; + const auto & credentialsInStorage = mCredentials[userIndex]; +#endif user.userStatus = userInDb.userStatus; if (UserStatusEnum::kAvailable == user.userStatus) @@ -488,7 +483,7 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember } user.userName = chip::CharSpan(userInDb.userName.data(), userInDb.userName.size()); - user.credentials = chip::Span(mCredentials[userIndex], userInDb.credentials.size()); + user.credentials = chip::Span(credentialsInStorage, userInDb.credentials.size()); user.userUniqueId = userInDb.userUniqueId; user.userType = userInDb.userType; user.credentialRule = userInDb.credentialRule; @@ -506,7 +501,6 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember endpointId, static_cast(user.userName.size()), user.userName.data(), user.credentials.size(), user.userUniqueId, to_underlying(user.userType), to_underlying(user.credentialRule), user.createdBy, user.lastModifiedBy); - return true; } @@ -527,7 +521,30 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip: VerifyOrReturnValue(IsValidUserIndex(userIndex), false); - auto & userInStorage = mLockUsers[userIndex]; +#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE + size_t outLen; + EmberAfPluginDoorLockUserInfo lockUser; + CredentialStruct credentialsUsers[APP_MAX_CREDENTIAL]; + char userNames[DOOR_LOCK_MAX_USER_NAME_SIZE]; + + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_LockUser[userIndex], reinterpret_cast(&lockUser), + sizeof(EmberAfPluginDoorLockUserInfo), outLen); + + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_UserCredentials[userIndex], + reinterpret_cast(credentialsUsers), + sizeof(CredentialStruct) * LockParams.numberOfCredentialsPerUser, outLen); + + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_LockUserName[userIndex], + reinterpret_cast(userNames), sizeof(userNames), outLen); + + auto & userInStorage = lockUser; + auto & credentialsInStorage = credentialsUsers; + auto & userNamesInStorage = userNames; +#else + auto & userInStorage = mLockUsers[userIndex]; + auto & credentialsInStorage = mCredentials[userIndex]; + auto & userNamesInStorage = mUserNames[userIndex]; +#endif if (userName.size() > DOOR_LOCK_MAX_USER_NAME_SIZE) { @@ -542,8 +559,8 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip: return false; } - chip::Platform::CopyString(mUserNames[userIndex], userName); - userInStorage.userName = chip::CharSpan(mUserNames[userIndex], userName.size()); + chip::Platform::CopyString(userNamesInStorage, userName); + userInStorage.userName = chip::CharSpan(userNamesInStorage, userName.size()); userInStorage.userUniqueId = uniqueId; userInStorage.userStatus = userStatus; userInStorage.userType = usertype; @@ -553,33 +570,37 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip: for (size_t i = 0; i < totalCredentials; ++i) { - mCredentials[userIndex][i] = credentials[i]; + credentialsInStorage[i] = credentials[i]; } - userInStorage.credentials = chip::Span(mCredentials[userIndex], totalCredentials); + userInStorage.credentials = chip::Span(credentialsInStorage, totalCredentials); #if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE - // Save user information in NVM flash CHIP_ERROR err = - ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), - sizeof(EmberAfPluginDoorLockUserInfo) * LockParams.numberOfUsers); + ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_LockUser[userIndex], + reinterpret_cast(&lockUser), sizeof(EmberAfPluginDoorLockUserInfo)); if (err != CHIP_NO_ERROR) - ChipLogError(Zcl, - "Failed to write kConfigKey_LockUser. User data will be resetted during reboot. Not enough storage space \n"); + { + ChipLogError(Zcl, "Failed to write kConfigKey_LockUser to NVM\n"); + return false; + } - err = ZephyrConfig::WriteConfigValueBin( - LockSettingsStorage::kConfigKey_UserCredentials, reinterpret_cast(mCredentials), - sizeof(CredentialStruct) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser); + err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_UserCredentials[userIndex], + reinterpret_cast(credentialsUsers), + sizeof(CredentialStruct) * LockParams.numberOfCredentialsPerUser); if (err != CHIP_NO_ERROR) - ChipLogError( - Zcl, - "Failed to write kConfigKey_UserCredentials. User data will be resetted during reboot. Not enough storage space \n"); + { + ChipLogError(Zcl, "Failed to write kConfigKey_UserCredentials to NVM\n"); + return false; + } - ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_LockUserName, reinterpret_cast(mUserNames), - sizeof(mUserNames)); + err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_LockUserName[userIndex], + reinterpret_cast(userNames), sizeof(userNames)); if (err != CHIP_NO_ERROR) - ChipLogError( - Zcl, "Failed to write kConfigKey_LockUserName. User data will be resetted during reboot. Not enough storage space \n"); + { + ChipLogError(Zcl, "Failed to write kConfigKey_LockUserName to NVM\n"); + return false; + } #endif ChipLogProgress(Zcl, "Successfully set the user [mEndpointId=%d,index=%d]", endpointId, userIndex); @@ -590,7 +611,6 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip: bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { - VerifyOrReturnValue(IsValidCredentialType(credentialType), false); if (CredentialTypeEnum::kProgrammingPIN == credentialType) @@ -606,7 +626,65 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential ChipLogProgress(Zcl, "Lock App: LockManager::GetCredential [credentialType=%u], credentialIndex=%d", to_underlying(credentialType), credentialIndex); - const auto & credentialInStorage = mLockCredentials[to_underlying(credentialType)][credentialIndex]; +#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE + size_t outLen; + EmberAfPluginDoorLockCredentialInfo lockCredentials; + uint8_t lockCredentialsData[kMaxCredentialSize] = { 0 }; + + auto & credentialInStorage = lockCredentials; + + switch (credentialType) + { + case CredentialTypeEnum::kProgrammingPIN: + ChipLogError(Zcl, "CredentialTypeEnum::kProgrammingPIN must not be specified as a new credential\n"); + break; + case CredentialTypeEnum::kPin: + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialPin[credentialIndex], + reinterpret_cast(&lockCredentials), sizeof(EmberAfPluginDoorLockCredentialInfo), + outLen); + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataPin[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize, outLen); + break; + case CredentialTypeEnum::kFace: + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialFace[credentialIndex], + reinterpret_cast(&lockCredentials), sizeof(EmberAfPluginDoorLockCredentialInfo), + outLen); + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataFace[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize, outLen); + break; + case CredentialTypeEnum::kFingerprint: + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialFingerprint[credentialIndex], + reinterpret_cast(&lockCredentials), sizeof(EmberAfPluginDoorLockCredentialInfo), + outLen); + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataFingerprint[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize, outLen); + break; + case CredentialTypeEnum::kFingerVein: + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialFingervein[credentialIndex], + reinterpret_cast(&lockCredentials), sizeof(EmberAfPluginDoorLockCredentialInfo), + outLen); + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataFingerVein[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize, outLen); + break; + case CredentialTypeEnum::kRfid: + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialRfid[credentialIndex], + reinterpret_cast(&lockCredentials), sizeof(EmberAfPluginDoorLockCredentialInfo), + outLen); + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataRfid[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize, outLen); + break; + default: + ChipLogError(Zcl, + "Lock App: LockManager::GetCredential [credentialType=%u], credentialIndex=%d : Credential Type not specified", + to_underlying(credentialType), credentialIndex); + break; + } + + memcpy(mCurrentCredentialData, lockCredentialsData, credentialInStorage.credentialData.size()); + credentialInStorage.credentialData = chip::ByteSpan{ mCurrentCredentialData, credentialInStorage.credentialData.size() }; +#else + const auto & credentialInStorage = mLockCredentials[to_underlying(credentialType)][credentialIndex]; +#endif credential.status = credentialInStorage.status; ChipLogProgress(Zcl, "CredentialStatus: %d, CredentialIndex: %d ", (int) credential.status, credentialIndex); @@ -636,6 +714,11 @@ bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credential const chip::ByteSpan & credentialData) { + // TODO: It may be a need to perform a check, if the credential type already exists. + // The credential setter doesn't contain the user index, so the amount of 10 credentials per user can be satisfied only in case, + // if each credential type exists only once per one user. Otherwise, it can be the situation, when one user creates 10 pin + // codes, so the next one user can't create any pincode, but can create the other types of credentials. + VerifyOrReturnValue(IsValidCredentialType(credentialType), false); if (CredentialTypeEnum::kProgrammingPIN == credentialType) @@ -653,35 +736,142 @@ bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credential "[credentialStatus=%u,credentialType=%u,credentialDataSize=%u,creator=%d,modifier=%d]", to_underlying(credentialStatus), to_underlying(credentialType), credentialData.size(), creator, modifier); - auto & credentialInStorage = mLockCredentials[to_underlying(credentialType)][credentialIndex]; +#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE + size_t outLen; + EmberAfPluginDoorLockCredentialInfo lockCredentials; + uint8_t lockCredentialsData[kMaxCredentialSize] = { 0 }; + + switch (credentialType) + { + case CredentialTypeEnum::kProgrammingPIN: + ChipLogError(Zcl, "CredentialTypeEnum::kProgrammingPIN must not be specified as a new credential\n"); + break; + case CredentialTypeEnum::kPin: + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialPin[credentialIndex], + reinterpret_cast(&lockCredentials), sizeof(EmberAfPluginDoorLockCredentialInfo), + outLen); + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataPin[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize, outLen); + break; + case CredentialTypeEnum::kFace: + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialFace[credentialIndex], + reinterpret_cast(&lockCredentials), sizeof(EmberAfPluginDoorLockCredentialInfo), + outLen); + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataFace[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize, outLen); + break; + case CredentialTypeEnum::kFingerprint: + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialFingerprint[credentialIndex], + reinterpret_cast(&lockCredentials), sizeof(EmberAfPluginDoorLockCredentialInfo), + outLen); + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataFingerprint[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize, outLen); + break; + case CredentialTypeEnum::kFingerVein: + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialFingervein[credentialIndex], + reinterpret_cast(&lockCredentials), sizeof(EmberAfPluginDoorLockCredentialInfo), + outLen); + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataFingerVein[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize, outLen); + break; + case CredentialTypeEnum::kRfid: + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialRfid[credentialIndex], + reinterpret_cast(&lockCredentials), sizeof(EmberAfPluginDoorLockCredentialInfo), + outLen); + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataRfid[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize, outLen); + break; + default: + ChipLogError(Zcl, + "Lock App: LockManager::GetCredential [credentialType=%u], credentialIndex=%d : Credential Type not specified", + to_underlying(credentialType), credentialIndex); + break; + } + + auto & credentialInStorage = lockCredentials; + auto & credentialDataInStorage = lockCredentialsData; +#else + auto & credentialInStorage = mLockCredentials[to_underlying(credentialType)][credentialIndex]; + auto & credentialDataInStorage = mCredentialData[to_underlying(credentialType)][credentialIndex]; +#endif credentialInStorage.status = credentialStatus; credentialInStorage.credentialType = credentialType; credentialInStorage.createdBy = creator; credentialInStorage.lastModifiedBy = modifier; - memcpy(mCredentialData[to_underlying(credentialType)][credentialIndex], credentialData.data(), credentialData.size()); - credentialInStorage.credentialData = - chip::ByteSpan{ mCredentialData[to_underlying(credentialType)][credentialIndex], credentialData.size() }; + memcpy(credentialDataInStorage, credentialData.data(), credentialData.size()); + credentialInStorage.credentialData = chip::ByteSpan{ credentialDataInStorage, credentialData.size() }; #if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE - CHIP_ERROR err; + CHIP_ERROR err = CHIP_NO_ERROR; - // Save credential information in NVM flash - err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_Credential[to_underlying(credentialType)], - reinterpret_cast(&mLockCredentials[to_underlying(credentialType)]), - sizeof(EmberAfPluginDoorLockCredentialInfo) * kMaxCredentials); - if (err != CHIP_NO_ERROR) - ChipLogError( - Zcl, "Failed to write kConfigKey_Credential. User data will be resetted during reboot. Not enough storage space \n"); + switch (credentialType) + { + case CredentialTypeEnum::kProgrammingPIN: + ChipLogError(Zcl, "CredentialTypeEnum::kProgrammingPIN must not be specified as a new credential\n"); + break; + case CredentialTypeEnum::kPin: + err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_CredentialPin[credentialIndex], + reinterpret_cast(&lockCredentials), + sizeof(EmberAfPluginDoorLockCredentialInfo)); + if (err != CHIP_NO_ERROR) + break; + + err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataPin[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize); + break; + case CredentialTypeEnum::kFace: + err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_CredentialFace[credentialIndex], + reinterpret_cast(&lockCredentials), + sizeof(EmberAfPluginDoorLockCredentialInfo)); + if (err != CHIP_NO_ERROR) + break; + + err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataFace[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize); + break; + case CredentialTypeEnum::kFingerprint: + err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_CredentialFingerprint[credentialIndex], + reinterpret_cast(&lockCredentials), + sizeof(EmberAfPluginDoorLockCredentialInfo)); + if (err != CHIP_NO_ERROR) + break; + + err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataFingerprint[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize); + break; + case CredentialTypeEnum::kFingerVein: + err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_CredentialFingervein[credentialIndex], + reinterpret_cast(&lockCredentials), + sizeof(EmberAfPluginDoorLockCredentialInfo)); + if (err != CHIP_NO_ERROR) + break; + + err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataFingerVein[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize); + break; + case CredentialTypeEnum::kRfid: + err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_CredentialRfid[credentialIndex], + reinterpret_cast(&lockCredentials), + sizeof(EmberAfPluginDoorLockCredentialInfo)); + if (err != CHIP_NO_ERROR) + break; + + err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataRfid[credentialIndex], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize); + break; + default: + break; + } - err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_CredentialData[to_underlying(credentialType)], - reinterpret_cast(&mCredentialData[to_underlying(credentialType)]), - kMaxCredentials * kMaxCredentialSize); if (err != CHIP_NO_ERROR) + { ChipLogError( Zcl, "Failed to write kConfigKey_CredentialData. User data will be resetted during reboot. Not enough storage space \n"); + return false; + } #endif ChipLogProgress(Zcl, "Successfully set the credential [credentialType=%u]", to_underlying(credentialType)); @@ -692,7 +882,6 @@ bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credential DlStatus LockManager::GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, EmberAfPluginDoorLockWeekDaySchedule & schedule) { - VerifyOrReturnValue(weekdayIndex > 0, DlStatus::kFailure); // indices are one-indexed VerifyOrReturnValue(userIndex > 0, DlStatus::kFailure); // indices are one-indexed @@ -702,7 +891,23 @@ DlStatus LockManager::GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t we VerifyOrReturnValue(IsValidWeekdayScheduleIndex(weekdayIndex), DlStatus::kFailure); VerifyOrReturnValue(IsValidUserIndex(userIndex), DlStatus::kFailure); - const auto & scheduleInStorage = mWeekdaySchedule[userIndex][weekdayIndex]; +#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE + size_t outLen; + + CHIP_ERROR err = + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_WeekDaySchedules[userIndex][weekdayIndex], + reinterpret_cast(&mWeekdaySchedule), sizeof(WeekDaysScheduleInfo), outLen); + if (err != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "GetWeekdaySchedule: No schedule found for user: %d at index %d\n", userIndex, weekdayIndex); + return DlStatus::kNotFound; + } + + const auto & scheduleInStorage = mWeekdaySchedule; +#else + const auto & scheduleInStorage = mWeekdaySchedule[userIndex][weekdayIndex]; +#endif + if (DlScheduleStatus::kAvailable == scheduleInStorage.status) { return DlStatus::kNotFound; @@ -717,7 +922,6 @@ DlStatus LockManager::SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t we DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { - VerifyOrReturnValue(weekdayIndex > 0, DlStatus::kFailure); // indices are one-indexed VerifyOrReturnValue(userIndex > 0, DlStatus::kFailure); // indices are one-indexed @@ -727,7 +931,16 @@ DlStatus LockManager::SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t we VerifyOrReturnValue(IsValidWeekdayScheduleIndex(weekdayIndex), DlStatus::kFailure); VerifyOrReturnValue(IsValidUserIndex(userIndex), DlStatus::kFailure); - auto & scheduleInStorage = mWeekdaySchedule[userIndex][weekdayIndex]; +#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE + size_t outLen; + + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_WeekDaySchedules[userIndex][weekdayIndex], + reinterpret_cast(&mWeekdaySchedule), sizeof(WeekDaysScheduleInfo), outLen); + + auto & scheduleInStorage = mWeekdaySchedule; +#else + auto & scheduleInStorage = mWeekdaySchedule[userIndex][weekdayIndex]; +#endif scheduleInStorage.schedule.daysMask = daysMask; scheduleInStorage.schedule.startHour = startHour; @@ -737,14 +950,14 @@ DlStatus LockManager::SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t we scheduleInStorage.status = status; #if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE - // Save schedule information in NVM flash - CHIP_ERROR err = ZephyrConfig::WriteConfigValueBin( - LockSettingsStorage::kConfigKey_WeekDaySchedules, reinterpret_cast(mWeekdaySchedule), - sizeof(EmberAfPluginDoorLockWeekDaySchedule) * LockParams.numberOfWeekdaySchedulesPerUser * LockParams.numberOfUsers); + CHIP_ERROR err = + ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_WeekDaySchedules[userIndex][weekdayIndex], + reinterpret_cast(&mWeekdaySchedule), sizeof(WeekDaysScheduleInfo)); if (err != CHIP_NO_ERROR) - ChipLogError( - Zcl, - "Failed to write kConfigKey_WeekDaySchedules. User data will be resetted during reboot. Not enough storage space \n"); + { + ChipLogError(Zcl, "Failed to write kConfigKey_WeekDaySchedules to NVM\n"); + return DlStatus::kFailure; + } #endif return DlStatus::kSuccess; @@ -762,7 +975,23 @@ DlStatus LockManager::GetYeardaySchedule(chip::EndpointId endpointId, uint8_t ye VerifyOrReturnValue(IsValidYeardayScheduleIndex(yearDayIndex), DlStatus::kFailure); VerifyOrReturnValue(IsValidUserIndex(userIndex), DlStatus::kFailure); - const auto & scheduleInStorage = mYeardaySchedule[userIndex][yearDayIndex]; +#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE + size_t outLen; + + CHIP_ERROR err = + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_YearDaySchedules[userIndex][yearDayIndex], + reinterpret_cast(&mYeardaySchedule), sizeof(YearDayScheduleInfo), outLen); + if (err != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "GetYeardaySchedule: No schedule found for user: %d at index %d\n", userIndex, yearDayIndex); + return DlStatus::kNotFound; + } + + const auto & scheduleInStorage = mYeardaySchedule; +#else + const auto & scheduleInStorage = mYeardaySchedule[userIndex][yearDayIndex]; +#endif + if (DlScheduleStatus::kAvailable == scheduleInStorage.status) { return DlStatus::kNotFound; @@ -785,21 +1014,29 @@ DlStatus LockManager::SetYeardaySchedule(chip::EndpointId endpointId, uint8_t ye VerifyOrReturnValue(IsValidYeardayScheduleIndex(yearDayIndex), DlStatus::kFailure); VerifyOrReturnValue(IsValidUserIndex(userIndex), DlStatus::kFailure); - auto & scheduleInStorage = mYeardaySchedule[userIndex][yearDayIndex]; +#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE + size_t outLen; + + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_YearDaySchedules[userIndex][yearDayIndex], + reinterpret_cast(&mYeardaySchedule), sizeof(YearDayScheduleInfo), outLen); + + auto & scheduleInStorage = mYeardaySchedule; +#else + auto & scheduleInStorage = mYeardaySchedule[userIndex][yearDayIndex]; +#endif scheduleInStorage.schedule.localStartTime = localStartTime; scheduleInStorage.schedule.localEndTime = localEndTime; scheduleInStorage.status = status; #if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE - // Save schedule information in NVM flash - CHIP_ERROR err = ZephyrConfig::WriteConfigValueBin( - LockSettingsStorage::kConfigKey_YearDaySchedules, reinterpret_cast(mYeardaySchedule), - sizeof(EmberAfPluginDoorLockYearDaySchedule) * LockParams.numberOfYeardaySchedulesPerUser * LockParams.numberOfUsers); + CHIP_ERROR err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_YearDaySchedules[userIndex][yearDayIndex], + reinterpret_cast(&mYeardaySchedule), sizeof(YearDayScheduleInfo)); if (err != CHIP_NO_ERROR) - ChipLogError( - Zcl, - "Failed to write kConfigKey_YearDaySchedules. User data will be resetted during reboot. Not enough storage space \n"); + { + ChipLogError(Zcl, "Failed to write kConfigKey_YearDaySchedules to NVM\n"); + return DlStatus::kFailure; + } #endif return DlStatus::kSuccess; @@ -814,7 +1051,23 @@ DlStatus LockManager::GetHolidaySchedule(chip::EndpointId endpointId, uint8_t ho VerifyOrReturnValue(IsValidHolidayScheduleIndex(holidayIndex), DlStatus::kFailure); - const auto & scheduleInStorage = mHolidaySchedule[holidayIndex]; +#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE + size_t outLen; + + CHIP_ERROR err = + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_HolidaySchedules[holidayIndex], + reinterpret_cast(&mHolidaySchedule), sizeof(HolidayScheduleInfo), outLen); + if (err != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "GetHolidaySchedule: No schedule found at index %d\n", holidayIndex); + return DlStatus::kNotFound; + } + + const auto & scheduleInStorage = mHolidaySchedule; +#else + const auto & scheduleInStorage = mHolidaySchedule[holidayIndex]; +#endif + if (DlScheduleStatus::kAvailable == scheduleInStorage.status) { return DlStatus::kNotFound; @@ -834,7 +1087,16 @@ DlStatus LockManager::SetHolidaySchedule(chip::EndpointId endpointId, uint8_t ho VerifyOrReturnValue(IsValidHolidayScheduleIndex(holidayIndex), DlStatus::kFailure); - auto & scheduleInStorage = mHolidaySchedule[holidayIndex]; +#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE + size_t outLen; + + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_HolidaySchedules[holidayIndex], + reinterpret_cast(&mHolidaySchedule), sizeof(HolidayScheduleInfo), outLen); + + auto & scheduleInStorage = mHolidaySchedule; +#else + auto & scheduleInStorage = mHolidaySchedule[holidayIndex]; +#endif scheduleInStorage.schedule.localStartTime = localStartTime; scheduleInStorage.schedule.localEndTime = localEndTime; @@ -842,14 +1104,13 @@ DlStatus LockManager::SetHolidaySchedule(chip::EndpointId endpointId, uint8_t ho scheduleInStorage.status = status; #if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE - // Save schedule information in NVM flash - CHIP_ERROR err = ZephyrConfig::WriteConfigValueBin( - LockSettingsStorage::kConfigKey_HolidaySchedules, reinterpret_cast(&(mHolidaySchedule)), - sizeof(EmberAfPluginDoorLockHolidaySchedule) * LockParams.numberOfHolidaySchedules); + CHIP_ERROR err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_HolidaySchedules[holidayIndex], + reinterpret_cast(&mHolidaySchedule), sizeof(HolidayScheduleInfo)); if (err != CHIP_NO_ERROR) - ChipLogError( - Zcl, - "Failed to write kConfigKey_YearDaySchedules. User data will be resetted during reboot. Not enough storage space \n"); + { + ChipLogError(Zcl, "Failed to write kConfigKey_HolidaySchedules to NVM\n"); + return DlStatus::kFailure; + } #endif return DlStatus::kSuccess; @@ -904,9 +1165,27 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat err = OperationErrorEnum::kRestricted; return false; } - // Check the PIN code + +#if LOCK_MANAGER_CONFIG_USE_NVM_CREDENTIAL_STORAGE + size_t outLen; + EmberAfPluginDoorLockCredentialInfo lockCredentials; + uint8_t lockCredentialsData[kMaxCredentialSize]; + + for (uint8_t credentialDataIdx = 0; credentialDataIdx < APP_MAX_CREDENTIAL; credentialDataIdx++) + { + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialPin[credentialDataIdx], + reinterpret_cast(&lockCredentials), sizeof(EmberAfPluginDoorLockCredentialInfo), + outLen); + ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialDataPin[credentialDataIdx], + reinterpret_cast(lockCredentialsData), kMaxCredentialSize, outLen); + + auto & currentCredential = lockCredentials; + auto & credentialDataInStorage = lockCredentialsData; + currentCredential.credentialData = chip::ByteSpan{ credentialDataInStorage, currentCredential.credentialData.size() }; +#else for (const auto & currentCredential : mLockCredentials[to_underlying(CredentialTypeEnum::kPin)]) { +#endif if (currentCredential.status == DlCredentialStatus::kAvailable) { continue; @@ -915,7 +1194,7 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat if (currentCredential.credentialData.data_equal(pin.Value())) { - for (uint16_t i = 1; i <= kMaxUsers; ++i) + for (uint16_t i = 1; i <= APP_MAX_USERS; ++i) { EmberAfPluginDoorLockUserInfo user; if (!emberAfPluginDoorLockGetUser(endpointId, i, user)) diff --git a/examples/lock-app/telink/src/LockSettingsStorage.cpp b/examples/lock-app/telink/src/LockSettingsStorage.cpp index 73b88e2c593dea..bb128de87ec04a 100644 --- a/examples/lock-app/telink/src/LockSettingsStorage.cpp +++ b/examples/lock-app/telink/src/LockSettingsStorage.cpp @@ -38,20 +38,65 @@ namespace Internal { #define NAMESPACE_CONFIG CHIP_DEVICE_CONFIG_SETTINGS_KEY "/cfg/" -const ZephyrConfig::Key LockSettingsStorage::kConfigKey_LockUser = CONFIG_KEY(NAMESPACE_CONFIG "lock-user"); -const ZephyrConfig::Key LockSettingsStorage::kConfigKey_LockUserName = CONFIG_KEY(NAMESPACE_CONFIG "lock-user-name"); -const ZephyrConfig::Key LockSettingsStorage::kConfigKey_UserCredentials = CONFIG_KEY(NAMESPACE_CONFIG "user-credentials"); -const ZephyrConfig::Key LockSettingsStorage::kConfigKey_WeekDaySchedules = CONFIG_KEY(NAMESPACE_CONFIG "week-day-schedules"); -const ZephyrConfig::Key LockSettingsStorage::kConfigKey_YearDaySchedules = CONFIG_KEY(NAMESPACE_CONFIG "year-day-schedules"); -const ZephyrConfig::Key LockSettingsStorage::kConfigKey_HolidaySchedules = CONFIG_KEY(NAMESPACE_CONFIG "holiday-schedules"); -const char * LockSettingsStorage::kConfigKey_Credential[kNumCredentialTypes] = { - CONFIG_KEY_CREDENTIAL("programming-pin"), CONFIG_KEY_CREDENTIAL("pin"), CONFIG_KEY_CREDENTIAL("rfid"), - CONFIG_KEY_CREDENTIAL("finger-print"), CONFIG_KEY_CREDENTIAL("finger-vein"), CONFIG_KEY_CREDENTIAL("face") -}; -const char * LockSettingsStorage::kConfigKey_CredentialData[kNumCredentialTypes] = { - CONFIG_KEY_CREDENTIAL_DATA("programming-pin"), CONFIG_KEY_CREDENTIAL_DATA("pin"), CONFIG_KEY_CREDENTIAL_DATA("rfid"), - CONFIG_KEY_CREDENTIAL_DATA("finger-print"), CONFIG_KEY_CREDENTIAL_DATA("finger-vein"), CONFIG_KEY_CREDENTIAL_DATA("face") -}; +#define CONFIG_KEY_USER(index, _) (NAMESPACE_CONFIG "lock-user-" #index) +#define CONFIG_KEY_USER_NAMES(index, _) (NAMESPACE_CONFIG "lock-user-name-" #index) +#define CONFIG_KEY_USER_CREDENTIALS(index, _) (NAMESPACE_CONFIG "user-credentials-" #index) +#define CONFIG_KEY_WEEK_DAY_SCH(index, _) (NAMESPACE_CONFIG "week-day-schedules-" #index) +#define CONFIG_KEY_YEAR_DAY_SCH(index, _) (NAMESPACE_CONFIG "year-day-schedules-" #index) +#define CONFIG_KEY_HOLYDAY_SCH(index, _) (NAMESPACE_CONFIG "holiday-schedules-" #index) + +#define CONFIG_KEY_CREDENTIALS_PIN(index, _) (NAMESPACE_CONFIG "credentials-pin" #index) +#define CONFIG_KEY_CREDENTIALS_FACE(index, _) (NAMESPACE_CONFIG "credentials-face" #index) +#define CONFIG_KEY_CREDENTIALS_FINGERPTRINT(index, _) (NAMESPACE_CONFIG "credentials-fp" #index) +#define CONFIG_KEY_CREDENTIALS_FINGERVEIN(index, _) (NAMESPACE_CONFIG "credentials-fv" #index) +#define CONFIG_KEY_CREDENTIALS_RFID(index, _) (NAMESPACE_CONFIG "credentials-rfid" #index) + +#define CONFIG_KEY_USER_CREDENTIALS_DATA_PIN(index, _) (NAMESPACE_CONFIG "credentials-datapin-" #index) +#define CONFIG_KEY_USER_CREDENTIALS_DATA_FACE(index, _) (NAMESPACE_CONFIG "credentials-dataface-" #index) +#define CONFIG_KEY_USER_CREDENTIALS_DATA_FINGERPTRINT(index, _) (NAMESPACE_CONFIG "credentials-datafp-" #index) +#define CONFIG_KEY_USER_CREDENTIALS_DATA_FINGERVEIN(index, _) (NAMESPACE_CONFIG "credentials-datafv-" #index) +#define CONFIG_KEY_USER_CREDENTIALS_DATA_RFID(index, _) (NAMESPACE_CONFIG "credentials-datarfid-" #index) + +const char * LockSettingsStorage::kConfigKey_LockUser[APP_MAX_USERS] = { LISTIFY(APP_MAX_USERS, CONFIG_KEY_USER, (, )) }; +const char * LockSettingsStorage::kConfigKey_LockUserName[APP_MAX_USERS] = { LISTIFY(APP_MAX_USERS, CONFIG_KEY_USER_NAMES, (, )) }; +const char * LockSettingsStorage::kConfigKey_UserCredentials[APP_MAX_CREDENTIAL] = { LISTIFY(APP_MAX_CREDENTIAL, + CONFIG_KEY_USER_CREDENTIALS, (, )) }; +const char * LockSettingsStorage::kConfigKey_WeekDaySchedules[APP_MAX_USERS][APP_MAX_WEEKDAY_SCHEDULE_PER_USER] = { LISTIFY( + APP_MAX_SCHEDULES_TOTAL, CONFIG_KEY_WEEK_DAY_SCH, (, )) }; +const char * LockSettingsStorage::kConfigKey_YearDaySchedules[APP_MAX_USERS][APP_MAX_YEARDAY_SCHEDULE_PER_USER] = { LISTIFY( + APP_MAX_SCHEDULES_TOTAL, CONFIG_KEY_YEAR_DAY_SCH, (, )) }; +const char * LockSettingsStorage::kConfigKey_HolidaySchedules[APP_MAX_HOLYDAY_SCHEDULE_PER_USER] = { LISTIFY( + APP_MAX_HOLYDAY_SCHEDULE_PER_USER, CONFIG_KEY_HOLYDAY_SCH, (, )) }; + +const char * LockSettingsStorage::kConfigKey_CredentialPin[APP_MAX_CREDENTIAL] = { LISTIFY(APP_MAX_CREDENTIAL, + CONFIG_KEY_CREDENTIALS_PIN, (, )) }; + +const char * LockSettingsStorage::kConfigKey_CredentialFace[APP_MAX_CREDENTIAL] = { LISTIFY(APP_MAX_CREDENTIAL, + CONFIG_KEY_CREDENTIALS_FACE, (, )) }; + +const char * LockSettingsStorage::kConfigKey_CredentialFingerprint[APP_MAX_CREDENTIAL] = { LISTIFY( + APP_MAX_CREDENTIAL, CONFIG_KEY_CREDENTIALS_FINGERPTRINT, (, )) }; + +const char * LockSettingsStorage::kConfigKey_CredentialFingervein[APP_MAX_CREDENTIAL] = { LISTIFY( + APP_MAX_CREDENTIAL, CONFIG_KEY_CREDENTIALS_FINGERVEIN, (, )) }; + +const char * LockSettingsStorage::kConfigKey_CredentialRfid[APP_MAX_CREDENTIAL] = { LISTIFY(APP_MAX_CREDENTIAL, + CONFIG_KEY_CREDENTIALS_RFID, (, )) }; + +const char * LockSettingsStorage::kConfigKey_CredentialDataPin[APP_MAX_CREDENTIAL] = { LISTIFY( + APP_MAX_CREDENTIAL, CONFIG_KEY_USER_CREDENTIALS_DATA_PIN, (, )) }; + +const char * LockSettingsStorage::kConfigKey_CredentialDataFace[APP_MAX_CREDENTIAL] = { LISTIFY( + APP_MAX_CREDENTIAL, CONFIG_KEY_USER_CREDENTIALS_DATA_FACE, (, )) }; + +const char * LockSettingsStorage::kConfigKey_CredentialDataFingerprint[APP_MAX_CREDENTIAL] = { LISTIFY( + APP_MAX_CREDENTIAL, CONFIG_KEY_USER_CREDENTIALS_DATA_FINGERPTRINT, (, )) }; + +const char * LockSettingsStorage::kConfigKey_CredentialDataFingerVein[APP_MAX_CREDENTIAL] = { LISTIFY( + APP_MAX_CREDENTIAL, CONFIG_KEY_USER_CREDENTIALS_DATA_FINGERVEIN, (, )) }; + +const char * LockSettingsStorage::kConfigKey_CredentialDataRfid[APP_MAX_CREDENTIAL] = { LISTIFY( + APP_MAX_CREDENTIAL, CONFIG_KEY_USER_CREDENTIALS_DATA_RFID, (, )) }; } // namespace Internal } // namespace DeviceLayer diff --git a/examples/microwave-oven-app/microwave-oven-common/microwave-oven-app.matter b/examples/microwave-oven-app/microwave-oven-common/microwave-oven-app.matter index eada9b169c8f8b..133ee495cdd5dc 100644 --- a/examples/microwave-oven-app/microwave-oven-common/microwave-oven-app.matter +++ b/examples/microwave-oven-app/microwave-oven-common/microwave-oven-app.matter @@ -602,6 +602,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -658,10 +662,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Wi-Fi Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1276,8 +1292,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/network-manager-app/network-manager-common/network-manager-app.matter b/examples/network-manager-app/network-manager-common/network-manager-app.matter index fdc906d0ad60b9..15a4efb50354f0 100644 --- a/examples/network-manager-app/network-manager-common/network-manager-app.matter +++ b/examples/network-manager-app/network-manager-common/network-manager-app.matter @@ -558,6 +558,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -614,10 +618,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Thread Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems */ @@ -1284,8 +1300,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter b/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter index 9f8d7049b5b172..7daeffee2e26ac 100644 --- a/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter +++ b/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter @@ -720,6 +720,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -776,10 +780,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** Commands to trigger a Node to allow a new Administrator to commission it. */ @@ -1209,8 +1225,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter b/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter index aa72684ff1f68a..da7faa284f9927 100644 --- a/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter +++ b/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter @@ -922,6 +922,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -978,10 +982,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** Commands to trigger a Node to allow a new Administrator to commission it. */ @@ -1411,8 +1427,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/placeholder/linux/apps/app1/config.matter b/examples/placeholder/linux/apps/app1/config.matter index 935a665fcde9f5..9474cd665e4e85 100644 --- a/examples/placeholder/linux/apps/app1/config.matter +++ b/examples/placeholder/linux/apps/app1/config.matter @@ -1714,6 +1714,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1770,10 +1774,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -8364,8 +8380,8 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/placeholder/linux/apps/app2/config.matter b/examples/placeholder/linux/apps/app2/config.matter index 83657fd83849d5..49415316b27e65 100644 --- a/examples/placeholder/linux/apps/app2/config.matter +++ b/examples/placeholder/linux/apps/app2/config.matter @@ -1671,6 +1671,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1727,10 +1731,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -8322,8 +8338,8 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/placeholder/templates/tests-commands.zapt b/examples/placeholder/templates/tests-commands.zapt index c1d87417bc5906..be0474f4632605 100644 --- a/examples/placeholder/templates/tests-commands.zapt +++ b/examples/placeholder/templates/tests-commands.zapt @@ -4,7 +4,7 @@ #include "TestCommand.h" -#include +#include {{>test_cluster tests="../linux/apps/app1/ciTests.json" credsIssuerConfigArg=false needsWaitDuration=false}} diff --git a/examples/platform/linux/AppMain.cpp b/examples/platform/linux/AppMain.cpp index 061d7b66c5e4c6..71701f74aaedd6 100644 --- a/examples/platform/linux/AppMain.cpp +++ b/examples/platform/linux/AppMain.cpp @@ -19,7 +19,8 @@ #include #include -#include "app/clusters/network-commissioning/network-commissioning.h" +#include +#include #include #include #include diff --git a/examples/platform/linux/ControllerShellCommands.cpp b/examples/platform/linux/ControllerShellCommands.cpp index 27116b28c15256..49b1e20dc97eb8 100644 --- a/examples/platform/linux/ControllerShellCommands.cpp +++ b/examples/platform/linux/ControllerShellCommands.cpp @@ -37,7 +37,6 @@ namespace chip { namespace Shell { using namespace chip; -using namespace ::chip::Controller; #if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY static CHIP_ERROR ResetUDC(bool printHeader) diff --git a/examples/platform/silabs/BaseApplication.cpp b/examples/platform/silabs/BaseApplication.cpp index 5870de2aeb947d..d2c6266a58382b 100644 --- a/examples/platform/silabs/BaseApplication.cpp +++ b/examples/platform/silabs/BaseApplication.cpp @@ -453,7 +453,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) { // The factory reset sequence was not initiated, // Press and Release: - // - Open the commissioning window and start BLE advertissement in fast mode when not commissioned + // - Open the commissioning window and start BLE advertisement in fast mode when not commissioned // - Output qr code in logs // - Cycle LCD screen CancelFunctionTimer(); @@ -477,7 +477,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) } else { - SILABS_LOG("Network is already provisioned, Ble advertissement not enabled"); + SILABS_LOG("Network is already provisioned, Ble advertisement not enabled"); #if CHIP_CONFIG_ENABLE_ICD_SERVER // Temporarily claim network activity, until we implement a "user trigger" reason for ICD wakeups. PlatformMgr().LockChipStack(); diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index 3a78cf774c8c5a..e9fed8d924c3e0 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -113,7 +113,11 @@ CHIP_ERROR SilabsMatterConfig::InitOpenThread(void) ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router)); #else // CHIP_DEVICE_CONFIG_THREAD_FTD #if CHIP_CONFIG_ENABLE_ICD_SERVER +#if CHIP_DEVICE_CONFIG_THREAD_SSED + ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SynchronizedSleepyEndDevice)); +#else ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice)); +#endif #else // CHIP_CONFIG_ENABLE_ICD_SERVER ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice)); #endif // CHIP_CONFIG_ENABLE_ICD_SERVER diff --git a/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h b/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h index e906e48ab02684..d7492f4044f3fa 100644 --- a/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h +++ b/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h @@ -45,35 +45,39 @@ // Timeout after 2 missed checkin or 4 mins if sleep interval is too short. #define OPENTHREAD_CONFIG_MLE_CHILD_TIMEOUT_DEFAULT ((SL_MLE_TIMEOUT_s < 120) ? 240 : ((SL_MLE_TIMEOUT_s * 2) + 1)) +#if defined(SL_CSL_ENABLE) && SL_CSL_ENABLE + +#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 1 +#define OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE 1 +#define OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE 1 +#define OPENTHREAD_CONFIG_CHILD_SUPERVISION_CHECK_TIMEOUT 0 +#define OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD 750 +#define OPENTHREAD_CONFIG_CSL_TIMEOUT SL_CSL_TIMEOUT +#define SL_OPENTHREAD_CSL_TX_UNCERTAINTY 200 + +#endif // SL_CSL_ENABLE + #endif // SL_ICD_ENABLED /****Uncomment below section for OpenThread Debug logs*/ // #define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG // #ifndef OPENTHREAD_CONFIG_LOG_CLI -// #define OPENTHREAD_CONFIG_LOG_CLI 1 +// #define OPENTHREAD_CONFIG_LOG_CLI 1 // #endif // #ifndef OPENTHREAD_CONFIG_LOG_PKT_DUMP -// #define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1 +// #define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1 // #endif // #ifndef OPENTHREAD_CONFIG_LOG_PLATFORM -// #define OPENTHREAD_CONFIG_LOG_PLATFORM 1 +// #define OPENTHREAD_CONFIG_LOG_PLATFORM 1 // #endif // #ifndef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL -// #define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 1 +// #define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 1 // #endif -// EFR32MG21A020F1024IM32 has 96k of RAM. Reduce the number of buffers to -// conserve RAM for this Series 2 part. -#if defined(EFR32MG21) -#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 22 -#define OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE 512 -#define OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE 512 -#endif - #define OPENTHREAD_CONFIG_NCP_HDLC_ENABLE 1 #define OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE 1 diff --git a/examples/pump-app/pump-common/pump-app.matter b/examples/pump-app/pump-common/pump-app.matter index b944766326f35d..a639858bb8cf22 100644 --- a/examples/pump-app/pump-common/pump-app.matter +++ b/examples/pump-app/pump-common/pump-app.matter @@ -930,6 +930,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -986,10 +990,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Thread Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems */ @@ -1767,8 +1783,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/pump-app/silabs/data_model/pump-thread-app.matter b/examples/pump-app/silabs/data_model/pump-thread-app.matter index 43dcac8a086ab7..a819a67ca5941a 100644 --- a/examples/pump-app/silabs/data_model/pump-thread-app.matter +++ b/examples/pump-app/silabs/data_model/pump-thread-app.matter @@ -930,6 +930,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -986,10 +990,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Thread Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems */ @@ -1767,8 +1783,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/pump-app/silabs/data_model/pump-wifi-app.matter b/examples/pump-app/silabs/data_model/pump-wifi-app.matter index 43dcac8a086ab7..a819a67ca5941a 100644 --- a/examples/pump-app/silabs/data_model/pump-wifi-app.matter +++ b/examples/pump-app/silabs/data_model/pump-wifi-app.matter @@ -930,6 +930,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -986,10 +990,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Thread Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems */ @@ -1767,8 +1783,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter b/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter index 6995c3193c4322..ba19fac882b230 100644 --- a/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter +++ b/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter @@ -805,6 +805,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -861,10 +865,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Thread Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems */ @@ -1601,8 +1617,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/refrigerator-app/refrigerator-common/refrigerator-app.matter b/examples/refrigerator-app/refrigerator-common/refrigerator-app.matter index d8f04c28aaece7..296b4b630f6631 100644 --- a/examples/refrigerator-app/refrigerator-common/refrigerator-app.matter +++ b/examples/refrigerator-app/refrigerator-common/refrigerator-app.matter @@ -595,6 +595,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -651,10 +655,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Wi-Fi Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1175,8 +1191,8 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/rvc-app/rvc-common/rvc-app.matter b/examples/rvc-app/rvc-common/rvc-app.matter index 4a44e74f963301..2de29e1783296b 100644 --- a/examples/rvc-app/rvc-common/rvc-app.matter +++ b/examples/rvc-app/rvc-common/rvc-app.matter @@ -605,6 +605,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -661,10 +665,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** Commands to trigger a Node to allow a new Administrator to commission it. */ @@ -1212,8 +1228,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.matter b/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.matter index 7ca0706457f11b..6c1938c578ea27 100644 --- a/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.matter +++ b/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.matter @@ -1156,6 +1156,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1212,10 +1216,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2043,8 +2059,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; @@ -2140,7 +2156,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; handle command OpenCommissioningWindow; - handle command OpenBasicCommissioningWindow; handle command RevokeCommissioning; } diff --git a/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.zap b/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.zap index 4cfe5ceb8ceca5..11413ba936714d 100644 --- a/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.zap +++ b/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.zap @@ -2902,14 +2902,6 @@ "isIncoming": 1, "isEnabled": 1 }, - { - "name": "OpenBasicCommissioningWindow", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, { "name": "RevokeCommissioning", "code": 2, diff --git a/examples/temperature-measurement-app/esp32/README.md b/examples/temperature-measurement-app/esp32/README.md index 567e302c6f8df8..18d07ff639b06a 100644 --- a/examples/temperature-measurement-app/esp32/README.md +++ b/examples/temperature-measurement-app/esp32/README.md @@ -24,6 +24,36 @@ Usage: ./out/debug/chip-tool temperaturemeasurement read measured-value 1 ``` +## Additional details + +This example demonstrates the utilization of the diagnostic logs cluster to send +diagnostic logs to the client. + +In this scenario, the [main/diagnostic_logs](main/diagnostic_logs) directory +contains three files: + +``` +main/diagnostic_logs +├── crash.log +├── end_user_support.log +└── network_diag.log +``` + +These files contain dummy data. + +#### To test the diagnostic logs cluster + +``` +# Commission the app +chip-tool pairing ble-wifi 1 SSID PASSPHRASE 20202021 3840 + +# Read end user support logs using response payload protocol +chip-tool diagnosticlogs retrieve-logs-request 0 0 1 0 + +# Read network diagnostic using BDX protocol +chip-tool diagnosticlogs retrieve-logs-request 1 0 1 0 --TransferFileDesignator network-diag.log +``` + ## Optimization Optimization related to WiFi, BLuetooth, Asserts etc are the part of this diff --git a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt index b48d05d8949b88..8953d34869b76a 100644 --- a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt +++ b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt @@ -82,7 +82,8 @@ endif (CONFIG_ENABLE_PW_RPC) idf_component_register(PRIV_INCLUDE_DIRS ${PRIV_INCLUDE_DIRS_LIST} SRC_DIRS ${SRC_DIRS_LIST} - PRIV_REQUIRES ${PRIV_REQUIRES_LIST}) + PRIV_REQUIRES ${PRIV_REQUIRES_LIST} + EMBED_FILES diagnostic_logs/end_user_support.log diagnostic_logs/network_diag.log diagnostic_logs/crash.log) include("${CHIP_ROOT}/build/chip/esp32/esp32_codegen.cmake") chip_app_component_codegen("${CHIP_ROOT}/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.matter") diff --git a/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp new file mode 100644 index 00000000000000..4bef0fbd86cc19 --- /dev/null +++ b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp @@ -0,0 +1,161 @@ +/* + * + * Copyright (c) 2024 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 + +using namespace chip; +using namespace chip::app::Clusters::DiagnosticLogs; + +LogProvider LogProvider::sInstance; + +namespace { +bool IsValidIntent(IntentEnum intent) +{ + return intent != IntentEnum::kUnknownEnumValue; +} + +// end_user_support.log, network_diag.log, and crash.log files are embedded in the firmware +extern const uint8_t endUserSupportLogStart[] asm("_binary_end_user_support_log_start"); +extern const uint8_t endUserSupportLogEnd[] asm("_binary_end_user_support_log_end"); + +extern const uint8_t networkDiagnosticLogStart[] asm("_binary_network_diag_log_start"); +extern const uint8_t networkDiagnosticLogEnd[] asm("_binary_network_diag_log_end"); + +extern const uint8_t crashLogStart[] asm("_binary_crash_log_start"); +extern const uint8_t crashLogEnd[] asm("_binary_crash_log_end"); +} // namespace + +LogProvider::~LogProvider() +{ + for (auto sessionSpan : mSessionSpanMap) + { + Platform::MemoryFree(sessionSpan.second); + } + mSessionSpanMap.clear(); +} + +CHIP_ERROR LogProvider::GetLogForIntent(IntentEnum intent, MutableByteSpan & outBuffer, Optional & outTimeStamp, + Optional & outTimeSinceBoot) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + LogSessionHandle sessionHandle = kInvalidLogSessionHandle; + + err = StartLogCollection(intent, sessionHandle, outTimeStamp, outTimeSinceBoot); + VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); + + bool unusedOutIsEndOfLog; + err = CollectLog(sessionHandle, outBuffer, unusedOutIsEndOfLog); + VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); + + err = EndLogCollection(sessionHandle); + VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); + + return CHIP_NO_ERROR; +} + +const uint8_t * LogProvider::GetDataStartForIntent(IntentEnum intent) +{ + switch (intent) + { + case IntentEnum::kEndUserSupport: + return &endUserSupportLogStart[0]; + case IntentEnum::kNetworkDiag: + return &networkDiagnosticLogStart[0]; + case IntentEnum::kCrashLogs: + return &crashLogStart[0]; + default: + return nullptr; + } +} + +size_t LogProvider::GetSizeForIntent(IntentEnum intent) +{ + switch (intent) + { + case IntentEnum::kEndUserSupport: + return static_cast(endUserSupportLogEnd - endUserSupportLogStart); + case IntentEnum::kNetworkDiag: + return static_cast(networkDiagnosticLogEnd - networkDiagnosticLogStart); + case IntentEnum::kCrashLogs: + return static_cast(crashLogEnd - crashLogStart); + default: + return 0; + } +} + +CHIP_ERROR LogProvider::StartLogCollection(IntentEnum intent, LogSessionHandle & outHandle, Optional & outTimeStamp, + Optional & outTimeSinceBoot) +{ + VerifyOrReturnValue(IsValidIntent(intent), CHIP_ERROR_INVALID_ARGUMENT); + + const uint8_t * dataStart = GetDataStartForIntent(intent); + VerifyOrReturnError(dataStart, CHIP_ERROR_NOT_FOUND); + + size_t dataSize = GetSizeForIntent(intent); + VerifyOrReturnError(dataSize, CHIP_ERROR_NOT_FOUND); + + ByteSpan * span = reinterpret_cast(Platform::MemoryCalloc(1, sizeof(ByteSpan))); + VerifyOrReturnValue(span, CHIP_ERROR_NO_MEMORY); + + *span = ByteSpan(dataStart, dataSize); + + mLogSessionHandle++; + // If the session handle rolls over to UINT16_MAX which is invalid, reset to 0. + VerifyOrDo(mLogSessionHandle != kInvalidLogSessionHandle, mLogSessionHandle = 0); + + outHandle = mLogSessionHandle; + mSessionSpanMap[mLogSessionHandle] = span; + return CHIP_NO_ERROR; +} + +CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle) +{ + VerifyOrReturnValue(sessionHandle != kInvalidLogSessionHandle, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnValue(mSessionSpanMap.count(sessionHandle), CHIP_ERROR_INVALID_ARGUMENT); + + ByteSpan * span = mSessionSpanMap[sessionHandle]; + mSessionSpanMap.erase(sessionHandle); + + Platform::MemoryFree(span); + return CHIP_NO_ERROR; +} + +CHIP_ERROR LogProvider::CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) +{ + VerifyOrReturnValue(sessionHandle != kInvalidLogSessionHandle, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnValue(mSessionSpanMap.count(sessionHandle), CHIP_ERROR_INVALID_ARGUMENT); + + ByteSpan * span = mSessionSpanMap[sessionHandle]; + auto dataSize = span->size(); + auto count = std::min(dataSize, outBuffer.size()); + + VerifyOrReturnError(CanCastTo(count), CHIP_ERROR_INVALID_ARGUMENT, outBuffer.reduce_size(0)); + + ReturnErrorOnFailure(CopySpanToMutableSpan(ByteSpan(span->data(), count), outBuffer)); + + outIsEndOfLog = dataSize == count; + + if (!outIsEndOfLog) + { + // reduce the span after reading count bytes + *span = span->SubSpan(count); + } + + return CHIP_NO_ERROR; +} diff --git a/examples/temperature-measurement-app/esp32/main/diagnostic_logs/crash.log b/examples/temperature-measurement-app/esp32/main/diagnostic_logs/crash.log new file mode 100644 index 00000000000000..04089de8ce7afd --- /dev/null +++ b/examples/temperature-measurement-app/esp32/main/diagnostic_logs/crash.log @@ -0,0 +1,21 @@ +W (5047Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled. + +Core 0 register dump: +PC : 0x4009579a PS : 0x00060c33 A0 : 0x800941e1 A1 : 0x3fff3630 +0x4009579a: uxListRemove at /opt/espressif/esp-idf/components/freertos/FreeRTOS-Kernel/list.c:195 + +A2 : 0x00000006 A3 : 0x00060c20 A4 : 0x00000000 A5 : 0x00060c23 +A6 : 0xb33fffff A7 : 0xb33fffff A8 : 0x800950f0 A9 : 0x3fff3600 +A10 : 0x00000001 A11 : 0x000000fe A12 : 0x00000000 A13 : 0x00000000 +A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000000a EXCCAUSE: 0x0000001c +EXCVADDR: 0x00000016 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff +0x4000c2e0: memcpy in ROM +0x4000c2f6: memcpy in ROM + +Backtrace: 0x40095797:0x3fff3630 0x400941de:0x3fff3650 0x40154b39:0x3fff3670 0x40154b53:0x3fff3690 0x4013e20d:0x3fff36b0 0x40094fa6:0x3fff36d0 +0x40095797: uxListRemove at /opt/espressif/esp-idf/components/freertos/FreeRTOS-Kernel/list.c:202 +0x400941de: vTaskDelete at /opt/espressif/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:1434 (discriminator 4) +0x40154b39: esp_nimble_disable at /opt/espressif/esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/src/nimble_port_freertos.c:55 +0x40154b53: nimble_port_freertos_deinit at /opt/espressif/esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/src/nimble_port_freertos.c:80 +0x4013e20d: chip::DeviceLayer::Internal::BLEManagerImpl::bleprph_host_task(void*) at /home/smart/projects/smp_matter/build/esp-idf/chip/../../../../../../../opt/espressif/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/platform/ESP32/nimble/BLEManagerImpl.cpp:864 +0x40094fa6: vPortTaskWrapper at /opt/espressif/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162 diff --git a/examples/temperature-measurement-app/esp32/main/diagnostic_logs/end_user_support.log b/examples/temperature-measurement-app/esp32/main/diagnostic_logs/end_user_support.log new file mode 100644 index 00000000000000..2844b97dab5988 --- /dev/null +++ b/examples/temperature-measurement-app/esp32/main/diagnostic_logs/end_user_support.log @@ -0,0 +1,3 @@ +I (223374) chip[light]: Turning on the smart light. +I (233374) chip[light]: Setting smart light level to 78 %. +I (243374) chip[light]: Turning off the smart light. diff --git a/examples/temperature-measurement-app/esp32/main/diagnostic_logs/network_diag.log b/examples/temperature-measurement-app/esp32/main/diagnostic_logs/network_diag.log new file mode 100644 index 00000000000000..2b945b9cf4f48d --- /dev/null +++ b/examples/temperature-measurement-app/esp32/main/diagnostic_logs/network_diag.log @@ -0,0 +1,4 @@ +I (223374) chip[ndiag]: Wi-Fi connection status: 1 +I (233374) chip[ndiag]: Wi-Fi RSSI: -67 dBm +I (243374) chip[ndiag]: Minimum ever Wi-Fi RSSI: -80 dBm +I (253374) chip[ndiag]: Wi-Fi disconnection count: 16 diff --git a/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h b/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h new file mode 100644 index 00000000000000..d47dccafa6079d --- /dev/null +++ b/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h @@ -0,0 +1,68 @@ +/* + * + * Copyright (c) 2024 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 + +namespace chip { +namespace app { +namespace Clusters { +namespace DiagnosticLogs { + +/** + * The LogProvider class serves as the sole instance delegate for handling diagnostic logs. + * + * It implements the DiagnosticLogsProviderDelegate interface + */ + +class LogProvider : public DiagnosticLogsProviderDelegate +{ +public: + static inline LogProvider & GetInstance() { return sInstance; } + + /////////// DiagnosticLogsProviderDelegate Interface ///////// + CHIP_ERROR StartLogCollection(IntentEnum intent, LogSessionHandle & outHandle, Optional & outTimeStamp, + Optional & outTimeSinceBoot) override; + CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle) override; + CHIP_ERROR CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) override; + size_t GetSizeForIntent(IntentEnum intent) override; + CHIP_ERROR GetLogForIntent(IntentEnum intent, MutableByteSpan & outBuffer, Optional & outTimeStamp, + Optional & outTimeSinceBoot) override; + +private: + static LogProvider sInstance; + LogProvider() = default; + ~LogProvider(); + + LogProvider(const LogProvider &) = delete; + LogProvider & operator=(const LogProvider &) = delete; + + // This tracks the ByteSpan for each session + std::map mSessionSpanMap; + + LogSessionHandle mLogSessionHandle = kInvalidLogSessionHandle; + + const uint8_t * GetDataStartForIntent(IntentEnum intent); +}; + +} // namespace DiagnosticLogs +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/examples/temperature-measurement-app/esp32/main/main.cpp b/examples/temperature-measurement-app/esp32/main/main.cpp index cb9ba768412772..9f7a73011a19a8 100644 --- a/examples/temperature-measurement-app/esp32/main/main.cpp +++ b/examples/temperature-measurement-app/esp32/main/main.cpp @@ -24,11 +24,13 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "nvs_flash.h" +#include #include #include #include #include #include +#include #include #include @@ -127,3 +129,10 @@ extern "C" void app_main() chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); } + +using namespace chip::app::Clusters::DiagnosticLogs; +void emberAfDiagnosticLogsClusterInitCallback(chip::EndpointId endpoint) +{ + auto & logProvider = LogProvider::GetInstance(); + DiagnosticLogsServer::Instance().SetDiagnosticLogsProviderDelegate(endpoint, &logProvider); +} diff --git a/examples/temperature-measurement-app/esp32/sdkconfig.defaults b/examples/temperature-measurement-app/esp32/sdkconfig.defaults index 81070fbfddb449..6d3243cabfeb8c 100644 --- a/examples/temperature-measurement-app/esp32/sdkconfig.defaults +++ b/examples/temperature-measurement-app/esp32/sdkconfig.defaults @@ -96,3 +96,6 @@ CONFIG_MBEDTLS_HKDF_C=y # Increase LwIP IPv6 address number CONFIG_LWIP_IPV6_NUM_ADDRESSES=6 + +# Enable the diagnostic logs transfer over BDX protocol +CONFIG_CHIP_ENABLE_BDX_LOG_TRANSFER=y diff --git a/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.matter b/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.matter index 4ee09b5869aaa4..e10100b918f8f6 100644 --- a/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.matter +++ b/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.matter @@ -796,6 +796,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -852,10 +856,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1452,10 +1468,15 @@ endpoint 0 { } server cluster DiagnosticLogs { + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; handle command RetrieveLogsRequest; + handle command RetrieveLogsResponse; } server cluster GeneralDiagnostics { @@ -1469,8 +1490,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.zap b/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.zap index 01453667d4538c..fde996ded8a2fb 100644 --- a/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.zap +++ b/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.zap @@ -1573,9 +1573,81 @@ "source": "client", "isIncoming": 1, "isEnabled": 1 + }, + { + "name": "RetrieveLogsResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 } ], "attributes": [ + { + "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, @@ -3225,5 +3297,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/thermostat/nxp/zap/thermostat_matter_thread.matter b/examples/thermostat/nxp/zap/thermostat_matter_thread.matter index e554c32be1cfd3..12441ffae6f858 100644 --- a/examples/thermostat/nxp/zap/thermostat_matter_thread.matter +++ b/examples/thermostat/nxp/zap/thermostat_matter_thread.matter @@ -1206,6 +1206,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1262,10 +1266,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Thread Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems */ @@ -2394,8 +2410,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/thermostat/nxp/zap/thermostat_matter_wifi.matter b/examples/thermostat/nxp/zap/thermostat_matter_wifi.matter index 43b09015e9a461..ff712e71043379 100644 --- a/examples/thermostat/nxp/zap/thermostat_matter_wifi.matter +++ b/examples/thermostat/nxp/zap/thermostat_matter_wifi.matter @@ -1206,6 +1206,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1262,10 +1266,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Wi-Fi Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2305,8 +2321,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/thermostat/qpg/zap/thermostaticRadiatorValve.matter b/examples/thermostat/qpg/zap/thermostaticRadiatorValve.matter index 713923440baa3a..776cef1ce4d8c8 100644 --- a/examples/thermostat/qpg/zap/thermostaticRadiatorValve.matter +++ b/examples/thermostat/qpg/zap/thermostaticRadiatorValve.matter @@ -933,6 +933,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -989,10 +993,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2043,8 +2059,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/thermostat/thermostat-common/thermostat.matter b/examples/thermostat/thermostat-common/thermostat.matter index 309c686e0756cb..301dbf6b94e1b3 100644 --- a/examples/thermostat/thermostat-common/thermostat.matter +++ b/examples/thermostat/thermostat-common/thermostat.matter @@ -994,6 +994,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1050,10 +1054,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2237,8 +2253,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; @@ -2369,7 +2385,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; handle command OpenCommissioningWindow; - handle command OpenBasicCommissioningWindow; handle command RevokeCommissioning; } diff --git a/examples/thermostat/thermostat-common/thermostat.zap b/examples/thermostat/thermostat-common/thermostat.zap index 4909f50165ab55..651b0fd201a2f1 100644 --- a/examples/thermostat/thermostat-common/thermostat.zap +++ b/examples/thermostat/thermostat-common/thermostat.zap @@ -3616,14 +3616,6 @@ "isIncoming": 1, "isEnabled": 1 }, - { - "name": "OpenBasicCommissioningWindow", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, { "name": "RevokeCommissioning", "code": 2, diff --git a/examples/tv-app/tv-common/tv-app.matter b/examples/tv-app/tv-common/tv-app.matter index b893f790792eb5..a2a6a086c5b0f8 100644 --- a/examples/tv-app/tv-common/tv-app.matter +++ b/examples/tv-app/tv-common/tv-app.matter @@ -1206,6 +1206,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1262,10 +1266,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -2007,6 +2023,99 @@ cluster UserLabel = 65 { readonly attribute int16u clusterRevision = 65533; } +/** This cluster provides an interface for passing messages to be presented by a device. */ +cluster Messages = 151 { + revision 3; + + enum FutureMessagePreferenceEnum : enum8 { + kAllowed = 0; + kIncreased = 1; + kReduced = 2; + kDisallowed = 3; + kBanned = 4; + } + + enum MessagePriorityEnum : enum8 { + kLow = 0; + kMedium = 1; + kHigh = 2; + kCritical = 3; + } + + bitmap Feature : bitmap32 { + kReceivedConfirmation = 0x1; + kConfirmationResponse = 0x2; + kConfirmationReply = 0x4; + kProtectedMessages = 0x8; + } + + bitmap MessageControlBitmap : bitmap8 { + kConfirmationRequired = 0x1; + kResponseRequired = 0x2; + kReplyMessage = 0x4; + kMessageConfirmed = 0x8; + kMessageProtected = 0x10; + } + + struct MessageResponseOptionStruct { + optional int32u messageResponseID = 0; + optional char_string<32> label = 1; + } + + struct MessageStruct { + octet_string<16> messageID = 0; + MessagePriorityEnum priority = 1; + MessageControlBitmap messageControl = 2; + nullable epoch_s startTime = 3; + nullable int16u duration = 4; + char_string<256> messageText = 5; + optional MessageResponseOptionStruct responses[] = 6; + } + + info event MessageQueued = 0 { + octet_string messageID = 0; + } + + info event MessagePresented = 1 { + octet_string messageID = 0; + } + + info event MessageComplete = 2 { + octet_string messageID = 0; + optional nullable int32u responseID = 1; + optional nullable char_string reply = 2; + nullable FutureMessagePreferenceEnum futureMessagesPreference = 3; + } + + readonly attribute MessageStruct messages[] = 0; + readonly attribute octet_string activeMessageIDs[] = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct PresentMessagesRequestRequest { + octet_string<16> messageID = 0; + MessagePriorityEnum priority = 1; + MessageControlBitmap messageControl = 2; + nullable epoch_s startTime = 3; + nullable int16u duration = 4; + char_string<256> messageText = 5; + optional MessageResponseOptionStruct responses[] = 6; + } + + request struct CancelMessagesRequestRequest { + octet_string messageIDs[] = 0; + } + + /** Command for requesting messages be presented */ + fabric command PresentMessagesRequest(PresentMessagesRequestRequest): DefaultSuccess = 0; + /** Command for cancelling message present requests */ + fabric command CancelMessagesRequest(CancelMessagesRequestRequest): DefaultSuccess = 1; +} + /** Attributes and commands for configuring the measurement of relative humidity, and reporting relative humidity measurements. */ cluster RelativeHumidityMeasurement = 1029 { revision 3; @@ -3213,8 +3322,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; @@ -3433,6 +3542,23 @@ endpoint 1 { callback attribute clusterRevision; } + server cluster Messages { + emits event MessageQueued; + emits event MessagePresented; + emits event MessageComplete; + callback attribute messages; + callback attribute activeMessageIDs; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 3; + + handle command PresentMessagesRequest; + handle command CancelMessagesRequest; + } + server cluster WakeOnLan { ram attribute MACAddress; ram attribute featureMap default = 0; diff --git a/examples/tv-app/tv-common/tv-app.zap b/examples/tv-app/tv-common/tv-app.zap index 955307dbf00c31..242fbba690931a 100644 --- a/examples/tv-app/tv-common/tv-app.zap +++ b/examples/tv-app/tv-common/tv-app.zap @@ -17,6 +17,12 @@ } ], "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + }, { "pathRelativity": "relativeToZap", "path": "../../../src/app/zap-templates/zcl/zcl.json", @@ -24,12 +30,6 @@ "category": "matter", "version": 1, "description": "Matter SDK ZCL data" - }, - { - "pathRelativity": "relativeToZap", - "path": "../../../src/app/zap-templates/app-templates.json", - "type": "gen-templates-json", - "version": "chip-v1" } ], "endpointTypes": [ @@ -4691,6 +4691,185 @@ } ] }, + { + "name": "Messages", + "code": 151, + "mfgCode": null, + "define": "MESSAGES_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "PresentMessagesRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "CancelMessagesRequest", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "Messages", + "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": "ActiveMessageIDs", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "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": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "MessageQueued", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "MessagePresented", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "MessageComplete", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, { "name": "Wake on LAN", "code": 1283, diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp index 0d493965e21829..0cbfab8b5864b8 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp @@ -22,6 +22,7 @@ #include "ConversionUtils.h" #include "JNIDACProvider.h" +#include #include #include #include @@ -32,7 +33,6 @@ #include #include #include -#include #include #include diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm index b19d72097f7ecc..86a1976aed7d18 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm @@ -25,10 +25,10 @@ #import "MatterCallbacks.h" #import "OnboardingPayload.h" +#include #include #include #include -#include #include #include diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter index 16c934e5095488..2b488ca072e89e 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter @@ -994,6 +994,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1050,10 +1054,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1485,6 +1501,99 @@ cluster FixedLabel = 64 { readonly attribute int16u clusterRevision = 65533; } +/** This cluster provides an interface for passing messages to be presented by a device. */ +cluster Messages = 151 { + revision 3; + + enum FutureMessagePreferenceEnum : enum8 { + kAllowed = 0; + kIncreased = 1; + kReduced = 2; + kDisallowed = 3; + kBanned = 4; + } + + enum MessagePriorityEnum : enum8 { + kLow = 0; + kMedium = 1; + kHigh = 2; + kCritical = 3; + } + + bitmap Feature : bitmap32 { + kReceivedConfirmation = 0x1; + kConfirmationResponse = 0x2; + kConfirmationReply = 0x4; + kProtectedMessages = 0x8; + } + + bitmap MessageControlBitmap : bitmap8 { + kConfirmationRequired = 0x1; + kResponseRequired = 0x2; + kReplyMessage = 0x4; + kMessageConfirmed = 0x8; + kMessageProtected = 0x10; + } + + struct MessageResponseOptionStruct { + optional int32u messageResponseID = 0; + optional char_string<32> label = 1; + } + + struct MessageStruct { + octet_string<16> messageID = 0; + MessagePriorityEnum priority = 1; + MessageControlBitmap messageControl = 2; + nullable epoch_s startTime = 3; + nullable int16u duration = 4; + char_string<256> messageText = 5; + optional MessageResponseOptionStruct responses[] = 6; + } + + info event MessageQueued = 0 { + octet_string messageID = 0; + } + + info event MessagePresented = 1 { + octet_string messageID = 0; + } + + info event MessageComplete = 2 { + octet_string messageID = 0; + optional nullable int32u responseID = 1; + optional nullable char_string reply = 2; + nullable FutureMessagePreferenceEnum futureMessagesPreference = 3; + } + + readonly attribute MessageStruct messages[] = 0; + readonly attribute octet_string activeMessageIDs[] = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct PresentMessagesRequestRequest { + octet_string<16> messageID = 0; + MessagePriorityEnum priority = 1; + MessageControlBitmap messageControl = 2; + nullable epoch_s startTime = 3; + nullable int16u duration = 4; + char_string<256> messageText = 5; + optional MessageResponseOptionStruct responses[] = 6; + } + + request struct CancelMessagesRequestRequest { + octet_string messageIDs[] = 0; + } + + /** Command for requesting messages be presented */ + fabric command PresentMessagesRequest(PresentMessagesRequestRequest): DefaultSuccess = 0; + /** Command for cancelling message present requests */ + fabric command CancelMessagesRequest(CancelMessagesRequestRequest): DefaultSuccess = 1; +} + /** This cluster provides an interface for managing low power mode on a device that supports the Wake On LAN protocol. */ cluster WakeOnLan = 1283 { revision 1; @@ -2653,8 +2762,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; @@ -2763,6 +2872,7 @@ endpoint 1 { binding cluster OnOff; binding cluster LevelControl; binding cluster Descriptor; + binding cluster Messages; binding cluster WakeOnLan; binding cluster Channel; binding cluster TargetNavigator; diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap b/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap index 2bb394da30433d..955ef18532ce02 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap @@ -17,6 +17,12 @@ } ], "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + }, { "pathRelativity": "relativeToZap", "path": "../../../src/app/zap-templates/zcl/zcl.json", @@ -24,12 +30,6 @@ "category": "matter", "version": 1, "description": "Matter SDK ZCL data" - }, - { - "pathRelativity": "relativeToZap", - "path": "../../../src/app/zap-templates/app-templates.json", - "type": "gen-templates-json", - "version": "chip-v1" } ], "endpointTypes": [ @@ -3585,6 +3585,66 @@ } ] }, + { + "name": "Messages", + "code": 151, + "mfgCode": null, + "define": "MESSAGES_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "PresentMessagesRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "CancelMessagesRequest", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Wake on LAN", "code": 1283, diff --git a/examples/virtual-device-app/virtual-device-common/virtual-device-app.matter b/examples/virtual-device-app/virtual-device-common/virtual-device-app.matter index 9e4c439744cf39..e9e7fee0531769 100644 --- a/examples/virtual-device-app/virtual-device-common/virtual-device-app.matter +++ b/examples/virtual-device-app/virtual-device-common/virtual-device-app.matter @@ -1197,6 +1197,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1253,10 +1257,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -3144,8 +3160,8 @@ endpoint 0 { callback attribute activeRadioFaults; callback attribute activeNetworkFaults; callback attribute testEventTriggersEnabled default = false; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; diff --git a/examples/window-app/common/window-app.matter b/examples/window-app/common/window-app.matter index c8308305b71a9e..7e0053fd83ee39 100644 --- a/examples/window-app/common/window-app.matter +++ b/examples/window-app/common/window-app.matter @@ -1135,6 +1135,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1191,10 +1195,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -1810,6 +1826,91 @@ cluster UserLabel = 65 { readonly attribute int16u clusterRevision = 65533; } +/** Allows servers to ensure that listed clients are notified when a server is available for communication. */ +cluster IcdManagement = 70 { + revision 2; + + enum OperatingModeEnum : enum8 { + kSIT = 0; + kLIT = 1; + } + + bitmap Feature : bitmap32 { + kCheckInProtocolSupport = 0x1; + kUserActiveModeTrigger = 0x2; + kLongIdleTimeSupport = 0x4; + } + + bitmap UserActiveModeTriggerBitmap : bitmap32 { + kPowerCycle = 0x1; + kSettingsMenu = 0x2; + kCustomInstruction = 0x4; + kDeviceManual = 0x8; + kActuateSensor = 0x10; + kActuateSensorSeconds = 0x20; + kActuateSensorTimes = 0x40; + kActuateSensorLightsBlink = 0x80; + kResetButton = 0x100; + kResetButtonLightsBlink = 0x200; + kResetButtonSeconds = 0x400; + kResetButtonTimes = 0x800; + kSetupButton = 0x1000; + kSetupButtonSeconds = 0x2000; + kSetupButtonLightsBlink = 0x4000; + kSetupButtonTimes = 0x8000; + kAppDefinedButton = 0x10000; + } + + fabric_scoped struct MonitoringRegistrationStruct { + fabric_sensitive node_id checkInNodeID = 1; + fabric_sensitive int64u monitoredSubject = 2; + fabric_idx fabricIndex = 254; + } + + readonly attribute int32u idleModeDuration = 0; + readonly attribute int32u activeModeDuration = 1; + readonly attribute int16u activeModeThreshold = 2; + readonly attribute access(read: administer) optional MonitoringRegistrationStruct registeredClients[] = 3; + readonly attribute access(read: administer) optional int32u ICDCounter = 4; + readonly attribute optional int16u clientsSupportedPerFabric = 5; + readonly attribute optional UserActiveModeTriggerBitmap userActiveModeTriggerHint = 6; + readonly attribute optional char_string<128> userActiveModeTriggerInstruction = 7; + readonly attribute optional OperatingModeEnum operatingMode = 8; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct RegisterClientRequest { + node_id checkInNodeID = 0; + int64u monitoredSubject = 1; + octet_string<16> key = 2; + optional octet_string<16> verificationKey = 3; + } + + response struct RegisterClientResponse = 1 { + int32u ICDCounter = 0; + } + + request struct UnregisterClientRequest { + node_id checkInNodeID = 0; + optional octet_string<16> verificationKey = 1; + } + + response struct StayActiveResponse = 4 { + int32u promisedActiveDuration = 0; + } + + /** Register a client to the end device */ + fabric command access(invoke: manage) RegisterClient(RegisterClientRequest): RegisterClientResponse = 0; + /** Unregister a client from an end device */ + fabric command access(invoke: manage) UnregisterClient(UnregisterClientRequest): DefaultSuccess = 2; + /** Request the end device to stay in Active Mode for an additional ActiveModeThreshold */ + command access(invoke: manage) StayActiveRequest(): StayActiveResponse = 3; +} + /** Provides an interface for controlling and adjusting automatic window coverings. */ cluster WindowCovering = 258 { revision 5; @@ -2159,8 +2260,8 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 0x0002; + callback attribute featureMap; + callback attribute clusterRevision; handle command TestEventTrigger; handle command TimeSnapshot; @@ -2297,7 +2398,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; handle command OpenCommissioningWindow; - handle command OpenBasicCommissioningWindow; handle command RevokeCommissioning; } @@ -2360,6 +2460,18 @@ endpoint 0 { ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; } + + server cluster IcdManagement { + callback attribute idleModeDuration; + callback attribute activeModeDuration; + callback attribute activeModeThreshold; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0x0000; + ram attribute clusterRevision default = 2; + } } endpoint 1 { device type ma_windowcovering = 514, version 2; diff --git a/examples/window-app/common/window-app.zap b/examples/window-app/common/window-app.zap index 46ca5f520c42eb..1ce4a5db8e81f4 100644 --- a/examples/window-app/common/window-app.zap +++ b/examples/window-app/common/window-app.zap @@ -4266,14 +4266,6 @@ "isIncoming": 1, "isEnabled": 1 }, - { - "name": "OpenBasicCommissioningWindow", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, { "name": "RevokeCommissioning", "code": 2, @@ -5065,6 +5057,160 @@ "reportableChange": 0 } ] + }, + { + "name": "ICD Management", + "code": 70, + "mfgCode": null, + "define": "ICD_MANAGEMENT_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "IdleModeDuration", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveModeDuration", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveModeThreshold", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "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": "0x0000", + "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": "2", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] } ] }, diff --git a/examples/window-app/silabs/openthread.gn b/examples/window-app/silabs/openthread.gn index b05216fc9d7eae..27aa6c766a17e6 100644 --- a/examples/window-app/silabs/openthread.gn +++ b/examples/window-app/silabs/openthread.gn @@ -23,7 +23,7 @@ check_system_includes = true default_args = { target_cpu = "arm" target_os = "freertos" - chip_openthread_ftd = true + chip_openthread_ftd = false import("//openthread.gni") } diff --git a/examples/window-app/silabs/openthread.gni b/examples/window-app/silabs/openthread.gni index ffe5dc7c278205..cdd7f8c0f1f42e 100644 --- a/examples/window-app/silabs/openthread.gni +++ b/examples/window-app/silabs/openthread.gni @@ -24,3 +24,18 @@ chip_enable_openthread = true openthread_external_platform = "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" + +# ICD Default configurations +chip_enable_icd_server = true +enable_synchronized_sed = true +chip_subscription_timeout_resumption = false +sl_use_subscription_synching = true + +# Openthread Configuration flags +sl_ot_idle_interval_ms = 1000 # 1s Idle Intervals +sl_ot_active_interval_ms = 500 # 500ms Active Intervals + +# ICD Matter Configuration flags +sl_idle_mode_interval_s = 600 # 10min Idle Mode Interval +sl_active_mode_interval_ms = 0 # 0s Active Mode Interval +sl_active_mode_threshold_ms = 0 # 1s Active Mode Threshold diff --git a/integrations/docker/images/base/chip-build/version b/integrations/docker/images/base/chip-build/version index 7c51e45e89e229..4a62ddb7795a85 100644 --- a/integrations/docker/images/base/chip-build/version +++ b/integrations/docker/images/base/chip-build/version @@ -1 +1 @@ -34 : [Telink] Update Docker image (Zephyr update) +35 : [Telink] Update Docker image (Zephyr update) diff --git a/integrations/docker/images/stage-2/chip-build-telink/Dockerfile b/integrations/docker/images/stage-2/chip-build-telink/Dockerfile index a057044c5a1fae..98de9d1c5c163f 100644 --- a/integrations/docker/images/stage-2/chip-build-telink/Dockerfile +++ b/integrations/docker/images/stage-2/chip-build-telink/Dockerfile @@ -12,7 +12,7 @@ RUN set -x \ && : # last line # Setup Zephyr -ARG ZEPHYR_REVISION=5bcb564c5bec3f3ebcaf7ae9949e053ef414df1f +ARG ZEPHYR_REVISION=c4dd151a1ffa96bfbd577ddc88a55c5785279514 WORKDIR /opt/telink/zephyrproject RUN set -x \ && python3 -m pip install -U --no-cache-dir west \ diff --git a/scripts/examples/gn_silabs_example.sh b/scripts/examples/gn_silabs_example.sh index fc8fcfd387f8fa..c69f9d495fa975 100755 --- a/scripts/examples/gn_silabs_example.sh +++ b/scripts/examples/gn_silabs_example.sh @@ -86,6 +86,10 @@ if [ "$#" == "0" ]; then chip_enable_icd_server Configure has a Intermitently connected device. (Default false) Must also set chip_openthread_ftd=false + enable_synchronized_sed + Enable Synchronized Sleepy end device. (Default false) + Must also set chip_enable_icd_server=true chip_openthread_ftd=false + --icd can be used to configure both arguments use_rs9116 Build wifi example with extension board rs9116. (Default false) use_SiWx917 diff --git a/scripts/py_matter_idl/matter_idl/generators/java/ChipClusters_java.jinja b/scripts/py_matter_idl/matter_idl/generators/java/ChipClusters_java.jinja index 45621c7e86469a..ba0abf5976f49c 100644 --- a/scripts/py_matter_idl/matter_idl/generators/java/ChipClusters_java.jinja +++ b/scripts/py_matter_idl/matter_idl/generators/java/ChipClusters_java.jinja @@ -238,7 +238,6 @@ public class ChipClusters { @Deprecated public void deleteCluster(long chipClusterPtr) {} - @SuppressWarnings("deprecation") protected void finalize() throws Throwable { super.finalize(); @@ -415,7 +414,7 @@ public class ChipClusters { elements.add(new StructElement({{field.name | lowfirst_except_acronym}}FieldID, {{field.name | lowfirst_except_acronym}}tlvValue)); {% endfor -%} {%- endif %} - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -456,7 +455,7 @@ public class ChipClusters { {%- else %} callback.onSuccess(); {%- endif %} - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } {% endfor %} {%- set already_handled_command = [] -%} diff --git a/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/java/ChipClusters.java b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/java/ChipClusters.java index 94d8415d01ccee..9b6287a9a954ae 100644 --- a/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/java/ChipClusters.java +++ b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/java/ChipClusters.java @@ -161,7 +161,6 @@ protected void invoke( @Deprecated public void deleteCluster(long chipClusterPtr) {} - @SuppressWarnings("deprecation") protected void finalize() throws Throwable { super.finalize(); diff --git a/scripts/py_matter_yamltests/matter_yamltests/websocket_runner.py b/scripts/py_matter_yamltests/matter_yamltests/websocket_runner.py index c63554ecf064b0..34b1ba17e68734 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/websocket_runner.py +++ b/scripts/py_matter_yamltests/matter_yamltests/websocket_runner.py @@ -70,7 +70,7 @@ async def execute(self, request): return await instance.recv() return None - async def _start_client(self, url, max_retries=4, interval_between_retries=1): + async def _start_client(self, url, max_retries=5, interval_between_retries=1): if max_retries: start = time.time() try: diff --git a/scripts/rules.matterlint b/scripts/rules.matterlint index d2fff0f9a53750..e876bae22094c6 100644 --- a/scripts/rules.matterlint +++ b/scripts/rules.matterlint @@ -29,6 +29,7 @@ load "../src/app/zap-templates/zcl/data-model/chip/device-energy-management-mode load "../src/app/zap-templates/zcl/data-model/chip/diagnostic-logs-cluster.xml"; load "../src/app/zap-templates/zcl/data-model/chip/dishwasher-alarm-cluster.xml"; load "../src/app/zap-templates/zcl/data-model/chip/dishwasher-mode-cluster.xml"; +load "../src/app/zap-templates/zcl/data-model/chip/measurement-and-sensing.xml"; load "../src/app/zap-templates/zcl/data-model/chip/microwave-oven-mode-cluster.xml"; load "../src/app/zap-templates/zcl/data-model/chip/microwave-oven-control-cluster.xml"; load "../src/app/zap-templates/zcl/data-model/chip/door-lock-cluster.xml"; @@ -67,6 +68,7 @@ load "../src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster load "../src/app/zap-templates/zcl/data-model/chip/oven-mode-cluster.xml"; load "../src/app/zap-templates/zcl/data-model/chip/power-source-cluster.xml"; load "../src/app/zap-templates/zcl/data-model/chip/power-source-configuration-cluster.xml"; +load "../src/app/zap-templates/zcl/data-model/chip/power-topology-cluster.xml"; load "../src/app/zap-templates/zcl/data-model/chip/pressure-measurement-cluster.xml"; load "../src/app/zap-templates/zcl/data-model/chip/proxy-configuration-cluster.xml"; load "../src/app/zap-templates/zcl/data-model/chip/proxy-discovery-cluster.xml"; @@ -98,13 +100,15 @@ load "../src/app/zap-templates/zcl/data-model/chip/wifi-network-diagnostics-clus load "../src/app/zap-templates/zcl/data-model/chip/window-covering.xml"; load "../src/app/zap-templates/zcl/data-model/chip/temperature-control-cluster.xml"; load "../src/app/zap-templates/zcl/data-model/chip/refrigerator-alarm.xml"; +load "../src/app/zap-templates/zcl/data-model/chip/air-quality-cluster.xml"; +load "../src/app/zap-templates/zcl/data-model/chip/resource-monitoring-cluster.xml"; +load "../src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml"; +load "../src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml"; +load "../src/app/zap-templates/zcl/data-model/chip/electrical-power-measurement-cluster.xml"; load "../src/app/zap-templates/zcl/data-model/draft/barrier-control-cluster.xml"; load "../src/app/zap-templates/zcl/data-model/draft/electrical-measurement-cluster.xml"; load "../src/app/zap-templates/zcl/data-model/draft/input-output-value-clusters.xml"; load "../src/app/zap-templates/zcl/data-model/draft/onoff-switch-configuration-cluster.xml"; -load "../src/app/zap-templates/zcl/data-model/chip/air-quality-cluster.xml"; -load "../src/app/zap-templates/zcl/data-model/chip/resource-monitoring-cluster.xml"; -load "../src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml"; all endpoints { // These attributes follow a different code path and do not have to be diff --git a/scripts/setup/zap.json b/scripts/setup/zap.json index 5eb1bc2a8986c0..c5d0defa49903e 100644 --- a/scripts/setup/zap.json +++ b/scripts/setup/zap.json @@ -8,13 +8,13 @@ "mac-amd64", "windows-amd64" ], - "tags": ["version:2@v2023.12.06-nightly.1"] + "tags": ["version:2@v2024.01.05-nightly.1"] }, { "_comment": "Always get the amd64 version on mac until usable arm64 zap build is available", "path": "fuchsia/third_party/zap/mac-amd64", "platforms": ["mac-arm64"], - "tags": ["version:2@v2023.12.06-nightly.1"] + "tags": ["version:2@v2024.01.05-nightly.1"] } ] } diff --git a/scripts/setup/zap.version b/scripts/setup/zap.version index ef81141953af89..ed26575a140e19 100644 --- a/scripts/setup/zap.version +++ b/scripts/setup/zap.version @@ -1 +1 @@ -v2023.12.06-nightly +v2024.01.05-nightly diff --git a/scripts/tests/chiptest/__init__.py b/scripts/tests/chiptest/__init__.py index 378e3df2e02669..dba11f15d44c1e 100644 --- a/scripts/tests/chiptest/__init__.py +++ b/scripts/tests/chiptest/__init__.py @@ -160,6 +160,60 @@ def _GetInDevelopmentTests() -> Set[str]: } +def _GetDarwinFrameworkToolUnsupportedTests() -> Set[str]: + """Tests that fail in darwin-framework-tool for some reason""" + return { + "DL_LockUnlock", # darwin-framework-tool does not currently support reading or subscribing to Events + "Test_AddNewFabricFromExistingFabric", # darwin-framework-tool does not support the GetCommissionerRootCertificate command. + # The name of the arguments once converted differs for chip-tool and darwin-framework-tool (attribute-ids vs attribute-id. See #31934) + "TestAttributesById", + "TestBasicInformation", # darwin-framework-tool does not support writing readonly attributes by name + "TestClusterComplexTypes", # Darwin framework has no way to represent a present but null optional nullable field. + # When reading TestFabricScoped in TestClusterMultiFabric, the result differs because of missing fields that have been declared in the YAML step with null value to workaround some limitation of the test harness (#29110) + "TestClusterMultiFabric", + "TestCommandsById", # darwin-framework-tool does not support writing readonly attributes by name + "TestDiagnosticLogs", # darwin-framework-tool does not implement a BDXTransferServerDelegate + "TestDiscovery", # darwin-framework-tool does not support dns-sd commands. + "TestEvents", # darwin-framework-tool does not currently support reading or subscribing to Events + "TestEventsById", # darwin-framework-tool does not currently support reading or subscribing to Events + "TestGroupMessaging", # darwin-framework-tool does not support group commands. + "TestIcdManagementCluster", # darwin-framework-tool does not support ICD registration + "TestUnitTestingClusterMei", # darwin-framework-tool does not currently support reading or subscribing to Events + "TestReadNoneSubscribeNone", # darwin-framework-tool does not supports those commands. + + "Test_TC_ACE_1_6", # darwin-framework-tool does not support group commands. + "Test_TC_ACL_2_5", # darwin-framework-tool does not currently support reading or subscribing to Events + "Test_TC_ACL_2_6", # darwin-framework-tool does not currently support reading or subscribing to Events + "Test_TC_ACL_2_7", # darwin-framework-tool does not currently support reading or subscribing to Events + "Test_TC_ACL_2_8", # darwin-framework-tool does not currently support reading or subscribing to Events + "Test_TC_ACL_2_9", # darwin-framework-tool does not currently support reading or subscribing to Events + "Test_TC_ACL_2_10", # darwin-framework-tool does not currently support reading or subscribing to Events + "Test_TC_BINFO_2_1", # darwin-framework-tool does not support writing readonly attributes by name + "Test_TC_BINFO_2_2", # darwin-framework-tool does not currently support reading or subscribing to Events + # The name of the arguments once converted differs for chip-tool and darwin-framework-tool (attribute-ids vs attribute-id. See #31934) + "Test_TC_BRBINFO_2_1", + "Test_TC_DGGEN_2_3", # darwin-framework-tool does not currently support reading or subscribing to Events + "Test_TC_DRLK_2_1", # darwin-framework-tool does not support writing readonly attributes by name + "Test_TC_DGTHREAD_2_1", # Thread Network Diagnostics is not implemented under darwin. + "Test_TC_DGTHREAD_2_2", # Thread Network Diagnostics is not implemented under darwin. + "Test_TC_DGTHREAD_2_3", # Thread Network Diagnostics is not implemented under darwin. + "Test_TC_DGTHREAD_2_4", # Thread Network Diagnostics is not implemented under darwin. + "Test_TC_FLABEL_2_1", # darwin-framework-tool does not support writing readonly attributes by name + "Test_TC_GRPKEY_2_1", # darwin-framework-tool does not support writing readonly attributes by name + "Test_TC_LCFG_2_1", # darwin-framework-tool does not support writing readonly attributes by name + "Test_TC_OPCREDS_3_7", # darwin-framework-tool does not support the GetCommissionerRootCertificate command. + "Test_TC_OPSTATE_2_4", # darwin-framework-tool does not currently support reading or subscribing to Events + "Test_TC_SMOKECO_2_2", # darwin-framework-tool does not currently support reading or subscribing to Events + "Test_TC_SMOKECO_2_3", # darwin-framework-tool does not currently support reading or subscribing to Events + "Test_TC_SMOKECO_2_4", # darwin-framework-tool does not currently support reading or subscribing to Events + "Test_TC_SMOKECO_2_5", # darwin-framework-tool does not currently support reading or subscribing to Events + "Test_TC_SMOKECO_2_6", # darwin-framework-tool does not currently support reading or subscribing to Events + "Test_TC_SC_4_1", # darwin-framework-tool does not support dns-sd commands. + "Test_TC_SC_5_2", # darwin-framework-tool does not support group commands. + "Test_TC_S_2_3", # darwin-framework-tool does not support group commands. + } + + def _GetChipReplUnsupportedTests() -> Set[str]: """Tests that fail in chip-repl for some reason""" return { @@ -284,7 +338,7 @@ def tests_with_command(chip_tool: str, is_manual: bool): ) -def _AllFoundYamlTests(treat_repl_unsupported_as_in_development: bool, use_short_run_name: bool): +def _AllFoundYamlTests(treat_repl_unsupported_as_in_development: bool, treat_dft_unsupported_as_in_development: bool, use_short_run_name: bool): """ use_short_run_name should be true if we want the run_name to be "Test_ABC" instead of "some/path/Test_ABC.yaml" """ @@ -294,6 +348,7 @@ def _AllFoundYamlTests(treat_repl_unsupported_as_in_development: bool, use_short extra_slow_tests = _GetExtraSlowTests() in_development_tests = _GetInDevelopmentTests() chip_repl_unsupported_tests = _GetChipReplUnsupportedTests() + treat_dft_unsupported_as_in_development_tests = _GetDarwinFrameworkToolUnsupportedTests() purposeful_failure_tests = _GetPurposefulFailureTests() for path in _AllYamlTests(): @@ -327,6 +382,9 @@ def _AllFoundYamlTests(treat_repl_unsupported_as_in_development: bool, use_short else: run_name = str(path) + if treat_dft_unsupported_as_in_development and run_name in treat_dft_unsupported_as_in_development_tests: + tags.add(TestTag.IN_DEVELOPMENT) + yield TestDefinition( run_name=run_name, name=path.stem, # `path.stem` converts "some/path/Test_ABC_1.2.yaml" to "Test_ABC.1.2" @@ -336,12 +394,17 @@ def _AllFoundYamlTests(treat_repl_unsupported_as_in_development: bool, use_short def AllReplYamlTests(): - for test in _AllFoundYamlTests(treat_repl_unsupported_as_in_development=True, use_short_run_name=False): + for test in _AllFoundYamlTests(treat_repl_unsupported_as_in_development=True, treat_dft_unsupported_as_in_development=False, use_short_run_name=False): yield test def AllChipToolYamlTests(): - for test in _AllFoundYamlTests(treat_repl_unsupported_as_in_development=False, use_short_run_name=True): + for test in _AllFoundYamlTests(treat_repl_unsupported_as_in_development=False, treat_dft_unsupported_as_in_development=False, use_short_run_name=True): + yield test + + +def AllDarwinFrameworkToolYamlTests(): + for test in _AllFoundYamlTests(treat_repl_unsupported_as_in_development=False, treat_dft_unsupported_as_in_development=True, use_short_run_name=True): yield test diff --git a/scripts/tests/chiptest/test_definition.py b/scripts/tests/chiptest/test_definition.py index da1b56afd919e1..19f0a7dcb74b0b 100644 --- a/scripts/tests/chiptest/test_definition.py +++ b/scripts/tests/chiptest/test_definition.py @@ -251,10 +251,9 @@ def to_s(self): class TestRunTime(Enum): - CHIP_TOOL_BUILTIN = auto() # run via chip-tool built-in test commands CHIP_TOOL_PYTHON = auto() # use the python yaml test parser with chip-tool + DARWIN_FRAMEWORK_TOOL_PYTHON = auto() # use the python yaml test parser with chip-tool CHIP_REPL_PYTHON = auto() # use the python yaml test runner - DARWIN_FRAMEWORK_TOOL_BUILTIN = auto() # run via darwin-framework-tool built-in test commands @dataclass @@ -281,7 +280,7 @@ def tags_str(self) -> str: return ", ".join([t.to_s() for t in self.tags]) def Run(self, runner, apps_register, paths: ApplicationPaths, pics_file: str, - timeout_seconds: typing.Optional[int], dry_run=False, test_runtime: TestRunTime = TestRunTime.CHIP_TOOL_BUILTIN): + timeout_seconds: typing.Optional[int], dry_run=False, test_runtime: TestRunTime = TestRunTime.CHIP_TOOL_PYTHON): """ Executes the given test case using the provided runner for execution. """ @@ -333,8 +332,6 @@ def Run(self, runner, apps_register, paths: ApplicationPaths, pics_file: str, # so it will be commissionable again. app.factoryReset() - tool_cmd = paths.chip_tool if test_runtime != TestRunTime.CHIP_TOOL_PYTHON else paths.chip_tool_with_python_cmd - if dry_run: tool_storage_dir = None tool_storage_args = [] @@ -350,38 +347,37 @@ def Run(self, runner, apps_register, paths: ApplicationPaths, pics_file: str, app.start() setupCode = app.setupCode - pairing_cmd = tool_cmd + ['pairing', 'code', TEST_NODE_ID, setupCode] - test_cmd = tool_cmd + ['tests', self.run_name] + ['--PICS', pics_file] - if test_runtime == TestRunTime.CHIP_TOOL_PYTHON: + if test_runtime == TestRunTime.CHIP_REPL_PYTHON: + chip_repl_yaml_tester_cmd = paths.chip_repl_yaml_tester_cmd + python_cmd = chip_repl_yaml_tester_cmd + \ + ['--setup-code', setupCode] + ['--yaml-path', self.run_name] + ["--pics-file", pics_file] + if dry_run: + logging.info(" ".join(python_cmd)) + else: + runner.RunSubprocess(python_cmd, name='CHIP_REPL_YAML_TESTER', + dependencies=[apps_register], timeout_seconds=timeout_seconds) + else: + pairing_cmd = paths.chip_tool_with_python_cmd + ['pairing', 'code', TEST_NODE_ID, setupCode] + test_cmd = paths.chip_tool_with_python_cmd + ['tests', self.run_name] + ['--PICS', pics_file] server_args = ['--server_path', paths.chip_tool[-1]] + \ ['--server_arguments', 'interactive server' + (' ' if len(tool_storage_args) else '') + ' '.join(tool_storage_args)] pairing_cmd += server_args test_cmd += server_args - elif test_runtime == TestRunTime.CHIP_TOOL_BUILTIN: - pairing_cmd += tool_storage_args - test_cmd += tool_storage_args - - if dry_run: - # Some of our command arguments have spaces in them, so if we are - # trying to log commands people can run we should quote those. - def quoter(arg): return f"'{arg}'" if ' ' in arg else arg - logging.info(" ".join(map(quoter, pairing_cmd))) - logging.info(" ".join(map(quoter, test_cmd))) - elif test_runtime == TestRunTime.CHIP_REPL_PYTHON: - chip_repl_yaml_tester_cmd = paths.chip_repl_yaml_tester_cmd - python_cmd = chip_repl_yaml_tester_cmd + \ - ['--setup-code', app.setupCode] + ['--yaml-path', self.run_name] + ["--pics-file", pics_file] - runner.RunSubprocess(python_cmd, name='CHIP_REPL_YAML_TESTER', - dependencies=[apps_register], timeout_seconds=timeout_seconds) - else: - runner.RunSubprocess(pairing_cmd, - name='PAIR', dependencies=[apps_register]) - runner.RunSubprocess( - test_cmd, - name='TEST', dependencies=[apps_register], - timeout_seconds=timeout_seconds) + if dry_run: + # Some of our command arguments have spaces in them, so if we are + # trying to log commands people can run we should quote those. + def quoter(arg): return f"'{arg}'" if ' ' in arg else arg + logging.info(" ".join(map(quoter, pairing_cmd))) + logging.info(" ".join(map(quoter, test_cmd))) + else: + runner.RunSubprocess(pairing_cmd, + name='PAIR', dependencies=[apps_register]) + runner.RunSubprocess( + test_cmd, + name='TEST', dependencies=[apps_register], + timeout_seconds=timeout_seconds) except Exception: logging.error("!!!!!!!!!!!!!!!!!!!! ERROR !!!!!!!!!!!!!!!!!!!!!!") diff --git a/scripts/tests/run_test_suite.py b/scripts/tests/run_test_suite.py index 03773e4fb88f84..d4d94b28bf858c 100755 --- a/scripts/tests/run_test_suite.py +++ b/scripts/tests/run_test_suite.py @@ -123,8 +123,8 @@ class RunContext: ) @click.option( '--runner', - type=click.Choice(['codegen', 'chip_repl_python', 'chip_tool_python'], case_sensitive=False), - default='codegen', + type=click.Choice(['chip_repl_python', 'chip_tool_python', 'darwin_framework_tool_python'], case_sensitive=False), + default='chip_tool_python', help='Run YAML tests using the specified runner.') @click.option( '--chip-tool', @@ -138,18 +138,18 @@ def main(context, dry_run, log_level, target, target_glob, target_skip_glob, log_fmt = '%(levelname)-7s %(message)s' coloredlogs.install(level=__LOG_LEVELS__[log_level], fmt=log_fmt) - runtime = TestRunTime.CHIP_TOOL_BUILTIN + runtime = TestRunTime.CHIP_TOOL_PYTHON if runner == 'chip_repl_python': runtime = TestRunTime.CHIP_REPL_PYTHON - elif runner == 'chip_tool_python': - runtime = TestRunTime.CHIP_TOOL_PYTHON - elif chip_tool is not None and os.path.basename(chip_tool) == "darwin-framework-tool": - runtime = TestRunTime.DARWIN_FRAMEWORK_TOOL_BUILTIN + elif runner == 'darwin_framework_tool_python': + runtime = TestRunTime.DARWIN_FRAMEWORK_TOOL_PYTHON if chip_tool is None and not runtime == TestRunTime.CHIP_REPL_PYTHON: - # non yaml tests REQUIRE chip-tool. Yaml tests should not require chip-tool paths_finder = PathsFinder() - chip_tool = paths_finder.get('chip-tool') + if runtime == TestRunTime.CHIP_TOOL_PYTHON: + chip_tool = paths_finder.get('chip-tool') + else: + chip_tool = paths_finder.get('darwin-framework-tool') if include_tags: include_tags = set([TestTag.__members__[t] for t in include_tags]) @@ -160,10 +160,10 @@ def main(context, dry_run, log_level, target, target_glob, target_skip_glob, # Figures out selected test that match the given name(s) if runtime == TestRunTime.CHIP_REPL_PYTHON: all_tests = [test for test in chiptest.AllReplYamlTests()] - elif runtime == TestRunTime.CHIP_TOOL_PYTHON and os.path.basename(chip_tool) != "darwin-framework-tool": - all_tests = [test for test in chiptest.AllChipToolYamlTests()] + elif runtime == TestRunTime.DARWIN_FRAMEWORK_TOOL_PYTHON: + all_tests = [test for test in chiptest.AllDarwinFrameworkToolYamlTests()] else: - all_tests = [test for test in chiptest.AllChipToolTests(chip_tool)] + all_tests = [test for test in chiptest.AllChipToolYamlTests()] tests = all_tests @@ -178,7 +178,7 @@ def main(context, dry_run, log_level, target, target_glob, target_skip_glob, TestTag.PURPOSEFUL_FAILURE, } - if runtime != TestRunTime.CHIP_TOOL_PYTHON: + if runtime == TestRunTime.CHIP_REPL_PYTHON: exclude_tags.add(TestTag.CHIP_TOOL_PYTHON_ONLY) if 'all' not in target: @@ -319,7 +319,7 @@ def cmd_run(context, iterations, all_clusters_app, lock_app, ota_provider_app, o chip_repl_yaml_tester = paths_finder.get('yamltest_with_chip_repl_tester.py') if chip_tool_with_python is None: - if context.obj.chip_tool and os.path.basename(context.obj.chip_tool) == "darwin-framework-tool": + if context.obj.runtime == TestRunTime.DARWIN_FRAMEWORK_TOOL_PYTHON: chip_tool_with_python = paths_finder.get('darwinframeworktool.py') else: chip_tool_with_python = paths_finder.get('chiptool.py') diff --git a/scripts/tools/check_includes_config.py b/scripts/tools/check_includes_config.py index abe2c0ed42f5af..42920c4014c133 100644 --- a/scripts/tools/check_includes_config.py +++ b/scripts/tools/check_includes_config.py @@ -93,7 +93,7 @@ 'vector', # CHIP headers using STL containers. - 'lib/support/CHIPListUtils.h', # uses std::set + 'app/data-model/ListLargeSystemExtensions.h', # uses std::set 'src/platform/DeviceSafeQueue.h', # uses std::deque } @@ -113,7 +113,7 @@ 'src/lib/support/IniEscaping.h': {'string'}, # Itself in DENY. - 'src/lib/support/CHIPListUtils.h': {'set'}, + 'src/app/data-model/ListLargeSystemExtensions.h': {'set'}, 'src/platform/DeviceSafeQueue.h': {'queue'}, # Only uses for zero-cost types. @@ -158,7 +158,7 @@ # Library meant for non-embedded 'src/tracing/json/json_tracing.cpp': {'string', 'sstream'}, - 'src/tracing/json/json_tracing.h': {'fstream'}, + 'src/tracing/json/json_tracing.h': {'fstream', 'unordered_map'}, # Not intended for embedded clients 'src/lib/support/jsontlv/JsonToTlv.cpp': {'sstream'}, diff --git a/scripts/tools/zap/tests/inputs/all-clusters-app.zap b/scripts/tools/zap/tests/inputs/all-clusters-app.zap index 1fbaef89d23d16..dda93888f29a16 100644 --- a/scripts/tools/zap/tests/inputs/all-clusters-app.zap +++ b/scripts/tools/zap/tests/inputs/all-clusters-app.zap @@ -12937,7 +12937,6 @@ "define": "ELECTRICAL_MEASUREMENT_CLUSTER", "side": "server", "enabled": 1, - "apiMaturity": "deprecated", "attributes": [ { "name": "measurement type", diff --git a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h index bf16ebb5941fa7..6985b44ac27da5 100644 --- a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h +++ b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h @@ -521,9 +521,9 @@ { ZAP_EMPTY_DEFAULT(), 0x00000007, 0, ZAP_TYPE(ARRAY), \ ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* ActiveNetworkFaults */ \ { ZAP_EMPTY_DEFAULT(), 0x00000008, 1, ZAP_TYPE(BOOLEAN), \ - ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* TestEventTriggersEnabled */ \ - { ZAP_SIMPLE_DEFAULT(0), 0x0000FFFC, 4, ZAP_TYPE(BITMAP32), 0 }, /* FeatureMap */ \ - { ZAP_SIMPLE_DEFAULT(1), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \ + ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* TestEventTriggersEnabled */ \ + { ZAP_EMPTY_DEFAULT(), 0x0000FFFC, 4, ZAP_TYPE(BITMAP32), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* FeatureMap */ \ + { ZAP_EMPTY_DEFAULT(), 0x0000FFFD, 2, ZAP_TYPE(INT16U), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Software Diagnostics (server) */ \ { ZAP_EMPTY_DEFAULT(), 0x00000000, 0, ZAP_TYPE(ARRAY), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* ThreadMetrics */ \ @@ -2162,7 +2162,7 @@ .clusterId = 0x00000033, \ .attributes = ZAP_ATTRIBUTE_INDEX(91), \ .attributeCount = 11, \ - .clusterSize = 6, \ + .clusterSize = 0, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ .functions = NULL, \ .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 40 ), \ @@ -3011,7 +3011,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 27, 341 }, { ZAP_CLUSTER_INDEX(27), 44, 3686 }, { ZAP_CLUSTER_INDEX(71), 7, 116 }, \ + { ZAP_CLUSTER_INDEX(0), 27, 335 }, { ZAP_CLUSTER_INDEX(27), 44, 3686 }, { ZAP_CLUSTER_INDEX(71), 7, 116 }, \ { ZAP_CLUSTER_INDEX(78), 2, 0 }, \ } @@ -3024,7 +3024,7 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, #define ATTRIBUTE_SINGLETONS_SIZE (37) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (4143) +#define ATTRIBUTE_MAX_SIZE (4137) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (4) diff --git a/scripts/tools/zap/tests/outputs/lighting-app/app-templates/endpoint_config.h b/scripts/tools/zap/tests/outputs/lighting-app/app-templates/endpoint_config.h index 89b62b8659fd2c..46990daf2555a6 100644 --- a/scripts/tools/zap/tests/outputs/lighting-app/app-templates/endpoint_config.h +++ b/scripts/tools/zap/tests/outputs/lighting-app/app-templates/endpoint_config.h @@ -220,9 +220,9 @@ { ZAP_EMPTY_DEFAULT(), 0x00000007, 0, ZAP_TYPE(ARRAY), \ ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* ActiveNetworkFaults */ \ { ZAP_EMPTY_DEFAULT(), 0x00000008, 1, ZAP_TYPE(BOOLEAN), \ - ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* TestEventTriggersEnabled */ \ - { ZAP_SIMPLE_DEFAULT(0), 0x0000FFFC, 4, ZAP_TYPE(BITMAP32), 0 }, /* FeatureMap */ \ - { ZAP_SIMPLE_DEFAULT(1), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \ + ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* TestEventTriggersEnabled */ \ + { ZAP_EMPTY_DEFAULT(), 0x0000FFFC, 4, ZAP_TYPE(BITMAP32), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* FeatureMap */ \ + { ZAP_EMPTY_DEFAULT(), 0x0000FFFD, 2, ZAP_TYPE(INT16U), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Software Diagnostics (server) */ \ { ZAP_EMPTY_DEFAULT(), 0x00000000, 0, ZAP_TYPE(ARRAY), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* ThreadMetrics */ \ @@ -912,7 +912,7 @@ .clusterId = 0x00000033, \ .attributes = ZAP_ATTRIBUTE_INDEX(72), \ .attributeCount = 11, \ - .clusterSize = 6, \ + .clusterSize = 0, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ .functions = NULL, \ .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 37 ), \ @@ -1150,7 +1150,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 22, 235 }, { ZAP_CLUSTER_INDEX(22), 7, 105 }, \ + { ZAP_CLUSTER_INDEX(0), 22, 229 }, { ZAP_CLUSTER_INDEX(22), 7, 105 }, \ } // Largest attribute size is needed for various buffers @@ -1162,7 +1162,7 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, #define ATTRIBUTE_SINGLETONS_SIZE (37) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (340) +#define ATTRIBUTE_MAX_SIZE (334) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (2) diff --git a/scripts/tools/zap/zap_execution.py b/scripts/tools/zap/zap_execution.py index fb4c9100bb63d1..685fbacdc366e2 100644 --- a/scripts/tools/zap/zap_execution.py +++ b/scripts/tools/zap/zap_execution.py @@ -23,7 +23,7 @@ # Use scripts/tools/zap/version_update.py to manage ZAP versioning as many # files may need updating for versions # -MIN_ZAP_VERSION = '2023.12.6' +MIN_ZAP_VERSION = '2024.1.5' class ZapTool: diff --git a/scripts/tools/zap_regen_all.py b/scripts/tools/zap_regen_all.py index 0b89b661ee31c5..ef950eb96fe94f 100755 --- a/scripts/tools/zap_regen_all.py +++ b/scripts/tools/zap_regen_all.py @@ -39,9 +39,6 @@ class TargetType(Flag): """Type of targets that can be re-generated""" - # Tests for golden images - TESTS = auto() - # Global templates: generally examples and chip controller GLOBAL = auto() @@ -56,11 +53,10 @@ class TargetType(Flag): GOLDEN_TEST_IMAGES = auto() # All possible targets. Convenience constant - ALL = TESTS | GLOBAL | IDL_CODEGEN | SPECIFIC | GOLDEN_TEST_IMAGES + ALL = GLOBAL | IDL_CODEGEN | SPECIFIC | GOLDEN_TEST_IMAGES __TARGET_TYPES__ = { - 'tests': TargetType.TESTS, 'global': TargetType.GLOBAL, 'idl_codegen': TargetType.IDL_CODEGEN, 'specific': TargetType.SPECIFIC, @@ -338,8 +334,6 @@ def setupArgumentsParser(): description='Generate content from ZAP files') parser.add_argument('--type', action='append', choices=__TARGET_TYPES__.keys(), help='Choose which content type to generate (default: all)') - parser.add_argument('--tests', default='all', choices=['all', 'darwin-framework-tool', 'app1', 'app2'], - help='When generating tests only target, Choose which tests to generate (default: all)') parser.add_argument('--dry-run', default=False, action='store_true', help="Don't do any generation, just log what targets would be generated (default: False)") parser.add_argument('--run-bootstrap', default=None, action='store_true', @@ -446,25 +440,6 @@ def getCodegenTemplates(): return targets -def getTestsTemplatesTargets(test_target): - zap_input = ZapInput.FromPropertiesJson('src/app/zap-templates/zcl/zcl.json') - templates = { - 'darwin-framework-tool': { - 'template': 'examples/darwin-framework-tool/templates/tests/templates.json', - 'output_dir': 'zzz_generated/darwin-framework-tool/zap-generated' - } - } - - targets = [] - for key, target in templates.items(): - if test_target == 'all' or test_target == key: - logging.info("Found test target %s (via %s)" % - (key, target['template'])) - targets.append(ZAPGenerateTarget(zap_input, template=target['template'], output_dir=target['output_dir'])) - - return targets - - def getGoldenTestImageTargets(): return [GoldenTestImageTarget()] @@ -491,12 +466,9 @@ def getSpecificTemplatesTargets(): return targets -def getTargets(type, test_target): +def getTargets(type): targets = [] - if type & TargetType.TESTS: - targets.extend(getTestsTemplatesTargets(test_target)) - if type & TargetType.GLOBAL: targets.extend(getGlobalTemplatesTargets()) @@ -549,7 +521,7 @@ def main(): os.chdir(CHIP_ROOT_DIR) args = setupArgumentsParser() - targets = getTargets(args.type, args.tests) + targets = getTargets(args.type) if args.dry_run: sys.exit(0) diff --git a/src/BUILD.gn b/src/BUILD.gn index ee3fd4d9c7a2ba..0588e897685fdd 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -43,9 +43,6 @@ config("includes") { include_dirs += [ "${chip_external_platform_include_dir}" ] } - # TODO: generated file dependency should be a lib NOT an include - include_dirs += [ "${chip_root}/zzz_generated/app-common" ] - defines = [ "CHIP_HAVE_CONFIG_H=1" ] # Make __FILE__ and related macros relative to chip_root diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index 12be70af10e867..84540e97892e6a 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -104,113 +104,12 @@ source_set("global-attributes") { ] } -source_set("pre-encoded-value") { - sources = [ - "data-model/FabricScopedPreEncodedValue.cpp", - "data-model/FabricScopedPreEncodedValue.h", - "data-model/PreEncodedValue.cpp", - "data-model/PreEncodedValue.h", - ] - - deps = [ - "${chip_root}/src/lib/core", - "${chip_root}/src/lib/support", - ] -} - source_set("subscription-manager") { sources = [ "SubscriptionsInfoProvider.h" ] public_deps = [ "${chip_root}/src/lib/core" ] } -source_set("message-def") { - sources = [ - "MessageDef/ArrayBuilder.cpp", - "MessageDef/ArrayParser.cpp", - "MessageDef/AttributeDataIB.cpp", - "MessageDef/AttributeDataIB.h", - "MessageDef/AttributeDataIBs.cpp", - "MessageDef/AttributeDataIBs.h", - "MessageDef/AttributePathIB.cpp", - "MessageDef/AttributePathIB.h", - "MessageDef/AttributePathIBs.cpp", - "MessageDef/AttributePathIBs.h", - "MessageDef/AttributeReportIB.cpp", - "MessageDef/AttributeReportIB.h", - "MessageDef/AttributeReportIBs.cpp", - "MessageDef/AttributeReportIBs.h", - "MessageDef/AttributeStatusIB.cpp", - "MessageDef/AttributeStatusIB.h", - "MessageDef/AttributeStatusIBs.cpp", - "MessageDef/AttributeStatusIBs.h", - "MessageDef/Builder.cpp", - "MessageDef/Builder.h", - "MessageDef/ClusterPathIB.cpp", - "MessageDef/ClusterPathIB.h", - "MessageDef/CommandDataIB.cpp", - "MessageDef/CommandPathIB.cpp", - "MessageDef/CommandStatusIB.cpp", - "MessageDef/DataVersionFilterIB.cpp", - "MessageDef/DataVersionFilterIB.h", - "MessageDef/DataVersionFilterIBs.cpp", - "MessageDef/DataVersionFilterIBs.h", - "MessageDef/EventDataIB.cpp", - "MessageDef/EventDataIB.h", - "MessageDef/EventFilterIB.cpp", - "MessageDef/EventFilterIBs.cpp", - "MessageDef/EventPathIB.cpp", - "MessageDef/EventPathIB.h", - "MessageDef/EventPathIBs.cpp", - "MessageDef/EventPathIBs.h", - "MessageDef/EventReportIB.cpp", - "MessageDef/EventReportIB.h", - "MessageDef/EventReportIBs.cpp", - "MessageDef/EventReportIBs.h", - "MessageDef/EventStatusIB.cpp", - "MessageDef/EventStatusIB.h", - "MessageDef/InvokeRequestMessage.cpp", - "MessageDef/InvokeRequests.cpp", - "MessageDef/InvokeResponseIB.cpp", - "MessageDef/InvokeResponseIBs.cpp", - "MessageDef/InvokeResponseMessage.cpp", - "MessageDef/ListBuilder.cpp", - "MessageDef/ListParser.cpp", - "MessageDef/MessageBuilder.cpp", - "MessageDef/MessageBuilder.h", - "MessageDef/MessageDefHelper.cpp", - "MessageDef/MessageDefHelper.h", - "MessageDef/MessageParser.cpp", - "MessageDef/MessageParser.h", - "MessageDef/Parser.cpp", - "MessageDef/Parser.h", - "MessageDef/ReadRequestMessage.cpp", - "MessageDef/ReadRequestMessage.h", - "MessageDef/ReportDataMessage.cpp", - "MessageDef/ReportDataMessage.h", - "MessageDef/StatusIB.cpp", - "MessageDef/StatusIB.h", - "MessageDef/StatusResponseMessage.cpp", - "MessageDef/StructBuilder.cpp", - "MessageDef/StructParser.cpp", - "MessageDef/SubscribeRequestMessage.cpp", - "MessageDef/SubscribeResponseMessage.cpp", - "MessageDef/TimedRequestMessage.cpp", - "MessageDef/WriteRequestMessage.cpp", - "MessageDef/WriteResponseMessage.cpp", - ] - - deps = [ - ":app_config", - ":paths", - ":revision_info", - "${chip_root}/src/lib/core", - "${chip_root}/src/lib/support", - "${chip_root}/src/protocols/interaction_model", - "${chip_root}/src/protocols/secure_channel", - ] -} - config("config-controller-dynamic-server") { defines = [ "CHIP_CONFIG_SKIP_APP_SPECIFIC_GENERATED_HEADER_INCLUDES=1", @@ -255,9 +154,9 @@ static_library("interaction-model") { public_deps = [ ":app_config", - ":message-def", ":paths", ":subscription-manager", + "${chip_root}/src/app/MessageDef", "${chip_root}/src/app/icd/server:icd-server-config", "${chip_root}/src/app/icd/server:observer", "${chip_root}/src/lib/address_resolve", @@ -335,8 +234,8 @@ static_library("app") { ":app_config", ":global-attributes", ":interaction-model", - ":pre-encoded-value", ":revision_info", + "${chip_root}/src/app/data-model", "${chip_root}/src/app/icd/server:icd-server-config", "${chip_root}/src/lib/address_resolve", "${chip_root}/src/lib/support", diff --git a/src/app/CommandSender.cpp b/src/app/CommandSender.cpp index 1066ca92825891..56399f8d3312bb 100644 --- a/src/app/CommandSender.cpp +++ b/src/app/CommandSender.cpp @@ -224,6 +224,7 @@ CHIP_ERROR CommandSender::OnMessageReceived(Messaging::ExchangeContext * apExcha { err = ProcessInvokeResponse(std::move(aPayload), moreChunkedMessages); SuccessOrExit(err); + mInvokeResponseMessageCount++; if (moreChunkedMessages) { StatusResponse::Send(Status::Success, apExchangeContext, /*aExpectResponse = */ true); @@ -534,6 +535,11 @@ CHIP_ERROR CommandSender::FinishCommand(const Optional & aTimedInvokeT return CHIP_NO_ERROR; } +size_t CommandSender::GetInvokeResponseMessageCount() +{ + return static_cast(mInvokeResponseMessageCount); +} + CHIP_ERROR CommandSender::Finalize(System::PacketBufferHandle & commandPacket) { VerifyOrReturnError(mState == State::AddedCommand, CHIP_ERROR_INCORRECT_STATE); diff --git a/src/app/CommandSender.h b/src/app/CommandSender.h index 76374416886e9b..08d518f5dbc843 100644 --- a/src/app/CommandSender.h +++ b/src/app/CommandSender.h @@ -318,6 +318,14 @@ class CommandSender final : public Messaging::ExchangeDelegate return FinishCommand(aTimedInvokeTimeoutMs, optionalArgs); } + /** + * @brief Returns the number of InvokeResponseMessages received. + * + * Responses to multiple requests might be split across several InvokeResponseMessages. + * This function helps track the total count. Primarily for test validation purposes. + */ + size_t GetInvokeResponseMessageCount(); + #if CONFIG_BUILD_FOR_HOST_UNIT_TEST /** * Version of AddRequestData that allows sending a message that is @@ -507,8 +515,10 @@ class CommandSender final : public Messaging::ExchangeDelegate TLV::TLVType mDataElementContainerType = TLV::kTLVType_NotSpecified; chip::System::PacketBufferTLVWriter mCommandMessageWriter; - uint16_t mFinishedCommandCount = 0; - uint16_t mRemoteMaxPathsPerInvoke = 1; + + uint16_t mInvokeResponseMessageCount = 0; + uint16_t mFinishedCommandCount = 0; + uint16_t mRemoteMaxPathsPerInvoke = 1; State mState = State::Idle; bool mSuppressResponse = false; diff --git a/src/app/EventManagement.cpp b/src/app/EventManagement.cpp index 7713ba18f3e468..aa3abd67f828d8 100644 --- a/src/app/EventManagement.cpp +++ b/src/app/EventManagement.cpp @@ -413,6 +413,7 @@ void EventManagement::VendEventNumber() CHIP_ERROR EventManagement::LogEvent(EventLoggingDelegate * apDelegate, const EventOptions & aEventOptions, EventNumber & aEventNumber) { + assertChipStackLockedByCurrentThread(); VerifyOrReturnError(mState != EventManagementStates::Shutdown, CHIP_ERROR_INCORRECT_STATE); return LogEventPrivate(apDelegate, aEventOptions, aEventNumber); } diff --git a/src/app/MessageDef/BUILD.gn b/src/app/MessageDef/BUILD.gn new file mode 100644 index 00000000000000..4880a9a8b126e4 --- /dev/null +++ b/src/app/MessageDef/BUILD.gn @@ -0,0 +1,123 @@ +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import("//build_overrides/chip.gni") + +source_set("MessageDef") { + sources = [ + "ArrayBuilder.cpp", + "ArrayBuilder.h", + "ArrayParser.cpp", + "ArrayParser.h", + "AttributeDataIB.cpp", + "AttributeDataIB.h", + "AttributeDataIBs.cpp", + "AttributeDataIBs.h", + "AttributePathIB.cpp", + "AttributePathIB.h", + "AttributePathIBs.cpp", + "AttributePathIBs.h", + "AttributeReportIB.cpp", + "AttributeReportIB.h", + "AttributeReportIBs.cpp", + "AttributeReportIBs.h", + "AttributeStatusIB.cpp", + "AttributeStatusIB.h", + "AttributeStatusIBs.cpp", + "AttributeStatusIBs.h", + "Builder.cpp", + "Builder.h", + "ClusterPathIB.cpp", + "ClusterPathIB.h", + "CommandDataIB.cpp", + "CommandDataIB.h", + "CommandPathIB.cpp", + "CommandPathIB.h", + "CommandStatusIB.cpp", + "CommandStatusIB.h", + "DataVersionFilterIB.cpp", + "DataVersionFilterIB.h", + "DataVersionFilterIBs.cpp", + "DataVersionFilterIBs.h", + "EventDataIB.cpp", + "EventDataIB.h", + "EventFilterIB.cpp", + "EventFilterIB.h", + "EventFilterIBs.cpp", + "EventFilterIBs.h", + "EventPathIB.cpp", + "EventPathIB.h", + "EventPathIBs.cpp", + "EventPathIBs.h", + "EventReportIB.cpp", + "EventReportIB.h", + "EventReportIBs.cpp", + "EventReportIBs.h", + "EventStatusIB.cpp", + "EventStatusIB.h", + "InvokeRequestMessage.cpp", + "InvokeRequestMessage.h", + "InvokeRequests.cpp", + "InvokeRequests.h", + "InvokeResponseIB.cpp", + "InvokeResponseIB.h", + "InvokeResponseIBs.cpp", + "InvokeResponseIBs.h", + "InvokeResponseMessage.cpp", + "InvokeResponseMessage.h", + "ListBuilder.cpp", + "ListBuilder.h", + "ListParser.cpp", + "ListParser.h", + "MessageBuilder.cpp", + "MessageBuilder.h", + "MessageDefHelper.cpp", + "MessageDefHelper.h", + "MessageParser.cpp", + "MessageParser.h", + "Parser.cpp", + "Parser.h", + "ReadRequestMessage.cpp", + "ReadRequestMessage.h", + "ReportDataMessage.cpp", + "ReportDataMessage.h", + "StatusIB.cpp", + "StatusIB.h", + "StatusResponseMessage.cpp", + "StatusResponseMessage.h", + "StructBuilder.cpp", + "StructBuilder.h", + "StructParser.cpp", + "StructParser.h", + "SubscribeRequestMessage.cpp", + "SubscribeRequestMessage.h", + "SubscribeResponseMessage.cpp", + "SubscribeResponseMessage.h", + "TimedRequestMessage.cpp", + "TimedRequestMessage.h", + "WriteRequestMessage.cpp", + "WriteRequestMessage.h", + "WriteResponseMessage.cpp", + "WriteResponseMessage.h", + ] + + deps = [ + "${chip_root}/src/app:app_config", + "${chip_root}/src/app:paths", + "${chip_root}/src/app:revision_info", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + "${chip_root}/src/protocols/interaction_model", + "${chip_root}/src/protocols/secure_channel", + ] +} diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp index bd63503a10493f..b5fc34484ea8ff 100644 --- a/src/app/ReadHandler.cpp +++ b/src/app/ReadHandler.cpp @@ -46,7 +46,7 @@ using Status = Protocols::InteractionModel::Status; uint16_t ReadHandler::GetPublisherSelectedIntervalLimit() { #if CHIP_CONFIG_ENABLE_ICD_SERVER - return static_cast(ICDConfigurationData::GetInstance().GetIdleModeDurationSec()); + return std::chrono::duration_cast(ICDConfigurationData::GetInstance().GetIdleModeDuration()).count(); #else return kSubscriptionMaxIntervalPublisherLimit; #endif diff --git a/src/app/SubscriptionsInfoProvider.h b/src/app/SubscriptionsInfoProvider.h index ef792904fc4bce..cb8d470cbb234d 100644 --- a/src/app/SubscriptionsInfoProvider.h +++ b/src/app/SubscriptionsInfoProvider.h @@ -42,6 +42,7 @@ class SubscriptionsInfoProvider * * @param[in] aFabricIndex fabric index of the subject * @param[in] subjectID NodeId of the subject + * subjectID may encode a CAT in the reserved section of the NodeID. * * @return true subject has at least one active subscription with the device * false subject doesn't have any active subscription with the device @@ -54,6 +55,7 @@ class SubscriptionsInfoProvider * * @param[in] aFabricIndex fabric index of the subject * @param[in] subjectID NodeId of the subject + * subjectID may encode a CAT in the reserved section of the NodeID * * @return true subject has at least one persisted subscription with the device * false subject doesn't have any persisted subscription with the device diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index aede00f0e12115..bc6c48df53d742 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -376,6 +376,7 @@ template("chip_data_model") { ":${_data_model_name}_zapgen", "${chip_root}/src/app", "${chip_root}/src/app/common:cluster-objects", + "${chip_root}/src/app/common:enums", "${chip_root}/src/controller", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", diff --git a/src/app/clusters/door-lock-server/door-lock-server.cpp b/src/app/clusters/door-lock-server/door-lock-server.cpp index 5b975d5d88262c..b4df96a8e50f4c 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.cpp +++ b/src/app/clusters/door-lock-server/door-lock-server.cpp @@ -44,8 +44,9 @@ using namespace chip::app::Clusters::DoorLock; using namespace chip::app::Clusters::DoorLock::Attributes; using chip::Protocols::InteractionModel::Status; -static constexpr uint8_t DOOR_LOCK_SCHEDULE_MAX_HOUR = 23; -static constexpr uint8_t DOOR_LOCK_SCHEDULE_MAX_MINUTE = 59; +static constexpr uint8_t DOOR_LOCK_SCHEDULE_MAX_HOUR = 23; +static constexpr uint8_t DOOR_LOCK_SCHEDULE_MAX_MINUTE = 59; +static constexpr uint8_t DOOR_LOCK_ALIRO_CREDENTIAL_SIZE = 65; static constexpr uint32_t DOOR_LOCK_MAX_LOCK_TIMEOUT_SEC = MAX_INT32U_VALUE / MILLISECOND_TICKS_PER_SECOND; @@ -1556,6 +1557,11 @@ DlStatus DoorLockServer::credentialLengthWithinRange(chip::EndpointId endpointId case CredentialTypeEnum::kFace: statusMin = statusMax = emberAfPluginDoorLockGetFaceCredentialLengthConstraints(endpointId, minLen, maxLen); break; + case CredentialTypeEnum::kAliroCredentialIssuerKey: + case CredentialTypeEnum::kAliroEvictableEndpointKey: + case CredentialTypeEnum::kAliroNonEvictableEndpointKey: + minLen = maxLen = DOOR_LOCK_ALIRO_CREDENTIAL_SIZE; + break; default: return DlStatus::kFailure; } @@ -2555,6 +2561,10 @@ bool DoorLockServer::credentialTypeSupported(chip::EndpointId endpointId, Creden return SupportsFingers(endpointId); case CredentialTypeEnum::kFace: return SupportsFace(endpointId); + case CredentialTypeEnum::kAliroEvictableEndpointKey: + case CredentialTypeEnum::kAliroCredentialIssuerKey: + case CredentialTypeEnum::kAliroNonEvictableEndpointKey: + return SupportsAliroProvisioning(endpointId); default: return false; } diff --git a/src/app/clusters/door-lock-server/door-lock-server.h b/src/app/clusters/door-lock-server/door-lock-server.h index 675a1450baf28a..6f25cd507621bf 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.h +++ b/src/app/clusters/door-lock-server/door-lock-server.h @@ -87,6 +87,18 @@ struct EmberAfDoorLockEndpointContext int wrongCodeEntryAttempts; }; +namespace chip { +namespace app { +namespace Clusters { +namespace DoorLock { + +void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate); + +} // namespace DoorLock +} // namespace Clusters +} // namespace app +} // namespace chip + /** * @brief Door Lock Server Plugin class. */ @@ -190,7 +202,8 @@ class DoorLockServer : public chip::app::AttributeAccessInterface inline bool SupportsAnyCredential(chip::EndpointId endpointId) { return GetFeatures(endpointId) - .HasAny(Feature::kPinCredential, Feature::kRfidCredential, Feature::kFingerCredentials, Feature::kFaceCredentials); + .HasAny(Feature::kPinCredential, Feature::kRfidCredential, Feature::kFingerCredentials, Feature::kFaceCredentials, + Feature::kAliroProvisioning); } inline bool SupportsCredentialsOTA(chip::EndpointId endpointId) @@ -723,9 +736,9 @@ enum class DlAssetSource : uint8_t */ struct EmberAfPluginDoorLockCredentialInfo { - DlCredentialStatus status; /**< Indicates if credential slot is occupied or not. */ - CredentialTypeEnum credentialType; /**< Specifies the type of the credential (PIN, RFID, etc.). */ - chip::ByteSpan credentialData; /**< Credential data bytes. */ + DlCredentialStatus status = DlCredentialStatus::kAvailable; /**< Indicates if credential slot is occupied or not. */ + CredentialTypeEnum credentialType; /**< Specifies the type of the credential (PIN, RFID, etc.). */ + chip::ByteSpan credentialData; /**< Credential data bytes. */ DlAssetSource creationSource; chip::FabricIndex createdBy; /**< Index of the fabric that created the user. */ diff --git a/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp b/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp index 728b41dee02f74..38911ff7e54358 100644 --- a/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp +++ b/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp @@ -26,25 +26,28 @@ using chip::Protocols::InteractionModel::Status; -namespace { +namespace chip { +namespace app { +namespace Clusters { +namespace ElectricalEnergyMeasurement { using namespace chip; -using namespace chip::app::Clusters::ElectricalEnergyMeasurement; using namespace chip::app::Clusters::ElectricalEnergyMeasurement::Attributes; using namespace chip::app::Clusters::ElectricalEnergyMeasurement::Structs; MeasurementData gMeasurements[EMBER_AF_ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT]; -class ElectricalEnergyMeasurementAttrAccess : public app::AttributeAccessInterface +CHIP_ERROR ElectricalEnergyMeasurementAttrAccess::Init() { -public: - ElectricalEnergyMeasurementAttrAccess() : - app::AttributeAccessInterface(Optional::Missing(), app::Clusters::ElectricalEnergyMeasurement::Id) - {} + VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + return CHIP_NO_ERROR; +} - CHIP_ERROR Read(const app::ConcreteReadAttributePath & aPath, app::AttributeValueEncoder & aEncoder) override; -}; +void ElectricalEnergyMeasurementAttrAccess::Shutdown() +{ + unregisterAttributeAccessOverride(this); +} CHIP_ERROR ElectricalEnergyMeasurementAttrAccess::Read(const app::ConcreteReadAttributePath & aPath, app::AttributeValueEncoder & aEncoder) @@ -55,6 +58,9 @@ CHIP_ERROR ElectricalEnergyMeasurementAttrAccess::Read(const app::ConcreteReadAt switch (aPath.mAttributeId) { + case FeatureMap::Id: + ReturnErrorOnFailure(aEncoder.Encode(mFeature)); + break; case Accuracy::Id: if (data == nullptr) { @@ -62,42 +68,77 @@ CHIP_ERROR ElectricalEnergyMeasurementAttrAccess::Read(const app::ConcreteReadAt } return aEncoder.Encode(data->measurementAccuracy); case CumulativeEnergyImported::Id: + VerifyOrReturnError( + HasFeature(ElectricalEnergyMeasurement::Feature::kCumulativeEnergy) && + HasFeature(ElectricalEnergyMeasurement::Feature::kImportedEnergy), + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Energy Measurement: can not get CumulativeEnergyImported, feature is not supported")); if ((data == nullptr) || !data->cumulativeImported.HasValue()) { return aEncoder.EncodeNull(); } return aEncoder.Encode(data->cumulativeImported.Value()); case CumulativeEnergyExported::Id: + VerifyOrReturnError( + HasFeature(ElectricalEnergyMeasurement::Feature::kCumulativeEnergy) && + HasFeature(ElectricalEnergyMeasurement::Feature::kExportedEnergy), + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Energy Measurement: can not get CumulativeEnergyExported, feature is not supported")); if ((data == nullptr) || !data->cumulativeExported.HasValue()) { return aEncoder.EncodeNull(); } return aEncoder.Encode(data->cumulativeExported.Value()); case PeriodicEnergyImported::Id: + VerifyOrReturnError( + HasFeature(ElectricalEnergyMeasurement::Feature::kPeriodicEnergy) && + HasFeature(ElectricalEnergyMeasurement::Feature::kImportedEnergy), + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Energy Measurement: can not get PeriodicEnergyImported, feature is not supported")); if ((data == nullptr) || !data->periodicImported.HasValue()) { return aEncoder.EncodeNull(); } return aEncoder.Encode(data->periodicImported.Value()); case PeriodicEnergyExported::Id: + VerifyOrReturnError( + HasFeature(ElectricalEnergyMeasurement::Feature::kPeriodicEnergy) && + HasFeature(ElectricalEnergyMeasurement::Feature::kExportedEnergy), + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Energy Measurement: can not get PeriodicEnergyExported, feature is not supported")); if ((data == nullptr) || !data->periodicExported.HasValue()) { return aEncoder.EncodeNull(); } return aEncoder.Encode(data->periodicExported.Value()); + case CumulativeEnergyReset::Id: + VerifyOrReturnError( + HasFeature(ElectricalEnergyMeasurement::Feature::kCumulativeEnergy), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Energy Measurement: can not get CumulativeEnergyReset, feature is not supported")); + + if (!SupportsOptAttr(OptionalAttributes::kOptionalAttributeCumulativeEnergyReset)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + if ((data == nullptr) || !data->cumulativeReset.HasValue()) + { + return aEncoder.EncodeNull(); + } + return aEncoder.Encode(data->cumulativeReset.Value()); } return CHIP_NO_ERROR; } -ElectricalEnergyMeasurementAttrAccess gAttrAccess; - -} // namespace +bool ElectricalEnergyMeasurementAttrAccess::HasFeature(Feature aFeature) const +{ + return mFeature.Has(aFeature); +} -namespace chip { -namespace app { -namespace Clusters { -namespace ElectricalEnergyMeasurement { +bool ElectricalEnergyMeasurementAttrAccess::SupportsOptAttr(OptionalAttributes aOptionalAttrs) const +{ + return mOptionalAttrs.Has(aOptionalAttrs); +} MeasurementData * MeasurementDataForEndpoint(EndpointId endpointId) { @@ -130,6 +171,19 @@ CHIP_ERROR SetMeasurementAccuracy(EndpointId endpointId, const MeasurementAccura return CHIP_NO_ERROR; } +CHIP_ERROR SetCumulativeReset(EndpointId endpointId, const Optional & cumulativeReset) +{ + + MeasurementData * data = MeasurementDataForEndpoint(endpointId); + VerifyOrReturnError(data != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + + data->cumulativeReset = cumulativeReset; + + MatterReportingAttributeChangeCallback(endpointId, ElectricalEnergyMeasurement::Id, CumulativeEnergyReset::Id); + + return CHIP_NO_ERROR; +} + bool NotifyCumulativeEnergyMeasured(EndpointId endpointId, const Optional & energyImported, const Optional & energyExported) { @@ -192,8 +246,3 @@ bool NotifyPeriodicEnergyMeasured(EndpointId endpointId, const Optional #include +#include namespace chip { namespace app { @@ -33,6 +34,35 @@ struct MeasurementData Optional cumulativeExported; Optional periodicImported; Optional periodicExported; + Optional cumulativeReset; +}; + +enum class OptionalAttributes : uint32_t +{ + kOptionalAttributeCumulativeEnergyReset = 0x1, +}; + +class ElectricalEnergyMeasurementAttrAccess : public AttributeAccessInterface +{ +public: + ElectricalEnergyMeasurementAttrAccess(BitMask aFeature, BitMask aOptionalAttrs) : + app::AttributeAccessInterface(Optional::Missing(), app::Clusters::ElectricalEnergyMeasurement::Id), + mFeature(aFeature), mOptionalAttrs(aOptionalAttrs) + {} + + ~ElectricalEnergyMeasurementAttrAccess() { Shutdown(); } + + CHIP_ERROR Init(); + void Shutdown(); + + CHIP_ERROR Read(const app::ConcreteReadAttributePath & aPath, app::AttributeValueEncoder & aEncoder) override; + + bool HasFeature(Feature aFeature) const; + bool SupportsOptAttr(OptionalAttributes aOptionalAttrs) const; + +private: + BitMask mFeature; + BitMask mOptionalAttrs; }; bool NotifyCumulativeEnergyMeasured(EndpointId endpointId, const Optional & energyImported, @@ -43,6 +73,8 @@ bool NotifyPeriodicEnergyMeasured(EndpointId endpointId, const Optional & cumulativeReset); + MeasurementData * MeasurementDataForEndpoint(EndpointId endpointId); } // namespace ElectricalEnergyMeasurement diff --git a/src/app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.cpp b/src/app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.cpp new file mode 100644 index 00000000000000..1b248310a686ef --- /dev/null +++ b/src/app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.cpp @@ -0,0 +1,318 @@ +/* + * + * Copyright (c) 2024 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 "electrical-power-measurement-server.h" + +#include + +#include +#include +#include +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::DataModel; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::ElectricalPowerMeasurement; +using namespace chip::app::Clusters::ElectricalPowerMeasurement::Attributes; +using namespace chip::app::Clusters::ElectricalPowerMeasurement::Structs; + +using chip::Protocols::InteractionModel::Status; + +namespace chip { +namespace app { +namespace Clusters { +namespace ElectricalPowerMeasurement { + +CHIP_ERROR Instance::Init() +{ + VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + return CHIP_NO_ERROR; +} + +void Instance::Shutdown() +{ + unregisterAttributeAccessOverride(this); +} + +bool Instance::HasFeature(Feature aFeature) const +{ + return mFeature.Has(aFeature); +} + +bool Instance::SupportsOptAttr(OptionalAttributes aOptionalAttrs) const +{ + return mOptionalAttrs.Has(aOptionalAttrs); +} + +// AttributeAccessInterface +CHIP_ERROR Instance::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) +{ + switch (aPath.mAttributeId) + { + case FeatureMap::Id: + ReturnErrorOnFailure(aEncoder.Encode(mFeature)); + break; + case PowerMode::Id: + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetPowerMode())); + break; + case NumberOfMeasurementTypes::Id: + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetNumberOfMeasurementTypes())); + break; + case Accuracy::Id: + return ReadAccuracy(aEncoder); + case Ranges::Id: + return ReadRanges(aEncoder); + case Voltage::Id: + if (!SupportsOptAttr(OptionalAttributes::kOptionalAttributeVoltage)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetVoltage())); + break; + case ActiveCurrent::Id: + if (!SupportsOptAttr(OptionalAttributes::kOptionalAttributeActiveCurrent)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetActiveCurrent())); + break; + case ReactiveCurrent::Id: + if (!SupportsOptAttr(OptionalAttributes::kOptionalAttributeReactiveCurrent)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + VerifyOrReturnError( + HasFeature(ElectricalPowerMeasurement::Feature::kAlternatingCurrent), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Power Measurement: can not get ReactiveCurrent, feature is not supported")); + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetReactiveCurrent())); + break; + case ApparentCurrent::Id: + if (!SupportsOptAttr(OptionalAttributes::kOptionalAttributeApparentCurrent)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + VerifyOrReturnError( + HasFeature(ElectricalPowerMeasurement::Feature::kAlternatingCurrent), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Power Measurement: can not get ApparentCurrent, feature is not supported")); + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetApparentCurrent())); + break; + case ActivePower::Id: + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetActivePower())); + break; + case ReactivePower::Id: + if (!SupportsOptAttr(OptionalAttributes::kOptionalAttributeReactivePower)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + VerifyOrReturnError(HasFeature(ElectricalPowerMeasurement::Feature::kAlternatingCurrent), + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Power Measurement: can not get ReactivePower, feature is not supported")); + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetReactivePower())); + break; + case ApparentPower::Id: + if (!SupportsOptAttr(OptionalAttributes::kOptionalAttributeApparentPower)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + VerifyOrReturnError(HasFeature(ElectricalPowerMeasurement::Feature::kAlternatingCurrent), + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Power Measurement: can not get ApparentPower, feature is not supported")); + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetApparentPower())); + break; + case RMSVoltage::Id: + if (!SupportsOptAttr(OptionalAttributes::kOptionalAttributeRMSVoltage)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + VerifyOrReturnError(HasFeature(ElectricalPowerMeasurement::Feature::kAlternatingCurrent), + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Power Measurement: can not get RMSVoltage, feature is not supported")); + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetRMSVoltage())); + break; + case RMSCurrent::Id: + if (!SupportsOptAttr(OptionalAttributes::kOptionalAttributeRMSCurrent)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + VerifyOrReturnError(HasFeature(ElectricalPowerMeasurement::Feature::kAlternatingCurrent), + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Power Measurement: can not get RMSCurrent, feature is not supported")); + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetRMSCurrent())); + break; + case RMSPower::Id: + if (!SupportsOptAttr(OptionalAttributes::kOptionalAttributeRMSPower)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + VerifyOrReturnError(HasFeature(ElectricalPowerMeasurement::Feature::kAlternatingCurrent), + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Power Measurement: can not get RMSPower, feature is not supported")); + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetRMSPower())); + break; + case Frequency::Id: + if (!SupportsOptAttr(OptionalAttributes::kOptionalAttributeFrequency)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + VerifyOrReturnError(HasFeature(ElectricalPowerMeasurement::Feature::kAlternatingCurrent), + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Power Measurement: can not get Frequency, feature is not supported")); + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetFrequency())); + break; + case HarmonicCurrents::Id: + return ReadHarmonicCurrents(aEncoder); + case HarmonicPhases::Id: + return ReadHarmonicPhases(aEncoder); + case PowerFactor::Id: + if (!SupportsOptAttr(OptionalAttributes::kOptionalAttributePowerFactor)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + VerifyOrReturnError(HasFeature(ElectricalPowerMeasurement::Feature::kAlternatingCurrent), + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Power Measurement: can not get PowerFactor, feature is not supported")); + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetPowerFactor())); + break; + case NeutralCurrent::Id: + if (!SupportsOptAttr(OptionalAttributes::kOptionalAttributeNeutralCurrent)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + VerifyOrReturnError( + HasFeature(ElectricalPowerMeasurement::Feature::kPolyphasePower), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Power Measurement: can not get NeutralCurrent, feature is not supported")); + ReturnErrorOnFailure(aEncoder.Encode(mDelegate.GetNeutralCurrent())); + break; + } + return CHIP_NO_ERROR; +} + +CHIP_ERROR Instance::ReadAccuracy(AttributeValueEncoder & aEncoder) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + auto accuracies = mDelegate.IterateAccuracy(); + VerifyOrReturnError(accuracies != nullptr, CHIP_IM_GLOBAL_STATUS(ResourceExhausted)); + if (accuracies->Count() == 0) + { + err = aEncoder.EncodeEmptyList(); + } + else + { + err = aEncoder.EncodeList([&accuracies](const auto & encoder) -> CHIP_ERROR { + Structs::MeasurementAccuracyStruct::Type accuracy; + while (accuracies->Next(accuracy)) + { + encoder.Encode(accuracy); + } + + return CHIP_NO_ERROR; + }); + } + accuracies->Release(); + return err; +} + +CHIP_ERROR Instance::ReadRanges(AttributeValueEncoder & aEncoder) +{ + if (!SupportsOptAttr(OptionalAttributes::kOptionalAttributeRanges)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + CHIP_ERROR err = CHIP_NO_ERROR; + auto ranges = mDelegate.IterateRanges(); + VerifyOrReturnError(ranges != nullptr, CHIP_IM_GLOBAL_STATUS(ResourceExhausted)); + if (ranges->Count() == 0) + { + err = aEncoder.EncodeEmptyList(); + } + else + { + err = aEncoder.EncodeList([&ranges](const auto & encoder) -> CHIP_ERROR { + Structs::MeasurementRangeStruct::Type range; + while (ranges->Next(range)) + { + encoder.Encode(range); + } + + return CHIP_NO_ERROR; + }); + } + ranges->Release(); + return err; +} + +CHIP_ERROR Instance::ReadHarmonicCurrents(AttributeValueEncoder & aEncoder) +{ + VerifyOrReturnError(HasFeature(ElectricalPowerMeasurement::Feature::kHarmonics), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Power Measurement: can not get HarmonicCurrents, feature is not supported")); + + CHIP_ERROR err = CHIP_NO_ERROR; + auto currents = mDelegate.IterateHarmonicCurrents(); + VerifyOrReturnError(currents != nullptr, CHIP_IM_GLOBAL_STATUS(ResourceExhausted)); + if (currents->Count() == 0) + { + err = aEncoder.EncodeEmptyList(); + } + else + { + err = aEncoder.EncodeList([¤ts](const auto & encoder) -> CHIP_ERROR { + Structs::HarmonicMeasurementStruct::Type current; + while (currents->Next(current)) + { + encoder.Encode(current); + } + + return CHIP_NO_ERROR; + }); + } + currents->Release(); + return err; +} + +CHIP_ERROR Instance::ReadHarmonicPhases(AttributeValueEncoder & aEncoder) +{ + VerifyOrReturnError(HasFeature(ElectricalPowerMeasurement::Feature::kPowerQuality), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, + ChipLogError(Zcl, "Electrical Power Measurement: can not get HarmonicPhases, feature is not supported")); + CHIP_ERROR err = CHIP_NO_ERROR; + auto phases = mDelegate.IterateHarmonicPhases(); + VerifyOrReturnError(phases != nullptr, CHIP_IM_GLOBAL_STATUS(ResourceExhausted)); + if (phases->Count() == 0) + { + err = aEncoder.EncodeEmptyList(); + } + else + { + err = aEncoder.EncodeList([&phases](const auto & encoder) -> CHIP_ERROR { + Structs::HarmonicMeasurementStruct::Type phase; + while (phases->Next(phase)) + { + encoder.Encode(phase); + } + + return CHIP_NO_ERROR; + }); + } + phases->Release(); + return err; +} + +} // namespace ElectricalPowerMeasurement +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.h b/src/app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.h new file mode 100644 index 00000000000000..dff7b44b1d13a4 --- /dev/null +++ b/src/app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.h @@ -0,0 +1,124 @@ +/* + * + * Copyright (c) 2024 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 ElectricalPowerMeasurement { + +using namespace chip::app::Clusters::ElectricalPowerMeasurement::Attributes; +using namespace chip::app::Clusters::ElectricalPowerMeasurement::Structs; + +using chip::Protocols::InteractionModel::Status; + +class Delegate +{ +public: + virtual ~Delegate() = default; + + void SetEndpointId(EndpointId aEndpoint) { mEndpointId = aEndpoint; } + + using AccuracyIterator = CommonIterator; + using RangeIterator = CommonIterator; + using HarmonicMeasurementIterator = CommonIterator; + + virtual PowerModeEnum GetPowerMode() = 0; + virtual uint8_t GetNumberOfMeasurementTypes() = 0; + virtual AccuracyIterator * IterateAccuracy() = 0; + virtual RangeIterator * IterateRanges() = 0; + virtual DataModel::Nullable GetVoltage() = 0; + virtual DataModel::Nullable GetActiveCurrent() = 0; + virtual DataModel::Nullable GetReactiveCurrent() = 0; + virtual DataModel::Nullable GetApparentCurrent() = 0; + virtual DataModel::Nullable GetActivePower() = 0; + virtual DataModel::Nullable GetReactivePower() = 0; + virtual DataModel::Nullable GetApparentPower() = 0; + virtual DataModel::Nullable GetRMSVoltage() = 0; + virtual DataModel::Nullable GetRMSCurrent() = 0; + virtual DataModel::Nullable GetRMSPower() = 0; + virtual DataModel::Nullable GetFrequency() = 0; + virtual HarmonicMeasurementIterator * IterateHarmonicCurrents() = 0; + virtual HarmonicMeasurementIterator * IterateHarmonicPhases() = 0; + virtual DataModel::Nullable GetPowerFactor() = 0; + virtual DataModel::Nullable GetNeutralCurrent() = 0; + +protected: + EndpointId mEndpointId = 0; +}; + +enum class OptionalAttributes : uint32_t +{ + kOptionalAttributeRanges = 0x1, + kOptionalAttributeVoltage = 0x2, + kOptionalAttributeActiveCurrent = 0x4, + kOptionalAttributeReactiveCurrent = 0x8, + kOptionalAttributeApparentCurrent = 0x10, + kOptionalAttributeReactivePower = 0x20, + kOptionalAttributeApparentPower = 0x40, + kOptionalAttributeRMSVoltage = 0x80, + kOptionalAttributeRMSCurrent = 0x100, + kOptionalAttributeRMSPower = 0x200, + kOptionalAttributeFrequency = 0x400, + kOptionalAttributePowerFactor = 0x800, + kOptionalAttributeNeutralCurrent = 0x1000, +}; + +class Instance : public AttributeAccessInterface +{ +public: + Instance(EndpointId aEndpointId, Delegate & aDelegate, BitMask aFeature, + BitMask aOptionalAttributes) : + AttributeAccessInterface(MakeOptional(aEndpointId), Id), + mDelegate(aDelegate), mFeature(aFeature), mOptionalAttrs(aOptionalAttributes) + { + /* set the base class delegates endpointId */ + mDelegate.SetEndpointId(aEndpointId); + } + ~Instance() { Shutdown(); } + + CHIP_ERROR Init(); + void Shutdown(); + + bool HasFeature(Feature aFeature) const; + bool SupportsOptAttr(OptionalAttributes aOptionalAttrs) const; + +private: + Delegate & mDelegate; + BitMask mFeature; + BitMask mOptionalAttrs; + + // AttributeAccessInterface + CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; + + CHIP_ERROR ReadAccuracy(AttributeValueEncoder & aEncoder); + CHIP_ERROR ReadRanges(AttributeValueEncoder & aEncoder); + CHIP_ERROR ReadHarmonicCurrents(AttributeValueEncoder & aEncoder); + CHIP_ERROR ReadHarmonicPhases(AttributeValueEncoder & aEncoder); +}; + +} // namespace ElectricalPowerMeasurement +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp b/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp index c392c963dc5bdd..0bd3fe0af9332f 100644 --- a/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp +++ b/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp @@ -17,6 +17,9 @@ #include "general-diagnostics-server.h" +#include +#include + #include #include "app/server/Server.h" @@ -28,6 +31,7 @@ #include #include #include +#include #include #include @@ -44,6 +48,8 @@ using chip::Protocols::InteractionModel::Status; namespace { +constexpr uint8_t kCurrentClusterRevision = 2; + bool IsTestEventTriggerEnabled() { auto * triggerDelegate = chip::Server::GetInstance().GetTestEventTriggerDelegate(); @@ -209,10 +215,24 @@ CHIP_ERROR GeneralDiagosticsAttrAccess::Read(const ConcreteReadAttributePath & a bool isTestEventTriggersEnabled = IsTestEventTriggerEnabled(); return aEncoder.Encode(isTestEventTriggersEnabled); } - // Note: Attribute ID 0x0009 was removed (#30002). - default: { - break; + // Note: Attribute ID 0x0009 was removed (#30002). + + case FeatureMap::Id: { + uint32_t features = 0; + +#if CHIP_CONFIG_MAX_PATHS_PER_INVOKE > 1 + features |= to_underlying(Clusters::GeneralDiagnostics::Feature::kDataModelTest); +#endif // CHIP_CONFIG_MAX_PATHS_PER_INVOKE > 1 + + return aEncoder.Encode(features); } + + case ClusterRevision::Id: { + return aEncoder.Encode(kCurrentClusterRevision); + } + + default: + break; } return CHIP_NO_ERROR; } @@ -352,29 +372,37 @@ void GeneralDiagnosticsServer::OnNetworkFaultsDetect(const GeneralFaultsAddStatus(commandPath, Status::ConstraintError); - return true; + return nullptr; } - if (IsByteSpanAllZeros(commandData.enableKey)) + if (IsByteSpanAllZeros(enableKey)) { - commandObj->AddStatus(commandPath, Status::ConstraintError); - return true; + return nullptr; } auto * triggerDelegate = chip::Server::GetInstance().GetTestEventTriggerDelegate(); - // Spec says "EnableKeyMismatch" but this never existed prior to 1.0 SVE2 and mismatches - // test plans as well. ConstraintError is specified for most other errors, so - // we keep the behavior as close as possible, except for EnableKeyMismatch which - // is going to be a ConstraintError. - if (triggerDelegate == nullptr || !triggerDelegate->DoesEnableKeyMatch(commandData.enableKey)) + if (triggerDelegate == nullptr || !triggerDelegate->DoesEnableKeyMatch(enableKey)) + { + return nullptr; + } + + return triggerDelegate; +} + +} // namespace + +bool emberAfGeneralDiagnosticsClusterTestEventTriggerCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath, + const Commands::TestEventTrigger::DecodableType & commandData) +{ + auto * triggerDelegate = GetTriggerDelegateOnMatchingKey(commandData.enableKey); + if (triggerDelegate == nullptr) { commandObj->AddStatus(commandPath, Status::ConstraintError); return true; @@ -420,6 +448,44 @@ bool emberAfGeneralDiagnosticsClusterTimeSnapshotCallback(CommandHandler * comma return true; } +bool emberAfGeneralDiagnosticsClusterPayloadTestRequestCallback(CommandHandler * commandObj, + const ConcreteCommandPath & commandPath, + const Commands::PayloadTestRequest::DecodableType & commandData) +{ + // Max allowed is 2048. + if (commandData.count > 2048) + { + commandObj->AddStatus(commandPath, Status::ConstraintError); + return true; + } + + // Ensure Test Event triggers are enabled and key matches. + auto * triggerDelegate = GetTriggerDelegateOnMatchingKey(commandData.enableKey); + if (triggerDelegate == nullptr) + { + commandObj->AddStatus(commandPath, Status::ConstraintError); + return true; + } + + Commands::PayloadTestResponse::Type response; + Platform::ScopedMemoryBufferWithSize payload; + if (!payload.Calloc(commandData.count)) + { + commandObj->AddStatus(commandPath, Status::ResourceExhausted); + return true; + } + + memset(payload.Get(), commandData.value, payload.AllocatedSize()); + response.payload = ByteSpan{ payload.Get(), payload.AllocatedSize() }; + + if (commandObj->AddResponseData(commandPath, response) != CHIP_NO_ERROR) + { + commandObj->AddStatus(commandPath, Status::ResourceExhausted); + } + + return true; +} + void MatterGeneralDiagnosticsPluginServerInitCallback() { BootReasonEnum bootReason; diff --git a/src/app/clusters/icd-management-server/icd-management-server.cpp b/src/app/clusters/icd-management-server/icd-management-server.cpp index e748030f1da9d3..90953e3b814dd2 100644 --- a/src/app/clusters/icd-management-server/icd-management-server.cpp +++ b/src/app/clusters/icd-management-server/icd-management-server.cpp @@ -101,17 +101,17 @@ CHIP_ERROR IcdManagementAttributeAccess::Read(const ConcreteReadAttributePath & CHIP_ERROR IcdManagementAttributeAccess::ReadIdleModeDuration(EndpointId endpoint, AttributeValueEncoder & encoder) { - return encoder.Encode(mICDConfigurationData->GetIdleModeDurationSec()); + return encoder.Encode(mICDConfigurationData->GetIdleModeDuration().count()); } CHIP_ERROR IcdManagementAttributeAccess::ReadActiveModeDuration(EndpointId endpoint, AttributeValueEncoder & encoder) { - return encoder.Encode(mICDConfigurationData->GetActiveModeDurationMs()); + return encoder.Encode(mICDConfigurationData->GetActiveModeDuration().count()); } CHIP_ERROR IcdManagementAttributeAccess::ReadActiveModeThreshold(EndpointId endpoint, AttributeValueEncoder & encoder) { - return encoder.Encode(mICDConfigurationData->GetActiveModeThresholdMs()); + return encoder.Encode(mICDConfigurationData->GetActiveModeThreshold().count()); } CHIP_ERROR IcdManagementAttributeAccess::ReadRegisteredClients(EndpointId endpoint, AttributeValueEncoder & encoder) @@ -149,7 +149,7 @@ CHIP_ERROR IcdManagementAttributeAccess::ReadRegisteredClients(EndpointId endpoi CHIP_ERROR IcdManagementAttributeAccess::ReadICDCounter(EndpointId endpoint, AttributeValueEncoder & encoder) { - return encoder.Encode(mICDConfigurationData->GetICDCounter()); + return encoder.Encode(mICDConfigurationData->GetICDCounter().GetValue()); } CHIP_ERROR IcdManagementAttributeAccess::ReadClientsSupportedPerFabric(EndpointId endpoint, AttributeValueEncoder & encoder) @@ -292,7 +292,7 @@ Status ICDManagementServer::RegisterClient(CommandHandler * commandObj, const Co TriggerICDMTableUpdatedEvent(); } - icdCounter = mICDConfigurationData->GetICDCounter(); + icdCounter = mICDConfigurationData->GetICDCounter().GetValue(); return InteractionModel::Status::Success; } diff --git a/src/app/clusters/scenes-server/SceneTable.h b/src/app/clusters/scenes-server/SceneTable.h index 8f0353bf05da44..1b634211ead063 100644 --- a/src/app/clusters/scenes-server/SceneTable.h +++ b/src/app/clusters/scenes-server/SceneTable.h @@ -39,7 +39,7 @@ inline constexpr SceneId kUndefinedSceneId = 0xff; static constexpr size_t kIteratorsMax = CHIP_CONFIG_MAX_SCENES_CONCURRENT_ITERATORS; static constexpr size_t kSceneNameMaxLength = CHIP_CONFIG_SCENES_CLUSTER_MAXIMUM_NAME_LENGTH; -static constexpr size_t kScenesMaxTransitionTime = 6'000'000u; +static constexpr size_t kScenesMaxTransitionTime = 60'000'000u; /// @brief SceneHandlers are meant as interface between various clusters and the Scene table. /// When a scene command involving extension field sets is received, the Scene Table will go through diff --git a/src/app/clusters/scenes-server/scenes-server.cpp b/src/app/clusters/scenes-server/scenes-server.cpp index cce4a7eb754c09..94039297713bed 100644 --- a/src/app/clusters/scenes-server/scenes-server.cpp +++ b/src/app/clusters/scenes-server/scenes-server.cpp @@ -61,7 +61,15 @@ CHIP_ERROR AddResponseOnError(CommandHandlerInterface::HandlerContext & ctx, Res { if (CHIP_NO_ERROR != err) { - resp.status = to_underlying(StatusIB(err).mStatus); + // TODO : Properly fix mapping between error types (issue https://github.com/project-chip/connectedhomeip/issues/26885) + if (CHIP_ERROR_NOT_FOUND == err) + { + resp.status = to_underlying(Protocols::InteractionModel::Status::NotFound); + } + else + { + resp.status = to_underlying(StatusIB(err).mStatus); + } ctx.mCommandHandler.AddResponse(ctx.mRequestPath, resp); } return err; diff --git a/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp index 217f44a3c61df2..8e919ef5bb7976 100644 --- a/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp +++ b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp @@ -773,7 +773,7 @@ CHIP_ERROR TimeSynchronizationServer::SetUTCTime(EndpointId ep, uint64_t utcTime CHIP_ERROR err = UpdateUTCTime(utcTime); if (err != CHIP_NO_ERROR && !RuntimeOptionsProvider::Instance().GetSimulateNoInternalTime()) { - ChipLogError(Zcl, "Error setting UTC time on the device"); + ChipLogError(Zcl, "Error setting UTC time on the device: %" CHIP_ERROR_FORMAT, err.Format()); return err; } GetDelegate()->UTCTimeAvailabilityChanged(utcTime); diff --git a/src/app/common/BUILD.gn b/src/app/common/BUILD.gn index c6c350e547fd86..f2eb7b479f42a2 100644 --- a/src/app/common/BUILD.gn +++ b/src/app/common/BUILD.gn @@ -14,21 +14,41 @@ import("//build_overrides/chip.gni") +config("includes") { + include_dirs = [ "${chip_root}/zzz_generated/app-common" ] +} + static_library("cluster-objects") { output_name = "libClusterObjects" sources = [ - "${chip_root}/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h", - "${chip_root}/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h", "${chip_root}/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp", "${chip_root}/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h", ] public_deps = [ + "${chip_root}/src/app/data-model", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", "${chip_root}/src/protocols/interaction_model", ] - defines = [] + public_configs = [ ":includes" ] +} + +source_set("enums") { + sources = [ + "${chip_root}/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h", + "${chip_root}/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h", + ] + + public_configs = [ ":includes" ] +} + +source_set("simulated") { + sources = [ "${chip_root}/zzz_generated/app-common/app-common/zap-generated/tests/simulated-cluster-objects.h" ] + + public_deps = [ ":enums" ] + + public_configs = [ ":includes" ] } diff --git a/src/app/common/templates/config-data.yaml b/src/app/common/templates/config-data.yaml index 26f4356f517f10..20677184632c6c 100644 --- a/src/app/common/templates/config-data.yaml +++ b/src/app/common/templates/config-data.yaml @@ -38,6 +38,8 @@ CommandHandlerInterfaceOnlyClusters: - Energy EVSE Mode - Device Energy Management - Device Energy Management Mode + - Electrical Power Measurement + - Electrical Energy Measurement # We need a more configurable way of deciding which clusters have which init functions.... # See https://github.com/project-chip/connectedhomeip/issues/4369 diff --git a/src/app/common/templates/templates.json b/src/app/common/templates/templates.json index 6d253d5e1b2d6f..de26d76697d0ad 100644 --- a/src/app/common/templates/templates.json +++ b/src/app/common/templates/templates.json @@ -21,6 +21,10 @@ "name": "cluster_objects_struct", "path": "../../zap-templates/partials/cluster-objects-struct.zapt" }, + { + "name": "cluster_enums_enum", + "path": "../../zap-templates/partials/cluster-enums-enum.zapt" + }, { "name": "cluster_objects_field_init", "path": "../../zap-templates/partials/cluster-objects-field-init.zapt" diff --git a/src/app/data-model/BUILD.gn b/src/app/data-model/BUILD.gn new file mode 100644 index 00000000000000..49a49033f0e9f2 --- /dev/null +++ b/src/app/data-model/BUILD.gn @@ -0,0 +1,47 @@ +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import("//build_overrides/chip.gni") + +source_set("data-model") { + sources = [ + "BasicTypes.h", + "DecodableList.h", + "Decode.h", + "Encode.h", + "FabricScoped.h", + "FabricScopedPreEncodedValue.cpp", + "FabricScopedPreEncodedValue.h", + "List.h", + "NullObject.h", + "Nullable.h", + "PreEncodedValue.cpp", + "PreEncodedValue.h", + "TagBoundEncoder.h", + "WrappedStructEncoder.h", + ] + + deps = [ + # TODO: dependencies NOT declared because they are not part of + # any GN dependency. Overall src/app seems to suffer greatly + # of this, in part due to zap-generated code dependency. + # + # - app/util/attribute-storage-null-handling.h + # - app/ConcreteAttributePath.h + # + "${chip_root}/src/app/common:enums", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + "${chip_root}/src/protocols/interaction_model", + ] +} diff --git a/src/lib/support/CHIPListUtils.h b/src/app/data-model/ListLargeSystemExtensions.h similarity index 90% rename from src/lib/support/CHIPListUtils.h rename to src/app/data-model/ListLargeSystemExtensions.h index 95e063a49581b7..fca49dd698939a 100644 --- a/src/lib/support/CHIPListUtils.h +++ b/src/app/data-model/ListLargeSystemExtensions.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2024 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. @@ -15,10 +15,12 @@ * limitations under the License. */ -#ifndef CHIP_LISTUTILS_INTERNAL_H -#define CHIP_LISTUTILS_INTERNAL_H +#pragma once +// NOTE: Functionality in this class uses HEAP and std::set. It is generally +// intended for large systems only #include + #include #include @@ -27,6 +29,7 @@ template struct ListMemberTypeGetter { }; + template struct ListMemberTypeGetter> { @@ -63,5 +66,3 @@ struct ListFreer std::set mListHolders; }; - -#endif /* CHIP_LISTUTILS_INTERNAL_H */ diff --git a/src/app/icd/client/BUILD.gn b/src/app/icd/client/BUILD.gn index fa32e9c68dbfd4..4d59a627a4bcbb 100644 --- a/src/app/icd/client/BUILD.gn +++ b/src/app/icd/client/BUILD.gn @@ -41,10 +41,13 @@ source_set("handler") { "CheckInHandler.h", "DefaultCheckInDelegate.cpp", "DefaultCheckInDelegate.h", + "RefreshKeySender.cpp", + "RefreshKeySender.h", ] public_deps = [ ":manager", "${chip_root}/src/app", + "${chip_root}/src/controller", "${chip_root}/src/lib/core", "${chip_root}/src/messaging", "${chip_root}/src/protocols", diff --git a/src/app/icd/client/CheckInDelegate.h b/src/app/icd/client/CheckInDelegate.h index 50d378a87a58e7..5c931d414aab2c 100644 --- a/src/app/icd/client/CheckInDelegate.h +++ b/src/app/icd/client/CheckInDelegate.h @@ -19,10 +19,13 @@ #pragma once #include +#include namespace chip { namespace app { +class RefreshKeySender; + /// Callbacks for check in protocol /** * @brief The application implementing an ICD client should inherit the CheckInDelegate and implement the listed callbacks @@ -39,6 +42,40 @@ class DLL_EXPORT CheckInDelegate node that sent the check-in message. */ virtual void OnCheckInComplete(const ICDClientInfo & clientInfo) = 0; + + /** + * @brief Callback used to let the application know that a key refresh is + * needed to avoid counter rollover problems. + * + * The implementer of this function should create a new RefreshKeySender object. This object will be tied to the specific key + * refresh process and will not be used by the caller after that particular key refresh process has ended, regardless of success + * or failure. + * + * The caller guarantees that if a non-null RefreshKeySender pointer is returned, it will call OnKeyRefreshDone + * at some point, and pass it the returned pointer. + * + * If the callee is unable to provide the RefreshKeySender object, that indicates key + * refresh is not possible until the callee is able to provide the required resources. + * + * @param[in] clientInfo - ICDClientInfo object representing the state associated with the + * node that sent the check-in message. The callee can use the clientInfo to determine the type of key + * to generate. + * @param[in] clientStorage - ICDClientStorage object stores the updated ICDClientInfo after re-registration into + * persistent storage. + * @return RefreshKeySender - pointer to RefreshKeySender object + */ + virtual RefreshKeySender * OnKeyRefreshNeeded(ICDClientInfo & clientInfo, ICDClientStorage * clientStorage) = 0; + + /** + * @brief Callback used to let the application know that the re-registration process is done. This callback will be called for + * both success and failure cases. On failure, the callee should take appropriate corrective action based on the error. + * + * @param[in] refreshKeySender - pointer to the RefreshKeySender object that was used for the key refresh process. The caller + * will NOT use this pointer any more. + * @param[in] error - CHIP_NO_ERROR indicates successful re-registration using the new key + * Other errors indicate the failure reason. + */ + virtual void OnKeyRefreshDone(RefreshKeySender * refreshKeySender, CHIP_ERROR error) = 0; }; } // namespace app diff --git a/src/app/icd/client/CheckInHandler.cpp b/src/app/icd/client/CheckInHandler.cpp index f05dcd8b7819ed..165301c45480fd 100644 --- a/src/app/icd/client/CheckInHandler.cpp +++ b/src/app/icd/client/CheckInHandler.cpp @@ -23,8 +23,8 @@ */ #include -#include #include +#include #include @@ -109,8 +109,20 @@ CHIP_ERROR CheckInHandler::OnMessageReceived(Messaging::ExchangeContext * ec, co if (refreshKey) { - // TODO: A new CASE session should be established to re-register the client using a new key. The registration will happen in - // CASE session callback + RefreshKeySender * refreshKeySender = mpCheckInDelegate->OnKeyRefreshNeeded(clientInfo, mpICDClientStorage); + if (refreshKeySender == nullptr) + { + ChipLogError(ICD, "Key Refresh failed for node ID:" ChipLogFormatScopedNodeId, + ChipLogValueScopedNodeId(clientInfo.peer_node)); + return CHIP_NO_ERROR; + } + err = refreshKeySender->EstablishSessionToPeer(); + if (CHIP_NO_ERROR != err) + { + ChipLogError(ICD, "CASE session establishment failed with error : %" CHIP_ERROR_FORMAT, err.Format()); + mpCheckInDelegate->OnKeyRefreshDone(refreshKeySender, err); + return CHIP_NO_ERROR; + } } else { diff --git a/src/app/icd/client/DefaultCheckInDelegate.cpp b/src/app/icd/client/DefaultCheckInDelegate.cpp index cec36d2db5660b..8df98006f6e9e0 100644 --- a/src/app/icd/client/DefaultCheckInDelegate.cpp +++ b/src/app/icd/client/DefaultCheckInDelegate.cpp @@ -15,13 +15,12 @@ * limitations under the License. */ -#include "CheckInHandler.h" #include #include +#include #include #include #include -#include namespace chip { namespace app { @@ -44,5 +43,42 @@ void DefaultCheckInDelegate::OnCheckInComplete(const ICDClientInfo & clientInfo) #endif } +RefreshKeySender * DefaultCheckInDelegate::OnKeyRefreshNeeded(ICDClientInfo & clientInfo, ICDClientStorage * clientStorage) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + RefreshKeySender::RefreshKeyBuffer newKey; + + err = Crypto::DRBG_get_bytes(newKey.Bytes(), newKey.Capacity()); + if (err != CHIP_NO_ERROR) + { + ChipLogError(ICD, "Generation of new key failed: %" CHIP_ERROR_FORMAT, err.Format()); + return nullptr; + } + + auto refreshKeySender = Platform::New(this, clientInfo, clientStorage, newKey); + if (refreshKeySender == nullptr) + { + return nullptr; + } + return refreshKeySender; +} + +void DefaultCheckInDelegate::OnKeyRefreshDone(RefreshKeySender * refreshKeySender, CHIP_ERROR error) +{ + if (error == CHIP_NO_ERROR) + { + ChipLogProgress(ICD, "Re-registration with new key completed successfully"); + } + else + { + ChipLogError(ICD, "Re-registration with new key failed with error : %" CHIP_ERROR_FORMAT, error.Format()); + // The callee can take corrective action based on the error received. + } + if (refreshKeySender != nullptr) + { + Platform::Delete(refreshKeySender); + refreshKeySender = nullptr; + } +} } // namespace app } // namespace chip diff --git a/src/app/icd/client/DefaultCheckInDelegate.h b/src/app/icd/client/DefaultCheckInDelegate.h index 5e77186b3c7c9d..e7b856677734bd 100644 --- a/src/app/icd/client/DefaultCheckInDelegate.h +++ b/src/app/icd/client/DefaultCheckInDelegate.h @@ -33,6 +33,8 @@ class DefaultCheckInDelegate : public CheckInDelegate virtual ~DefaultCheckInDelegate() {} CHIP_ERROR Init(ICDClientStorage * storage); void OnCheckInComplete(const ICDClientInfo & clientInfo) override; + RefreshKeySender * OnKeyRefreshNeeded(ICDClientInfo & clientInfo, ICDClientStorage * clientStorage) override; + void OnKeyRefreshDone(RefreshKeySender * refreshKeySender, CHIP_ERROR error) override; private: ICDClientStorage * mpStorage = nullptr; diff --git a/src/app/icd/client/RefreshKeySender.cpp b/src/app/icd/client/RefreshKeySender.cpp new file mode 100644 index 00000000000000..45cbbd9c987a68 --- /dev/null +++ b/src/app/icd/client/RefreshKeySender.cpp @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2024 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 "RefreshKeySender.h" +#include "CheckInDelegate.h" +#include "controller/InvokeInteraction.h" +#include +#include +#include +#include +#include + +namespace chip { +namespace app { + +RefreshKeySender::RefreshKeySender(CheckInDelegate * checkInDelegate, const ICDClientInfo & icdClientInfo, + ICDClientStorage * icdClientStorage, const RefreshKeyBuffer & refreshKeyBuffer) : + mICDClientInfo(icdClientInfo), + mpICDClientStorage(icdClientStorage), mpCheckInDelegate(checkInDelegate), mOnConnectedCallback(HandleDeviceConnected, this), + mOnConnectionFailureCallback(HandleDeviceConnectionFailure, this) + +{ + mNewKey = refreshKeyBuffer; +} + +CHIP_ERROR RefreshKeySender::RegisterClientWithNewKey(Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle) +{ + auto onSuccess = [&](const ConcreteCommandPath & commandPath, const StatusIB & status, const auto & dataResponse) { + ChipLogProgress(ICD, "RegisterClient command succeeded"); + CHIP_ERROR error; + + // Update the ICDClientInfo with new key and start counter and store it to persistence + mICDClientInfo.start_icd_counter = dataResponse.ICDCounter; + mICDClientInfo.offset = 0; + mpICDClientStorage->RemoveKey(mICDClientInfo); + error = mpICDClientStorage->SetKey(mICDClientInfo, mNewKey.Span()); + if (error != CHIP_NO_ERROR) + { + ChipLogError(ICD, "Failed to set the new key after re-registration: %" CHIP_ERROR_FORMAT, error.Format()); + mpCheckInDelegate->OnKeyRefreshDone(this, error); + return; + } + + error = mpICDClientStorage->StoreEntry(mICDClientInfo); + if (error != CHIP_NO_ERROR) + { + ChipLogError(ICD, "Failed to store the new key after re-registration: %" CHIP_ERROR_FORMAT, error.Format()); + mpCheckInDelegate->OnKeyRefreshDone(this, error); + return; + } + + mpCheckInDelegate->OnCheckInComplete(mICDClientInfo); + mpCheckInDelegate->OnKeyRefreshDone(this, CHIP_NO_ERROR); + }; + + auto onFailure = [&](CHIP_ERROR error) { + ChipLogError(ICD, "RegisterClient command failed: %" CHIP_ERROR_FORMAT, error.Format()); + mpCheckInDelegate->OnKeyRefreshDone(this, error); + }; + + EndpointId endpointId = 0; + + Clusters::IcdManagement::Commands::RegisterClient::Type registerClientCommand; + registerClientCommand.checkInNodeID = mICDClientInfo.peer_node.GetNodeId(); + registerClientCommand.monitoredSubject = mICDClientInfo.monitored_subject; + registerClientCommand.key = mNewKey.Span(); + return Controller::InvokeCommandRequest(&exchangeMgr, sessionHandle, endpointId, registerClientCommand, onSuccess, onFailure); +} + +CHIP_ERROR RefreshKeySender::EstablishSessionToPeer() +{ + ChipLogProgress(ICD, "Trying to establish a CASE session for re-registering an ICD client"); + auto * caseSessionManager = InteractionModelEngine::GetInstance()->GetCASESessionManager(); + VerifyOrReturnError(caseSessionManager != nullptr, CHIP_ERROR_INVALID_CASE_PARAMETER); + caseSessionManager->FindOrEstablishSession(mICDClientInfo.peer_node, &mOnConnectedCallback, &mOnConnectionFailureCallback); + return CHIP_NO_ERROR; +} + +void RefreshKeySender::HandleDeviceConnected(void * context, Messaging::ExchangeManager & exchangeMgr, + const SessionHandle & sessionHandle) +{ + RefreshKeySender * const _this = static_cast(context); + VerifyOrDie(_this != nullptr); + + CHIP_ERROR err = _this->RegisterClientWithNewKey(exchangeMgr, sessionHandle); + if (CHIP_NO_ERROR != err) + { + ChipLogError(ICD, "Failed to send register client command"); + _this->mpCheckInDelegate->OnKeyRefreshDone(_this, err); + } +} + +void RefreshKeySender::HandleDeviceConnectionFailure(void * context, const ScopedNodeId & peerId, CHIP_ERROR err) +{ + RefreshKeySender * const _this = static_cast(context); + VerifyOrDie(_this != nullptr); + + ChipLogError(ICD, "Failed to establish CASE for re-registration with error '%" CHIP_ERROR_FORMAT "'", err.Format()); + _this->mpCheckInDelegate->OnKeyRefreshDone(_this, err); +} +} // namespace app +} // namespace chip diff --git a/src/app/icd/client/RefreshKeySender.h b/src/app/icd/client/RefreshKeySender.h new file mode 100644 index 00000000000000..a0cf822fa446f9 --- /dev/null +++ b/src/app/icd/client/RefreshKeySender.h @@ -0,0 +1,93 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ICDClientInfo.h" +#include "ICDClientStorage.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace chip { +namespace app { + +class CheckInDelegate; + +/** + * @brief RefreshKeySender contains all the data and methods needed for key refresh and re-registration of an ICD client. + */ +class RefreshKeySender +{ +public: + typedef Crypto::SensitiveDataBuffer RefreshKeyBuffer; + + RefreshKeySender(CheckInDelegate * checkInDelegate, const ICDClientInfo & icdClientInfo, ICDClientStorage * icdClientStorage, + const RefreshKeyBuffer & refreshKeyBuffer); + + /** + * @brief Sets up a CASE session to the peer for re-registering a client with the peer when a key refresh is required to avoid + * ICD counter rollover. Returns error if we did not even manage to kick off a CASE attempt. + */ + CHIP_ERROR EstablishSessionToPeer(); + +private: + // CASE session callbacks + /** + * @brief Callback received on successfully establishing a CASE session in order to re-register the client with the peer node + * using a new key to avoid counter rollover problems. + * + * @param[in] context - context of the client establishing the CASE session + * @param[in] exchangeMgr - exchange manager to use for the re-registration + * @param[in] sessionHandle - session handle to use for the re-registration + */ + static void HandleDeviceConnected(void * context, Messaging::ExchangeManager & exchangeMgr, + const SessionHandle & sessionHandle); + /** + * @brief Callback received on failure to establish a CASE session in order to re-register the client with the peer node using a + * new key to avoid counter rollover problems. + * + * @param[in] context - context of the client establishing the CASE session + * @param[in] peerId - Scoped Node ID of the peer node + * @param[in] err - failure reason + */ + static void HandleDeviceConnectionFailure(void * context, const ScopedNodeId & peerId, CHIP_ERROR err); + + /** + * @brief Used to send a re-registration command to the peer using a new key. + * + * @param[in] exchangeMgr - exchange manager to use for the re-registration + * @param[in] sessionHandle - session handle to use for the re-registration + */ + CHIP_ERROR RegisterClientWithNewKey(Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle); + + ICDClientInfo mICDClientInfo; + ICDClientStorage * mpICDClientStorage = nullptr; + CheckInDelegate * mpCheckInDelegate = nullptr; + RefreshKeyBuffer mNewKey; + Callback::Callback mOnConnectedCallback; + Callback::Callback mOnConnectionFailureCallback; +}; +} // namespace app +} // namespace chip diff --git a/src/app/icd/server/BUILD.gn b/src/app/icd/server/BUILD.gn index ee2b2be0034c5c..41c73b5f7e6bbc 100644 --- a/src/app/icd/server/BUILD.gn +++ b/src/app/icd/server/BUILD.gn @@ -115,5 +115,6 @@ source_set("configuration-data") { ":icd-server-config", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", + "${chip_root}/src/protocols/secure_channel:check-in-counter", ] } diff --git a/src/app/icd/server/ICDCheckInSender.cpp b/src/app/icd/server/ICDCheckInSender.cpp index 21bcc336b0d357..0321fb1ad822ef 100644 --- a/src/app/icd/server/ICDCheckInSender.cpp +++ b/src/app/icd/server/ICDCheckInSender.cpp @@ -64,7 +64,8 @@ CHIP_ERROR ICDCheckInSender::SendCheckInMsg(const Transport::PeerAddress & addr) size_t writtenBytes = 0; Encoding::LittleEndian::BufferWriter writer(activeModeThresholdBuffer, sizeof(activeModeThresholdBuffer)); - writer.Put16(ICDConfigurationData::GetInstance().GetActiveModeThresholdMs()); + uint16_t activeModeThreshold_ms = ICDConfigurationData::GetInstance().GetActiveModeThreshold().count(); + writer.Put16(activeModeThreshold_ms); VerifyOrReturnError(writer.Fit(writtenBytes), CHIP_ERROR_INTERNAL); ByteSpan activeModeThresholdByteSpan(writer.Buffer(), writtenBytes); diff --git a/src/app/icd/server/ICDConfigurationData.cpp b/src/app/icd/server/ICDConfigurationData.cpp index 332e7bbebc88b4..cfd2325671ea0f 100644 --- a/src/app/icd/server/ICDConfigurationData.cpp +++ b/src/app/icd/server/ICDConfigurationData.cpp @@ -37,20 +37,24 @@ System::Clock::Milliseconds32 ICDConfigurationData::GetSlowPollingInterval() return mSlowPollingInterval; } -CHIP_ERROR ICDConfigurationData::SetModeDurations(Optional activeModeDuration_ms, Optional idleModeDuration_ms) +CHIP_ERROR ICDConfigurationData::SetModeDurations(Optional activeModeDuration, + Optional idleModeDuration) { - VerifyOrReturnError(activeModeDuration_ms.HasValue() || idleModeDuration_ms.HasValue(), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(activeModeDuration.HasValue() || idleModeDuration.HasValue(), CHIP_ERROR_INVALID_ARGUMENT); - uint32_t tmpIdleModeDuration_s = - idleModeDuration_ms.HasValue() ? (idleModeDuration_ms.Value() / kMillisecondsPerSecond) : mIdleModeDuration_s; - uint32_t tmpActiveModeDuration_ms = activeModeDuration_ms.HasValue() ? activeModeDuration_ms.Value() : mActiveModeDuration_ms; + // Convert idleModeDuration to seconds for the correct precision + System::Clock::Seconds32 tmpIdleModeDuration = idleModeDuration.HasValue() + ? std::chrono::duration_cast(idleModeDuration.Value()) + : mIdleModeDuration; - VerifyOrReturnError(tmpActiveModeDuration_ms <= (tmpIdleModeDuration_s * kMillisecondsPerSecond), CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(tmpIdleModeDuration_s <= kMaxIdleModeDuration_s, CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(tmpIdleModeDuration_s >= kMinIdleModeDuration_s, CHIP_ERROR_INVALID_ARGUMENT); + System::Clock::Milliseconds32 tmpActiveModeDuration = activeModeDuration.ValueOr(mActiveModeDuration); - mIdleModeDuration_s = tmpIdleModeDuration_s; - mActiveModeDuration_ms = tmpActiveModeDuration_ms; + VerifyOrReturnError(tmpActiveModeDuration <= tmpIdleModeDuration, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(tmpIdleModeDuration <= kMaxIdleModeDuration, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(tmpIdleModeDuration >= kMinIdleModeDuration, CHIP_ERROR_INVALID_ARGUMENT); + + mIdleModeDuration = tmpIdleModeDuration; + mActiveModeDuration = tmpActiveModeDuration; return CHIP_NO_ERROR; } diff --git a/src/app/icd/server/ICDConfigurationData.h b/src/app/icd/server/ICDConfigurationData.h index 6668bdd216f0ca..3fb3e9a92d2304 100644 --- a/src/app/icd/server/ICDConfigurationData.h +++ b/src/app/icd/server/ICDConfigurationData.h @@ -20,6 +20,7 @@ #include #include #include +#include #include namespace chip { @@ -44,7 +45,7 @@ class TestICDManager; class ICDConfigurationData { public: - static constexpr uint32_t ICD_CHECK_IN_COUNTER_MIN_INCREMENT = 100; + static constexpr uint32_t kICDCounterPersistenceIncrement = 100; enum class ICDMode : uint8_t { @@ -54,13 +55,13 @@ class ICDConfigurationData static ICDConfigurationData & GetInstance() { return instance; }; - uint32_t GetIdleModeDurationSec() { return mIdleModeDuration_s; } + System::Clock::Seconds32 GetIdleModeDuration() { return mIdleModeDuration; } - uint32_t GetActiveModeDurationMs() { return mActiveModeDuration_ms; } + System::Clock::Milliseconds32 GetActiveModeDuration() { return mActiveModeDuration; } - uint16_t GetActiveModeThresholdMs() { return mActiveThreshold_ms; } + System::Clock::Milliseconds16 GetActiveModeThreshold() { return mActiveThreshold; } - uint32_t GetICDCounter() { return mICDCounter; } + Protocols::SecureChannel::CheckInCounter & GetICDCounter() { return mICDCounter; } uint16_t GetClientsSupportedPerFabric() { return mFabricClientsSupported; } @@ -68,7 +69,7 @@ class ICDConfigurationData System::Clock::Milliseconds32 GetFastPollingInterval() { return mFastPollingInterval; } - uint32_t GetMinLitActiveModeThresholdMs() { return kMinLitActiveModeThreshold_ms; } + System::Clock::Milliseconds16 GetMinLitActiveModeThreshold() { return kMinLitActiveModeThreshold; } /** * If ICD_ENFORCE_SIT_SLOW_POLL_LIMIT is set to 0, function will always return the configured Slow Polling interval @@ -99,18 +100,17 @@ class ICDConfigurationData friend class chip::app::TestICDManager; void SetICDMode(ICDMode mode) { mICDMode = mode; }; - void SetICDCounter(uint32_t count) { mICDCounter = count; } void SetSlowPollingInterval(System::Clock::Milliseconds32 slowPollInterval) { mSlowPollingInterval = slowPollInterval; }; void SetFastPollingInterval(System::Clock::Milliseconds32 fastPollInterval) { mFastPollingInterval = fastPollInterval; }; - static constexpr uint32_t kMinLitActiveModeThreshold_ms = 5000; + static constexpr System::Clock::Milliseconds16 kMinLitActiveModeThreshold = System::Clock::Milliseconds16(5000); /** * @brief Change the ActiveModeDuration or the IdleModeDuration value * If only one value is provided, check will be done agaisn't the other already set value. * - * @param[in] activeModeDuration_ms new ActiveModeDuration value - * @param[in] idleModeDuration_ms new IdleModeDuration value + * @param[in] activeModeDuration new ActiveModeDuration value + * @param[in] idleModeDuration new IdleModeDuration value * The precision of the IdleModeDuration must be seconds. * @return CHIP_ERROR CHIP_ERROR_INVALID_ARGUMENT is returned if idleModeDuration_ms is smaller than activeModeDuration_ms * is returned if idleModeDuration_ms is greater than 64800000 ms @@ -118,24 +118,26 @@ class ICDConfigurationData * is returned if no valid values are provided * CHIP_NO_ERROR is returned if the new intervals were set */ - CHIP_ERROR SetModeDurations(Optional activeModeDuration_ms, Optional idleModeDuration_ms); + CHIP_ERROR SetModeDurations(Optional activeModeDuration, + Optional idleModeDuration); - static constexpr uint32_t kMaxIdleModeDuration_s = (18 * kSecondsPerHour); - static constexpr uint32_t kMinIdleModeDuration_s = 1; + static constexpr System::Clock::Seconds32 kMaxIdleModeDuration = System::Clock::Seconds32(18 * kSecondsPerHour); + static constexpr System::Clock::Seconds32 kMinIdleModeDuration = System::Clock::Seconds32(1); - static_assert((CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC) <= kMaxIdleModeDuration_s, + static_assert((CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC) <= kMaxIdleModeDuration.count(), "Spec requires the IdleModeDuration to be equal or inferior to 64800s."); - static_assert((CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC) >= kMinIdleModeDuration_s, + static_assert((CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC) >= kMinIdleModeDuration.count(), "Spec requires the IdleModeDuration to be equal or greater to 1s."); - uint32_t mIdleModeDuration_s = CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC; + System::Clock::Seconds32 mIdleModeDuration = System::Clock::Seconds32(CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC); - static_assert((CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS) <= (CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC * kMillisecondsPerSecond), + static_assert(System::Clock::Milliseconds32(CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS) <= + System::Clock::Seconds32(CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC), "Spec requires the IdleModeDuration be equal or greater to the ActiveModeDuration."); - uint32_t mActiveModeDuration_ms = CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS; + System::Clock::Milliseconds32 mActiveModeDuration = System::Clock::Milliseconds32(CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS); - uint16_t mActiveThreshold_ms = CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS; + System::Clock::Milliseconds16 mActiveThreshold = System::Clock::Milliseconds16(CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS); - uint32_t mICDCounter = 0; + Protocols::SecureChannel::CheckInCounter mICDCounter; static_assert((CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC) >= 1, "Spec requires the minimum of supported clients per fabric be equal or greater to 1."); diff --git a/src/app/icd/server/ICDManager.cpp b/src/app/icd/server/ICDManager.cpp index 2fbf7ae8fb39b9..954b3d753be7ce 100644 --- a/src/app/icd/server/ICDManager.cpp +++ b/src/app/icd/server/ICDManager.cpp @@ -35,6 +35,7 @@ namespace app { using namespace chip::app; using namespace chip::app::Clusters; using namespace chip::app::Clusters::IcdManagement; +using namespace System::Clock; static_assert(UINT8_MAX >= CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS, "ICDManager::mOpenExchangeContextCount cannot hold count for the max exchange count"); @@ -55,8 +56,8 @@ void ICDManager::Init(PersistentStorageDelegate * storage, FabricTable * fabricT "The CheckIn protocol feature is required for LIT support."); VerifyOrDieWithMsg(SupportsFeature(Feature::kUserActiveModeTrigger), AppServer, "The user ActiveMode trigger feature is required for LIT support."); - VerifyOrDieWithMsg(ICDConfigurationData::GetInstance().GetMinLitActiveModeThresholdMs() <= - ICDConfigurationData::GetInstance().GetActiveModeThresholdMs(), + VerifyOrDieWithMsg(ICDConfigurationData::GetInstance().GetMinLitActiveModeThreshold() <= + ICDConfigurationData::GetInstance().GetActiveModeThreshold(), AppServer, "The minimum ActiveModeThreshold value for a LIT ICD is 5 seconds."); // Disabling check until LIT support is compelte // VerifyOrDieWithMsg((GetSlowPollingInterval() <= GetSITPollingThreshold()) , AppServer, @@ -71,7 +72,9 @@ void ICDManager::Init(PersistentStorageDelegate * storage, FabricTable * fabricT mExchangeManager = exchangeManager; mSubManager = manager; - VerifyOrDie(InitCounter() == CHIP_NO_ERROR); + VerifyOrDie(ICDConfigurationData::GetInstance().GetICDCounter().Init(mStorage, DefaultStorageKeyAllocator::ICDCheckInCounter(), + ICDConfigurationData::kICDCounterPersistenceIncrement) == + CHIP_NO_ERROR); UpdateICDMode(); UpdateOperationState(OperationalState::IdleMode); @@ -114,7 +117,8 @@ void ICDManager::SendCheckInMsgs() #if !CONFIG_BUILD_FOR_HOST_UNIT_TEST VerifyOrDie(mStorage != nullptr); VerifyOrDie(mFabricTable != nullptr); - uint32_t counter = ICDConfigurationData::GetInstance().GetICDCounter(); + + uint32_t counterValue = ICDConfigurationData::GetInstance().GetICDCounter().GetNextCheckInCounterValue(); bool counterIncremented = false; for (const auto & fabricInfo : *mFabricTable) @@ -155,7 +159,7 @@ void ICDManager::SendCheckInMsgs() { counterIncremented = true; - if (CHIP_NO_ERROR != IncrementCounter()) + if (CHIP_NO_ERROR != ICDConfigurationData::GetInstance().GetICDCounter().Advance()) { ChipLogError(AppServer, "Incremented ICDCounter but failed to access/save to Persistent storage"); } @@ -166,7 +170,7 @@ void ICDManager::SendCheckInMsgs() ICDCheckInSender * sender = mICDSenderPool.CreateObject(mExchangeManager); VerifyOrReturn(sender != nullptr, ChipLogError(AppServer, "Failed to allocate ICDCheckinSender")); - if (CHIP_NO_ERROR != sender->RequestResolve(entry, mFabricTable, counter)) + if (CHIP_NO_ERROR != sender->RequestResolve(entry, mFabricTable, counterValue)) { ChipLogError(AppServer, "Failed to send ICD Check-In"); } @@ -175,54 +179,6 @@ void ICDManager::SendCheckInMsgs() #endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST } -CHIP_ERROR ICDManager::InitCounter() -{ - CHIP_ERROR err; - uint32_t temp; - uint16_t size = static_cast(sizeof(uint32_t)); - - err = mStorage->SyncGetKeyValue(DefaultStorageKeyAllocator::ICDCheckInCounter().KeyName(), &temp, size); - if (err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND) - { - // First time retrieving the counter - temp = chip::Crypto::GetRandU32(); - } - else if (err != CHIP_NO_ERROR) - { - return err; - } - - ICDConfigurationData::GetInstance().SetICDCounter(temp); - temp += ICDConfigurationData::ICD_CHECK_IN_COUNTER_MIN_INCREMENT; - - // Increment the count directly to minimize flash write. - return mStorage->SyncSetKeyValue(DefaultStorageKeyAllocator::ICDCheckInCounter().KeyName(), &temp, size); -} - -CHIP_ERROR ICDManager::IncrementCounter() -{ - uint32_t temp = 0; - StorageKeyName key = DefaultStorageKeyAllocator::ICDCheckInCounter(); - uint16_t size = static_cast(sizeof(uint32_t)); - - ICDConfigurationData::GetInstance().mICDCounter++; - - if (mStorage == nullptr) - { - return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; - } - - ReturnErrorOnFailure(mStorage->SyncGetKeyValue(key.KeyName(), &temp, size)); - - if (temp == ICDConfigurationData::GetInstance().mICDCounter) - { - temp = ICDConfigurationData::GetInstance().mICDCounter + ICDConfigurationData::ICD_CHECK_IN_COUNTER_MIN_INCREMENT; - return mStorage->SyncSetKeyValue(key.KeyName(), &temp, size); - } - - return CHIP_NO_ERROR; -} - void ICDManager::UpdateICDMode() { assertChipStackLockedByCurrentThread(); @@ -280,13 +236,12 @@ void ICDManager::UpdateOperationState(OperationalState state) // When the active mode interval is 0, we stay in idleMode until a notification brings the icd into active mode // unless the device would need to send Check-In messages // TODO(#30281) : Verify how persistent subscriptions affects this at ICDManager::Init - if (ICDConfigurationData::GetInstance().GetActiveModeDurationMs() > 0 || CheckInMessagesWouldBeSent()) + if (ICDConfigurationData::GetInstance().GetActiveModeDuration() > kZero || CheckInMessagesWouldBeSent()) { - uint32_t idleModeDuration = ICDConfigurationData::GetInstance().GetIdleModeDurationSec(); - DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds32(idleModeDuration), OnIdleModeDone, this); + DeviceLayer::SystemLayer().StartTimer(ICDConfigurationData::GetInstance().GetIdleModeDuration(), OnIdleModeDone, this); } - System::Clock::Milliseconds32 slowPollInterval = ICDConfigurationData::GetInstance().GetSlowPollingInterval(); + Milliseconds32 slowPollInterval = ICDConfigurationData::GetInstance().GetSlowPollingInterval(); // Going back to Idle, all Check-In messages are sent mICDSenderPool.ReleaseAll(); @@ -305,21 +260,23 @@ void ICDManager::UpdateOperationState(OperationalState state) // Make sure the idle mode timer is stopped DeviceLayer::SystemLayer().CancelTimer(OnIdleModeDone, this); - mOperationalState = OperationalState::ActiveMode; - uint32_t activeModeDuration = ICDConfigurationData::GetInstance().GetActiveModeDurationMs(); + mOperationalState = OperationalState::ActiveMode; + Milliseconds32 activeModeDuration = ICDConfigurationData::GetInstance().GetActiveModeDuration(); - if (activeModeDuration == 0 && !mKeepActiveFlags.HasAny()) + if (activeModeDuration == kZero && !mKeepActiveFlags.HasAny()) { // A Network Activity triggered the active mode and activeModeDuration is 0. // Stay active for at least Active Mode Threshold. - activeModeDuration = ICDConfigurationData::GetInstance().GetActiveModeThresholdMs(); + activeModeDuration = ICDConfigurationData::GetInstance().GetActiveModeThreshold(); } - DeviceLayer::SystemLayer().StartTimer(System::Clock::Timeout(activeModeDuration), OnActiveModeDone, this); + DeviceLayer::SystemLayer().StartTimer(activeModeDuration, OnActiveModeDone, this); - uint32_t activeModeJitterInterval = - (activeModeDuration >= ICD_ACTIVE_TIME_JITTER_MS) ? activeModeDuration - ICD_ACTIVE_TIME_JITTER_MS : 0; - DeviceLayer::SystemLayer().StartTimer(System::Clock::Timeout(activeModeJitterInterval), OnTransitionToIdle, this); + Milliseconds32 activeModeJitterInterval = Milliseconds32(ICD_ACTIVE_TIME_JITTER_MS); + activeModeJitterInterval = + (activeModeDuration >= activeModeJitterInterval) ? activeModeDuration - activeModeJitterInterval : kZero; + + DeviceLayer::SystemLayer().StartTimer(activeModeJitterInterval, OnTransitionToIdle, this); CHIP_ERROR err = DeviceLayer::ConnectivityMgr().SetPollingInterval(ICDConfigurationData::GetInstance().GetFastPollingInterval()); @@ -337,14 +294,16 @@ void ICDManager::UpdateOperationState(OperationalState state) } else { - uint16_t activeModeThreshold = ICDConfigurationData::GetInstance().GetActiveModeThresholdMs(); - DeviceLayer::SystemLayer().ExtendTimerTo(System::Clock::Timeout(activeModeThreshold), OnActiveModeDone, this); - uint16_t activeModeJitterThreshold = - (activeModeThreshold >= ICD_ACTIVE_TIME_JITTER_MS) ? activeModeThreshold - ICD_ACTIVE_TIME_JITTER_MS : 0; + Milliseconds16 activeModeThreshold = ICDConfigurationData::GetInstance().GetActiveModeThreshold(); + DeviceLayer::SystemLayer().ExtendTimerTo(activeModeThreshold, OnActiveModeDone, this); + + Milliseconds32 activeModeJitterThreshold = Milliseconds32(ICD_ACTIVE_TIME_JITTER_MS); + activeModeJitterThreshold = + (activeModeThreshold >= activeModeJitterThreshold) ? activeModeThreshold - activeModeJitterThreshold : kZero; + if (!mTransitionToIdleCalled) { - DeviceLayer::SystemLayer().ExtendTimerTo(System::Clock::Timeout(activeModeJitterThreshold), OnTransitionToIdle, - this); + DeviceLayer::SystemLayer().ExtendTimerTo(activeModeJitterThreshold, OnTransitionToIdle, this); } } } diff --git a/src/app/icd/server/ICDManager.h b/src/app/icd/server/ICDManager.h index 12ae535ce2ed47..3f78cccc69cfd1 100644 --- a/src/app/icd/server/ICDManager.h +++ b/src/app/icd/server/ICDManager.h @@ -122,10 +122,6 @@ class ICDManager : public ICDListener */ static void OnTransitionToIdle(System::Layer * aLayer, void * appState); - // ICD Counter - CHIP_ERROR IncrementCounter(); - CHIP_ERROR InitCounter(); - uint8_t mOpenExchangeContextCount = 0; uint8_t mCheckInRequestCount = 0; diff --git a/src/app/server/BUILD.gn b/src/app/server/BUILD.gn index 690da2354071cc..7e441518c9b133 100644 --- a/src/app/server/BUILD.gn +++ b/src/app/server/BUILD.gn @@ -62,6 +62,11 @@ static_library("server") { "${chip_root}/src/transport", ] + # TODO: Server.cpp uses TestGroupData.h. Unsure why test code would be in such a central place + # This dependency is split since it should probably be removed (or naming should + # be updated if this is not really "testing" even though headers are Test*.h) + public_deps += [ "${chip_root}/src/lib/support:testing" ] + if (chip_enable_icd_server) { public_deps += [ "${chip_root}/src/app/icd/server:notifier" ] } diff --git a/src/app/server/Dnssd.cpp b/src/app/server/Dnssd.cpp index e91ef563007cfb..dfb1fc4d6062a4 100644 --- a/src/app/server/Dnssd.cpp +++ b/src/app/server/Dnssd.cpp @@ -48,9 +48,6 @@ void OnPlatformEvent(const DeviceLayer::ChipDeviceEvent * event) { case DeviceLayer::DeviceEventType::kDnssdInitialized: case DeviceLayer::DeviceEventType::kDnssdRestartNeeded: -#if CHIP_CONFIG_ENABLE_ICD_SERVER - case DeviceLayer::DeviceEventType::kICDPollingIntervalChange: -#endif app::DnssdServer::Instance().StartServer(); break; default: @@ -499,7 +496,7 @@ CHIP_ERROR DnssdServer::GenerateRotatingDeviceId(char rotatingDeviceIdHexBuffer[ void DnssdServer::OnICDModeChange() { // ICDMode changed, restart DNS-SD advertising, because SII and ICD key are affected by this change. - // StartServer will take care of setting the operational and commissionable advertissements + // StartServer will take care of setting the operational and commissionable advertisements StartServer(); } diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn index 88311e2b414e58..245e939fc39799 100644 --- a/src/app/tests/BUILD.gn +++ b/src/app/tests/BUILD.gn @@ -213,6 +213,7 @@ chip_test_suite_using_nltest("tests") { "${chip_root}/src/app/util/mock:mock_ember", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support:test_utils", + "${chip_root}/src/lib/support:testing", "${chip_root}/src/lib/support:testing_nlunit", "${nlunit_test_root}:nlunit-test", ] diff --git a/src/app/tests/TestCommandInteraction.cpp b/src/app/tests/TestCommandInteraction.cpp index 02b4b01b116a9f..442d155242b3ec 100644 --- a/src/app/tests/TestCommandInteraction.cpp +++ b/src/app/tests/TestCommandInteraction.cpp @@ -883,6 +883,7 @@ void TestCommandInteraction::TestCommandInvalidMessage1(nlTestSuite * apSuite, v NL_TEST_ASSERT(apSuite, mockCommandSenderDelegate.onResponseCalledTimes == 0 && mockCommandSenderDelegate.onFinalCalledTimes == 1 && mockCommandSenderDelegate.onErrorCalledTimes == 1); + NL_TEST_ASSERT(apSuite, commandSender.GetInvokeResponseMessageCount() == 0); ctx.DrainAndServiceIO(); @@ -1338,12 +1339,14 @@ void TestCommandInteraction::TestCommandSenderCommandSuccessResponseFlow(nlTestS err = commandSender.SendCommandRequest(ctx.GetSessionBobToAlice()); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(apSuite, commandSender.GetInvokeResponseMessageCount() == 0); ctx.DrainAndServiceIO(); NL_TEST_ASSERT(apSuite, mockCommandSenderDelegate.onResponseCalledTimes == 1 && mockCommandSenderDelegate.onFinalCalledTimes == 1 && mockCommandSenderDelegate.onErrorCalledTimes == 0); + NL_TEST_ASSERT(apSuite, commandSender.GetInvokeResponseMessageCount() == 1); NL_TEST_ASSERT(apSuite, GetNumActiveHandlerObjects() == 0); NL_TEST_ASSERT(apSuite, ctx.GetExchangeManager().GetNumActiveExchanges() == 0); diff --git a/src/app/tests/TestICDManager.cpp b/src/app/tests/TestICDManager.cpp index 823a98a490df7c..da549ff5062f34 100644 --- a/src/app/tests/TestICDManager.cpp +++ b/src/app/tests/TestICDManager.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,8 @@ using namespace chip; using namespace chip::app; using namespace chip::System; +using namespace chip::System::Clock; +using namespace chip::System::Clock::Literals; using TestSessionKeystoreImpl = Crypto::DefaultSessionKeystore; @@ -111,7 +114,7 @@ class TestContext : public chip::Test::AppContext CHIP_ERROR SetUp() override { ReturnErrorOnFailure(chip::Test::AppContext::SetUp()); - mICDManager.Init(&testStorage, &GetFabricTable(), &mKeystore, &GetExchangeManager(), &mSubManager); + mICDManager.Init(&testStorage, &GetFabricTable(), &mKeystore, &GetExchangeManager(), &mSubInfoProvider); mICDManager.RegisterObserver(&mICDStateObserver); return CHIP_NO_ERROR; } @@ -126,12 +129,12 @@ class TestContext : public chip::Test::AppContext System::Clock::Internal::MockClock mMockClock; TestSessionKeystoreImpl mKeystore; app::ICDManager mICDManager; - TestSubscriptionsInfoProvider mSubManager; + TestSubscriptionsInfoProvider mSubInfoProvider; TestPersistentStorageDelegate testStorage; + TestICDStateObserver mICDStateObserver; private: System::Clock::ClockBase * mRealClock; - TestICDStateObserver mICDStateObserver; }; } // namespace @@ -148,9 +151,9 @@ class TestICDManager * * @param time_ms: Value in milliseconds. */ - static void AdvanceClockAndRunEventLoop(TestContext * ctx, uint64_t time_ms) + static void AdvanceClockAndRunEventLoop(TestContext * ctx, Milliseconds64 time) { - ctx->mMockClock.AdvanceMonotonic(System::Clock::Timeout(time_ms)); + ctx->mMockClock.AdvanceMonotonic(time); ctx->GetIOContext().DriveIO(); } @@ -160,23 +163,23 @@ class TestICDManager // After the init we should be in Idle mode NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); - AdvanceClockAndRunEventLoop(ctx, SecondsToMilliseconds(ICDConfigurationData::GetInstance().GetIdleModeDurationSec()) + 1); + AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetIdleModeDuration() + 1_s); // Idle mode Duration expired, ICDManager transitioned to the ActiveMode. NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); - AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDurationMs() + 1); + AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDuration() + 1_ms32); // Active mode Duration expired, ICDManager transitioned to the IdleMode. NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); - AdvanceClockAndRunEventLoop(ctx, SecondsToMilliseconds(ICDConfigurationData::GetInstance().GetIdleModeDurationSec()) + 1); + AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetIdleModeDuration() + 1_s); // Idle mode Duration expired, ICDManager transitioned to the ActiveMode. NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); // Events updating the Operation to Active mode can extend the current active mode time by 1 Active mode threshold. // Kick an active Threshold just before the end of the ActiveMode duration and validate that the active mode is extended. - AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDurationMs() - 1); + AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDuration() - 1_ms32); ICDNotifier::GetInstance().NotifyNetworkActivityNotification(); - AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeThresholdMs() / 2); + AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeThreshold() / 2); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); - AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeThresholdMs()); + AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeThreshold()); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); } @@ -194,25 +197,25 @@ class TestICDManager ctx->mICDManager.SetTestFeatureMapValue(0x07); // Set that there are no matching subscriptions - ctx->mSubManager.SetReturnValue(false); + ctx->mSubInfoProvider.SetReturnValue(false); // Set New durations for test case - uint32_t oldActiveModeDuration_ms = icdConfigData.GetActiveModeDurationMs(); - icdConfigData.SetModeDurations(MakeOptional(static_cast(0)), NullOptional); + Milliseconds32 oldActiveModeDuration = icdConfigData.GetActiveModeDuration(); + icdConfigData.SetModeDurations(MakeOptional(0), NullOptional); // Verify That ICDManager starts in Idle NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); // Reset IdleModeInterval since it was started before the ActiveModeDuration change - AdvanceClockAndRunEventLoop(ctx, SecondsToMilliseconds(icdConfigData.GetIdleModeDurationSec()) + 1); + AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetIdleModeDuration() + 1_s); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); // Force the device to return to IdleMode - Increase time by ActiveModeThreshold since ActiveModeDuration is now 0 - AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetActiveModeThresholdMs() + 1); + AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetActiveModeThreshold() + 1_ms16); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); // Expire Idle mode duration; ICDManager should remain in IdleMode since it has no message to send - AdvanceClockAndRunEventLoop(ctx, SecondsToMilliseconds(icdConfigData.GetIdleModeDurationSec()) + 1); + AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetIdleModeDuration() + 1_s); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); // Add an entry to the ICDMonitoringTable @@ -236,11 +239,11 @@ class TestICDManager NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); // Return the device to return to IdleMode - Increase time by ActiveModeThreshold since ActiveModeDuration is 0 - AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetActiveModeThresholdMs() + 1); + AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetActiveModeThreshold() + 1_ms16); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); // Expire IdleModeDuration - Device should be in ActiveMode since it has an ICDM registration - AdvanceClockAndRunEventLoop(ctx, SecondsToMilliseconds(icdConfigData.GetIdleModeDurationSec()) + 1); + AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetIdleModeDuration() + 1_s); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); // Remove entry from the fabric - ICDManager won't have any messages to send @@ -248,15 +251,15 @@ class TestICDManager NL_TEST_ASSERT(aSuite, table.IsEmpty()); // Return the device to return to IdleMode - Increase time by ActiveModeThreshold since ActiveModeDuration is 0 - AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetActiveModeThresholdMs() + 1); + AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetActiveModeThreshold() + 1_ms16); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); // Expire Idle mode duration; ICDManager should remain in IdleMode since it has no message to send - AdvanceClockAndRunEventLoop(ctx, SecondsToMilliseconds(icdConfigData.GetIdleModeDurationSec()) + 1); + AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetIdleModeDuration() + 1_s); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); // Reset Old durations - icdConfigData.SetModeDurations(MakeOptional(oldActiveModeDuration_ms), NullOptional); + icdConfigData.SetModeDurations(MakeOptional(oldActiveModeDuration), NullOptional); } /** @@ -273,25 +276,25 @@ class TestICDManager ctx->mICDManager.SetTestFeatureMapValue(0x07); // Set that there are not matching subscriptions - ctx->mSubManager.SetReturnValue(true); + ctx->mSubInfoProvider.SetReturnValue(true); // Set New durations for test case - uint32_t oldActiveModeDuration_ms = icdConfigData.GetActiveModeDurationMs(); - icdConfigData.SetModeDurations(MakeOptional(static_cast(0)), NullOptional); + Milliseconds32 oldActiveModeDuration = icdConfigData.GetActiveModeDuration(); + icdConfigData.SetModeDurations(MakeOptional(0), NullOptional); // Verify That ICDManager starts in Idle NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); // Reset IdleModeInterval since it was started before the ActiveModeDuration change - AdvanceClockAndRunEventLoop(ctx, SecondsToMilliseconds(icdConfigData.GetIdleModeDurationSec()) + 1); + AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetIdleModeDuration() + 1_s); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); // Force the device to return to IdleMode - Increase time by ActiveModeThreshold since ActiveModeDuration is now 0 - AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetActiveModeThresholdMs() + 1); + AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetActiveModeThreshold() + 1_ms16); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); // Expire Idle mode duration; ICDManager should remain in IdleMode since it has no message to send - AdvanceClockAndRunEventLoop(ctx, SecondsToMilliseconds(icdConfigData.GetIdleModeDurationSec()) + 1); + AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetIdleModeDuration() + 1_s); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); // Add an entry to the ICDMonitoringTable @@ -315,11 +318,11 @@ class TestICDManager NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); // Return the device to return to IdleMode - Increase time by ActiveModeThreshold since ActiveModeDuration is 0 - AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetActiveModeThresholdMs() + 1); + AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetActiveModeThreshold() + 1_ms16); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); // Expire IdleModeDuration - Device stay in IdleMode since it has an active subscription for the ICDM entry - AdvanceClockAndRunEventLoop(ctx, SecondsToMilliseconds(icdConfigData.GetIdleModeDurationSec()) + 1); + AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetIdleModeDuration() + 1_s); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); // Remove entry from the fabric @@ -338,15 +341,15 @@ class TestICDManager NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); // Return the device to return to IdleMode - Increase time by ActiveModeThreshold since ActiveModeDuration is 0 - AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetActiveModeThresholdMs() + 1); + AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetActiveModeThreshold() + 1_ms16); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); // Expire Idle mode duration; ICDManager should remain in IdleMode since it has no message to send - AdvanceClockAndRunEventLoop(ctx, SecondsToMilliseconds(icdConfigData.GetIdleModeDurationSec()) + 1); + AdvanceClockAndRunEventLoop(ctx, icdConfigData.GetIdleModeDuration() + 1_s); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); // Reset Old durations - icdConfigData.SetModeDurations(MakeOptional(oldActiveModeDuration_ms), NullOptional); + icdConfigData.SetModeDurations(MakeOptional(oldActiveModeDuration), NullOptional); } static void TestKeepActivemodeRequests(nlTestSuite * aSuite, void * aContext) @@ -359,7 +362,7 @@ class TestICDManager notifier.NotifyActiveRequestNotification(ActiveFlag::kCommissioningWindowOpen); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); // Advance time so active mode duration expires. - AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDurationMs() + 1); + AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDuration() + 1_ms32); // Requirement flag still set. We stay in active mode NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); @@ -373,12 +376,12 @@ class TestICDManager // Advance time, but by less than the active mode duration and remove the requirement. // We should stay in active mode. - AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDurationMs() / 2); + AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDuration() / 2); notifier.NotifyActiveRequestWithdrawal(ActiveFlag::kFailSafeArmed); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); // Advance time again, The activemode duration is completed. - AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDurationMs() + 1); + AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDuration() + 1_ms32); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); // Set two requirements @@ -386,7 +389,7 @@ class TestICDManager notifier.NotifyActiveRequestNotification(ActiveFlag::kExchangeContextOpen); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); // advance time so the active mode duration expires. - AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDurationMs() + 1); + AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDuration() + 1_ms32); // A requirement flag is still set. We stay in active mode. NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); @@ -504,10 +507,16 @@ class TestICDManager static void TestICDCounter(nlTestSuite * aSuite, void * aContext) { TestContext * ctx = static_cast(aContext); - uint32_t counter = ICDConfigurationData::GetInstance().GetICDCounter(); - ctx->mICDManager.IncrementCounter(); - uint32_t counter2 = ICDConfigurationData::GetInstance().GetICDCounter(); - NL_TEST_ASSERT(aSuite, (counter + 1) == counter2); + uint32_t counter = ICDConfigurationData::GetInstance().GetICDCounter().GetValue(); + + // Shut down and reinit ICDManager to increment counter + ctx->mICDManager.Shutdown(); + ctx->mICDManager.Init(&(ctx->testStorage), &(ctx->GetFabricTable()), &(ctx->mKeystore), &(ctx->GetExchangeManager()), + &(ctx->mSubInfoProvider)); + ctx->mICDManager.RegisterObserver(&(ctx->mICDStateObserver)); + + NL_TEST_ASSERT_EQUALS(aSuite, counter + ICDConfigurationData::kICDCounterPersistenceIncrement, + ICDConfigurationData::GetInstance().GetICDCounter().GetValue()); } static void TestOnSubscriptionReport(nlTestSuite * aSuite, void * aContext) @@ -526,7 +535,7 @@ class TestICDManager notifier.NotifySubscriptionReport(); // Advance time so active mode interval expires. - AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDurationMs() + 1); + AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDuration() + 1_ms32); // After the init we should be in Idle mode NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); diff --git a/src/app/tests/suites/TestIcdManagementCluster.yaml b/src/app/tests/suites/TestIcdManagementCluster.yaml index 3d69afd7744af8..f8a853c5fe09e7 100644 --- a/src/app/tests/suites/TestIcdManagementCluster.yaml +++ b/src/app/tests/suites/TestIcdManagementCluster.yaml @@ -18,6 +18,9 @@ config: nodeId: 0x12344321 cluster: "ICD Management" endpoint: 0 + beforeRebootICDCounter: + type: int32u + defaultValue: 0 tests: - label: "Read the commissioner node ID" @@ -36,6 +39,26 @@ tests: - name: "nodeId" value: nodeId + # chip-tool will register itself with the ICD during the tests. + - label: "Read RegisteredClients For Registration During Commissioning" + command: "readAttribute" + attribute: "RegisteredClients" + response: + value: + [ + { + CheckInNodeID: commissionerNodeId, + MonitoredSubject: commissionerNodeId, + }, + ] + + - label: "Unregister Client Registered During Commissioning" + command: "UnregisterClient" + arguments: + values: + - name: "CheckInNodeID" + value: commissionerNodeId + - label: "Read Feature Map" command: "readAttribute" attribute: "FeatureMap" @@ -68,6 +91,25 @@ tests: type: int32u minValue: 0x0 maxValue: 0xFFFFFFFF + saveAs: beforeRebootICDCounter + + - label: "Reboot target device" + cluster: "SystemCommands" + command: "Reboot" + + - label: "Connect to the device again" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId + + - label: "Read ICDCounter after reboot" + command: "readAttribute" + attribute: "ICDCounter" + response: + value: beforeRebootICDCounter + 100 - label: "Read UserActiveModeTriggerHint" command: "readAttribute" @@ -119,26 +161,6 @@ tests: response: error: NOT_FOUND - # chip-tool will register itself with the ICD during the tests. - - label: "Read RegisteredClients For Registration During Commissioning" - command: "readAttribute" - attribute: "RegisteredClients" - response: - value: - [ - { - CheckInNodeID: commissionerNodeId, - MonitoredSubject: commissionerNodeId, - }, - ] - - - label: "Unregister Client Registered During Commissioning" - command: "UnregisterClient" - arguments: - values: - - name: "CheckInNodeID" - value: commissionerNodeId - - label: "Register 1.0 (key too short)" command: "RegisterClient" arguments: diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index 09d55dff5881b3..205955b9ebdeb2 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -5781,7 +5781,7 @@ PICS: - label: "Write all supported optional attributes" id: RH.C.AO-WRITE - # Scenes Cluster Test Plan + # Scenes Management Cluster Test Plan - label: "Does the device implement the Scenes cluster as a server?" id: S.S @@ -5870,11 +5870,6 @@ PICS: - label: "Does the device implement sending the CopyScene command?" id: S.C.C40.Tx - - label: - "Does the device process the TransitionTime parameter of the - RecallScene command?" - id: PICS_SC_RECALL_SCENE_TRANSITION_TIME_MS - # # client / manually # diff --git a/src/app/tests/suites/certification/Test_TC_DGGEN_1_1.yaml b/src/app/tests/suites/certification/Test_TC_DGGEN_1_1.yaml index 7342101677e115..fc10b3d02eeaba 100644 --- a/src/app/tests/suites/certification/Test_TC_DGGEN_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_DGGEN_1_1.yaml @@ -43,7 +43,6 @@ tests: command: "readAttribute" attribute: "FeatureMap" response: - value: 0 constraints: type: bitmap32 @@ -178,6 +177,6 @@ tests: command: "readAttribute" attribute: "GeneratedCommandList" response: - value: [2] constraints: type: list + contains: [2] diff --git a/src/app/tests/suites/certification/Test_TC_IDM_1_3.yaml b/src/app/tests/suites/certification/Test_TC_IDM_1_3.yaml index 3cd059db6e8e73..de5625a8d11ad4 100644 --- a/src/app/tests/suites/certification/Test_TC_IDM_1_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_IDM_1_3.yaml @@ -46,7 +46,7 @@ tests: test step can be simulated using chip-repl (when DUT is a commissioner/Client). The cluster used in the below command is an example, User can use any supported chip cluster/attribute/command. Note in this example the unique path is created by using 2 different endpoints. - `await devCtrl.SendBatchCommands(0x12344321, [Clusters.Command.InvokeRequestInfo(1, Clusters.OnOff.Commands.Toggle()), Clusters.Command.InvokeRequestInfo(2, Clusters.OnOff.Commands.Toggle())]` + `await devCtrl.SendBatchCommands(0x12344321, [chip.clusters.Command.InvokeRequestInfo(1, chip.clusters.OnOff.Commands.Toggle()), chip.clusters.Command.InvokeRequestInfo(2, chip.clusters.OnOff.Commands.Toggle())])` On TH(all-clusters-app), Verify that the EndpointIDs, CommandIDs, ClusterIDs in the InvokeRequestMessage (as below) matching with the data sent in the above command @@ -110,7 +110,7 @@ tests: test step can be simulated using chip-repl (when DUT is a commissioner/Client). The cluster used in the below command is an example, User can use any supported chip cluster/attribute/command. Note in this example the unique path is created by using 2 different endpoints. - `await devCtrl.SendBatchCommands(0x12344321, [Clusters.Command.InvokeRequestInfo(1, Clusters.OnOff.Commands.Toggle()), Clusters.Command.InvokeRequestInfo(2, Clusters.OnOff.Commands.Toggle())]` + `await devCtrl.SendBatchCommands(0x12344321, [chip.clusters.Command.InvokeRequestInfo(1, chip.clusters.OnOff.Commands.Toggle()), chip.clusters.Command.InvokeRequestInfo(2, chip.clusters.OnOff.Commands.Toggle())])` Verify DUT doesn't crash by seeing next step execute. disabled: true @@ -131,7 +131,7 @@ tests: test step can be simulated using chip-repl (when DUT is a commissioner/Client). The cluster used in the below command is an example, User can use any supported chip cluster/attribute/command. Note in this example the unique path is created by using 2 different endpoints. - `await devCtrl.SendBatchCommands(0x12344321, [Clusters.Command.InvokeRequestInfo(1, Clusters.OnOff.Commands.Toggle()), Clusters.Command.InvokeRequestInfo(2, Clusters.OnOff.Commands.Toggle())]` + `await devCtrl.SendBatchCommands(0x12344321, [chip.clusters.Command.InvokeRequestInfo(1, chip.clusters.OnOff.Commands.Toggle()), chip.clusters.Command.InvokeRequestInfo(2, chip.clusters.OnOff.Commands.Toggle())])` Verify DUT doesn't crash by seeing next step execute. disabled: true @@ -152,7 +152,7 @@ tests: test step can be simulated using chip-repl (when DUT is a commissioner/Client). The cluster used in the below command is an example, User can use any supported chip cluster/attribute/command. Note in this example the unique path is created by using 2 different endpoints. - `await devCtrl.SendBatchCommands(0x12344321, [Clusters.Command.InvokeRequestInfo(1, Clusters.OnOff.Commands.Toggle()), Clusters.Command.InvokeRequestInfo(2, Clusters.OnOff.Commands.Toggle())]` + `await devCtrl.SendBatchCommands(0x12344321, [chip.clusters.Command.InvokeRequestInfo(1, chip.clusters.OnOff.Commands.Toggle()), chip.clusters.Command.InvokeRequestInfo(2, chip.clusters.OnOff.Commands.Toggle())])` Verify DUT doesn't crash by seeing next step execute. disabled: true @@ -169,7 +169,7 @@ tests: test step can be simulated using chip-repl (when DUT is a commissioner/Client). The cluster used in the below command is an example, User can use any supported chip cluster/attribute/command. Note in this example the unique path is created by using 2 different endpoints. - `await devCtrl.SendCommands(0x12344321, 1, Clusters.OnOff.Commands.Toggle())` + `await devCtrl.SendCommand(0x12344321, 1, chip.clusters.OnOff.Commands.Toggle())` On TH(all-clusters-app), Verify that we recieves an InvokeRequestMessage that contains a single InvokeRequests diff --git a/src/app/tests/suites/certification/Test_TC_S_1_1.yaml b/src/app/tests/suites/certification/Test_TC_S_1_1.yaml index 9b5eb4dbb4b155..36314424458714 100644 --- a/src/app/tests/suites/certification/Test_TC_S_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_1_1.yaml @@ -110,7 +110,7 @@ tests: contains: [0, 1, 2, 3, 4, 6] - label: - "Step 7b: Read optional command(CopySceneResponse) in + "Step 7b: TH reads Read optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528)" PICS: S.S.C40.Rsp command: "readAttribute" diff --git a/src/app/tests/suites/certification/Test_TC_S_2_2.yaml b/src/app/tests/suites/certification/Test_TC_S_2_2.yaml index 627bbe088f9420..d569b12d512a8a 100644 --- a/src/app/tests/suites/certification/Test_TC_S_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_2_2.yaml @@ -28,6 +28,9 @@ config: G2: type: group_id defaultValue: 0x0002 + GI: + type: group_id + defaultValue: 0x0099 tests: - label: "Wait for the commissioned device to be retrieved" @@ -78,8 +81,9 @@ tests: value: maxScenesMinusOne / 2 - label: - "Step 0a: preparation step for using commands from Groups cluster: Add - KeySet" + "Step 0a :TH sends KeySetWrite command in the GroupKeyManagement + cluster to DUT using a key that is pre-installed on the TH. + GroupKeySet fields are as follows:" cluster: "Group Key Management" endpoint: 0 command: "KeySetWrite" @@ -99,8 +103,9 @@ tests: } - label: - "Step 0b: Preparation step for using commands from Groups cluster: - Write Group Keys" + "Step 0b: TH binds GroupIds 0x0001 and 0x0002 with GroupKeySetID + 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster + by writing the GroupKeyMap attribute with two entries as follows:" cluster: "Group Key Management" endpoint: 0 command: "writeAttribute" @@ -154,7 +159,24 @@ tests: value: G1 - label: - "Step 1c: TH sends a GetSceneMembership command to DUT with the + "Step 1c: TH sends a RemoveAllScenes command to DUT with the GroupID + field set to GI (Where GI is a group currently absent from the group + table)." + PICS: S.S.C03.Rsp + command: "RemoveAllScenes" + arguments: + values: + - name: "GroupID" + value: GI + response: + values: + - name: "Status" + value: 0x85 + - name: "GroupID" + value: GI + + - label: + "Step 1d: TH sends a GetSceneMembership command to DUT with the GroupID field set to G1." PICS: S.S.C06.Rsp command: "GetSceneMembership" @@ -172,7 +194,28 @@ tests: value: G1 - label: - "STep 2a: TH configures AC1 on DUT for all implemented application + "Step 1e: TH sends a GetSceneMembership command to DUT with the + GroupID field set to GI (Where GI is a group currently absent from the + group table)." + PICS: S.S.C06.Rsp + command: "GetSceneMembership" + arguments: + values: + - name: "GroupID" + value: GI + response: + values: + - name: "Status" + value: 0x85 + - name: "Capacity" + constraints: + anyOf: [fabricCapacity, 0xfe, null] + value: null + - name: "GroupID" + value: GI + + - label: + "Step 2a: TH configures AC1 on DUT for all implemented application clusters supporting scenes." PICS: PICS_SDK_CI_ONLY cluster: "Level Control" @@ -225,6 +268,27 @@ tests: - name: "SceneID" value: 0x01 + - label: + "Step 2c: TH sends a StoreScene command to DUT with the GroupID field + set to GI (Where GI is a group currently absent from the group table) + and the SceneID field set to 0x01." + PICS: S.S.C04.Rsp + command: "StoreScene" + arguments: + values: + - name: "GroupID" + value: GI + - name: "SceneID" + value: 0x01 + response: + values: + - name: "Status" + value: 0x85 + - name: "GroupID" + value: GI + - name: "SceneID" + value: 0x01 + - label: "Step 3a: TH configures AC2 on DUT for all implemented application clusters supporting scenes." @@ -369,7 +433,7 @@ tests: value: 0x01 - label: - "Step 5: TH sends a ViewScene command to DUT with the GroupID field + "Step 5a: TH sends a ViewScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01." PICS: S.S.C01.Rsp && PICS_SDK_CI_ONLY command: "ViewScene" @@ -417,7 +481,7 @@ tests: ] - label: - "Step 5: TH sends a ViewScene command to DUT with the GroupID field + "Step 5a: TH sends a ViewScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01." PICS: S.S.C01.Rsp && PICS_SKIP_SAMPLE_APP command: "ViewScene" @@ -438,6 +502,47 @@ tests: - name: "TransitionTime" value: 0x0000 + - label: + "Step 5b: TH sends a ViewScene command to DUT with the GroupID field + set to GI (Where GI is a group currently absent from the group table) + and the SceneID field set to 0x01." + PICS: S.S.C01.Rsp + command: "ViewScene" + arguments: + values: + - name: "GroupID" + value: GI + - name: "SceneID" + value: 0x01 + response: + values: + - name: "Status" + value: 0x85 + - name: "GroupID" + value: GI + - name: "SceneID" + value: 0x01 + + - label: + "Step 5c: TH sends a ViewScene command to DUT with the GroupID field + set to G1 and the SceneID field set to 0xFE." + PICS: S.S.C01.Rsp + command: "ViewScene" + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0xFE + response: + values: + - name: "Status" + value: 0x8b + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0xFE + - label: "Step 6: TH sends a GetSceneMembership command to DUT with the GroupID field set to G1." @@ -489,44 +594,15 @@ tests: value: 0x00 - name: "Capacity" constraints: - anyOf: [fabricCapacity, 0xfe, 0x89] + anyOf: [fabricCapacity, 0xfe, null] - name: "GroupID" value: G1 - label: "Step 8a: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set - to 7 000 000 (7 000s) and no extension field sets. This should fail - and return a status of 0x85 (INVALID_COMMAND) because we exceed the - max TransitionTime" - #TODO Add to chip-test-plan - PICS: S.S.C00.Rsp && PICS_SDK_CI_ONLY - command: "AddScene" - arguments: - values: - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x01 - - name: "TransitionTime" - value: 7000000 - - name: "SceneName" - value: "Scene1" - - name: "ExtensionFieldSets" - value: [] - response: - values: - - name: "Status" - value: 0x85 - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x01 - - - label: - "Step 8b: TH sends a AddScene command to DUT with the GroupID field - set to G1, the SceneID field set to 0x01, the TransitionTime field set - to 1000 (1s) and a set of extension fields appropriate to AC1." + to 60 000 000 (60 000s) and a set of extension fields appropriate to + AC1." PICS: S.S.C00.Rsp && PICS_SDK_CI_ONLY command: "AddScene" arguments: @@ -536,7 +612,7 @@ tests: - name: "SceneID" value: 0x01 - name: "TransitionTime" - value: 1000 + value: 60000000 - name: "SceneName" value: "Scene1" - name: "ExtensionFieldSets" @@ -563,13 +639,12 @@ tests: value: 0x01 - label: - "Step 8b: TH sends a AddScene command to DUT with the GroupID field + "Step 8a: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set - to 1000 (1s) and a set of extension fields appropriate to AC1." + to 60 000 000 (60 000s) and a set of extension fields appropriate to + AC1." verification: | - Execute the following command in TH to generate the pre-condition to execute this test case: - - ./chip-tool scenes add-scene 0x0001 1 1 "Test Name" '[{"clusterId": value, "attributeValueList":[{"attributeId": value, "attributeValue": value}]}' nodeId endpointId + ./chip-tool scenes add-scene 0x0001 1 60000000 "Test Name" '[{"clusterId": value, "attributeValueList":[{"attributeId": value, "attributeValue": value}]}' nodeId endpointId Note: The number of ExtensionFieldSets, the value of clusterId of each ExtensionFieldSet, the number of attributes in attributeValueList and their values varies for each application @@ -624,6 +699,34 @@ tests: - name: "expectedValue" value: "y" + - label: + "Step 8b: TH sends a AddScene command to DUT with the GroupID field + set to GI (Where GI is a group currently absent from the group table), + the SceneID field set to 0x01, the TransitionTime field set to 1000 + (1s) and a set of extension fields appropriate to AC1." + PICS: S.S.C00.Rsp + command: "AddScene" + arguments: + values: + - name: "GroupID" + value: GI + - name: "SceneID" + value: 0x01 + - name: "TransitionTime" + value: 1000 + - name: "SceneName" + value: "Scene1" + - name: "ExtensionFieldSets" + value: [] + response: + values: + - name: "Status" + value: 0x85 + - name: "GroupID" + value: GI + - name: "SceneID" + value: 0x01 + - label: "Step 8c: TH sends a GetSceneMembership command to DUT with the GroupID field set to G1." @@ -645,6 +748,62 @@ tests: - name: "SceneList" value: [0x01] + - label: + "Step 8d: TH sends a AddScene command to DUT with the GroupID field + set to G1, the SceneID field set to 0x01, the TransitionTime field set + to 70 000 000 (70 000s) and no extension field sets. This should fail + and return a status of 0x85 (INVALID_COMMAND)." + PICS: S.S.C00.Rsp && PICS_SDK_CI_ONLY + command: "AddScene" + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x01 + - name: "TransitionTime" + value: 70000000 + - name: "SceneName" + value: "Scene1" + - name: "ExtensionFieldSets" + value: [] + response: + values: + - name: "Status" + value: 0x85 + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x01 + + - label: + "Step 8e: TH sends a AddScene command to DUT with the GroupID field + set to G1, the SceneID field set to 0x01, the TransitionTime field set + to 60 000 001 (60 000.001s) and no extension field sets. This should + fail and return a status of 0x85 (INVALID_COMMAND)." + PICS: S.S.C00.Rsp && PICS_SDK_CI_ONLY + command: "AddScene" + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x01 + - name: "TransitionTime" + value: 60000001 + - name: "SceneName" + value: "Scene1" + - name: "ExtensionFieldSets" + value: [] + response: + values: + - name: "Status" + value: 0x85 + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x01 + - label: "Step 9a: TH sends a RemoveScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01." @@ -666,7 +825,48 @@ tests: value: 0x01 - label: - "Step 9b: TH sends a GetSceneMembership command to DUT with the + "Step 9b: TH sends a RemoveScene command to DUT with the GroupID field + set to GI (Where GI is a group currently absent from the group table) + and the SceneID field set to 0x01." + PICS: S.S.C02.Rsp + command: "RemoveScene" + arguments: + values: + - name: "GroupID" + value: GI + - name: "SceneID" + value: 0x01 + response: + values: + - name: "Status" + value: 0x85 + - name: "GroupID" + value: GI + - name: "SceneID" + value: 0x01 + + - label: + "Step 9c: TH sends a RemoveScene command to DUT with the GroupID field + set to G1 and the SceneID field set to 0x01." + PICS: S.S.C02.Rsp + command: "RemoveScene" + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x01 + response: + values: + - name: "Status" + value: 0x8b + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x01 + + - label: + "Step 9d: TH sends a GetSceneMembership command to DUT with the GroupID field set to G1." PICS: S.S.C06.Rsp command: "GetSceneMembership" diff --git a/src/app/tests/suites/certification/Test_TC_S_2_3.yaml b/src/app/tests/suites/certification/Test_TC_S_2_3.yaml index 156bf45579e400..21549a843b29ac 100644 --- a/src/app/tests/suites/certification/Test_TC_S_2_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_2_3.yaml @@ -25,6 +25,12 @@ config: G1: type: group_id defaultValue: 0x0101 + G2: + type: group_id + defaultValue: 0x0102 + GI: + type: group_id + defaultValue: 0x0099 tests: - label: "Wait for the commissioned device to be retrieved" @@ -79,10 +85,10 @@ tests: cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a1 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: - d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 - 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: - 2220001 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf - 8)EpochStartTime2: 2220002" + a0a1a2a3a4a5a6a7a8a9aaabacadaeaf 4)EpochStartTime0: 1110000 + 5)EpochKey1: b0b1b2b3b4b5b6b7b8b9babbbcbdbebf 6)EpochStartTime1: + 1110001 7)EpochKey2: c0c1c2c3c4c5c6c7c8c9cacbcccdcecf + 8)EpochStartTime2: 1110002" cluster: "Group Key Management" endpoint: 0 command: "KeySetWrite" @@ -102,7 +108,34 @@ tests: } - label: - "Step 0b: TH binds GroupId G1 with GroupKeySetID 0x01a1 in the + "Step 0b: TH sends KeySetWrite command in the GroupKeyManagement + cluster to DUT using a key that is pre-installed on the TH. + GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a2 + 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: + d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 + 5)EpochKey1: e0e1e2e3e4e5e6e7e8e9eaebecedeeef 6)EpochStartTime1: + 2220001 7)EpochKey2: f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff + 8)EpochStartTime2: 2220002" + cluster: "Group Key Management" + endpoint: 0 + command: "KeySetWrite" + arguments: + values: + - name: "GroupKeySet" + value: + { + GroupKeySetID: 0x01a2, + GroupKeySecurityPolicy: 0, + EpochKey0: "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf", + EpochStartTime0: 2220000, + EpochKey1: "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef", + EpochStartTime1: 2220001, + EpochKey2: "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", + EpochStartTime2: 2220002, + } + + - label: + "Step 0c: TH binds GroupId G1 with GroupKeySetID 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster by writing the GroupKeyMap attribute with one entry as follows: List item 1: 1)FabricIndex: 1 2)GroupId :_G1_ 3)GroupKeySetId: 0x01a1" @@ -111,7 +144,11 @@ tests: command: "writeAttribute" attribute: "GroupKeyMap" arguments: - value: [{ FabricIndex: 1, GroupId: G1, GroupKeySetID: 0x01a1 }] + value: + [ + { FabricIndex: 1, GroupId: G1, GroupKeySetID: 0x01a1 }, + { FabricIndex: 1, GroupId: G2, GroupKeySetID: 0x01a2 }, + ] - label: "Step 1a: TH sends a AddGroup command to DUT with the GroupID field @@ -132,7 +169,26 @@ tests: - name: "GroupID" value: G1 - - label: "Install ACLs" + - label: + "Step 1b: TH sends a AddGroup command to DUT with the GroupID field + set to G2." + PICS: G.S.C00.Rsp + cluster: "Groups" + command: "AddGroup" + arguments: + values: + - name: "GroupID" + value: G2 + - name: "GroupName" + value: "Group #2" + response: + values: + - name: "Status" + value: 0x00 + - name: "GroupID" + value: G2 + + - label: "Step 1c: Install ACLs" cluster: "Access Control" endpoint: 0 command: "writeAttribute" @@ -158,7 +214,7 @@ tests: ] - label: - "Step 1b: TH sends a RemoveAllScenes command to DUT with the GroupID + "Step 1d: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1." PICS: S.S.C03.Rsp command: "RemoveAllScenes" @@ -174,7 +230,23 @@ tests: value: G1 - label: - "Step 1c: TH sends a GetSceneMembership command to DUT with the + "Step 1e: TH sends a RemoveAllScenes command to DUT with the GroupID + field set to G2." + PICS: S.S.C03.Rsp + command: "RemoveAllScenes" + arguments: + values: + - name: "GroupID" + value: G2 + response: + values: + - name: "Status" + value: 0x00 + - name: "GroupID" + value: G2 + + - label: + "Step 1f: TH sends a GetSceneMembership command to DUT with the GroupID field set to G1." PICS: S.S.C06.Rsp command: "GetSceneMembership" @@ -196,7 +268,7 @@ tests: - label: "Step 2: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to - 0x0001 (1s) and a set of extension fields appropriate to AC1." + 1000 (1s) and a set of extension fields appropriate to AC1." PICS: S.S.C00.Rsp && PICS_SDK_CI_ONLY command: "AddScene" arguments: @@ -206,7 +278,7 @@ tests: - name: "SceneID" value: 0x01 - name: "TransitionTime" - value: 0x0001 + value: 1000 - name: "SceneName" value: "Scene1" - name: "ExtensionFieldSets" @@ -235,10 +307,8 @@ tests: - label: "Step 2: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to - G1 and a set of extension fields appropriate to AC1." + 1000 (1s) and a set of extension fields appropriate to AC1." verification: | - Execute the following command in TH to generate the pre-condition to execute this test case: - ./chip-tool scenes add-scene GroupID SceneID TransitionTime "SceneName" '[{"clusterId": value, "attributeValueList":[{"attributeId": value, "attributeValue": value}]}' nodeId endpointId Note: The number of ExtensionFieldSets, the value of clusterId of each ExtensionFieldSet, the number of attributes in attributeValueList and their values varies for each application @@ -314,7 +384,7 @@ tests: - name: "SceneID" value: 0x01 - name: "TransitionTime" - value: 0x0001 + value: 1000 - name: "ExtensionFieldSets" value: [ @@ -335,8 +405,6 @@ tests: set to G1 and the SceneID field set to 0x01." PICS: S.S.C01.Rsp && PICS_SKIP_SAMPLE_APP verification: | - Execute the following command in TH to generate the pre-condition to execute this test case: - ./chip-tool scenes view-scene GroupId SceneId Node-Id EndpointId Note: The number of ExtensionFieldSets, the value of clusterId of each ExtensionFieldSet, the number of attributes in attributeValueList and their values varies for each application @@ -418,8 +486,7 @@ tests: field set to G1 and the scene ID field set to 0x01." PICS: S.S.C05.Rsp command: "RecallScene" - # This value should be changed to G1 instead of 0x101 when it is supported, Issue opened here https://github.com/project-chip/connectedhomeip/issues/29637 - groupId: 0x101 + groupId: G1 arguments: values: - name: "GroupID" @@ -459,7 +526,210 @@ tests: value: "y" - label: - "Step 6a: TH sends a CopyScene command to DUT with the mode field set + "Step 6a: TH sends a AddScene command to group G1 with the GroupID + field set to G1, the SceneID field set to 0x01, the TransitionTime + field set to 1000 (1s) and a set of extension fields appropriate to + AC1." + PICS: S.S.C00.Rsp && PICS_SDK_CI_ONLY + command: "AddScene" + groupId: G1 + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x03 + - name: "TransitionTime" + value: 1000 + - name: "SceneName" + value: "Scene1" + - name: "ExtensionFieldSets" + value: + [ + { + ClusterID: 0x0006, + AttributeValueList: + [{ AttributeID: 0x0000, AttributeValue: 0x01 }], + }, + { + ClusterID: 0x0008, + AttributeValueList: + [{ AttributeID: 0x0000, AttributeValue: 0x64 }], + }, + ] + + - label: + "Step 6a: TH sends a AddScene command to group G1 with the GroupID + field set to G1, the SceneID field set to 0x03, the TransitionTime + field set to G1 and a set of extension fields appropriate to AC1." + verification: | + ./chip-tool scenes add-scene GroupID SceneID TransitionTime "SceneName" '[{"clusterId": value, "attributeValueList":[{"attributeId": value, "attributeValue": value}]}' groupID endpointId + + Note: The number of ExtensionFieldSets, the value of clusterId of each ExtensionFieldSet, the number of attributes in attributeValueList and their values varies for each application + + Verify the "status is success" on the TH(Chip-tool) Log and below is the sample log provided for the raspi platform: + [1670970505.887060][5742:5744] CHIP:DMG: InvokeResponseMessage = + [1670970505.887118][5742:5744] CHIP:DMG: { + [1670970505.887172][5742:5744] CHIP:DMG: suppressResponse = false, + [1670970505.887231][5742:5744] CHIP:DMG: InvokeResponseIBs = + [1670970505.887307][5742:5744] CHIP:DMG: [ + [1670970505.887366][5742:5744] CHIP:DMG: InvokeResponseIB = + [1670970505.887444][5742:5744] CHIP:DMG: { + [1670970505.887507][5742:5744] CHIP:DMG: CommandDataIB = + [1670970505.887576][5742:5744] CHIP:DMG: { + [1670970505.887713][5742:5744] CHIP:DMG: CommandPathIB = + [1670970505.887804][5742:5744] CHIP:DMG: { + [1670970505.887940][5742:5744] CHIP:DMG: EndpointId = 0x1, + [1670970505.888093][5742:5744] CHIP:DMG: ClusterId = 0x5, + [1670970505.888242][5742:5744] CHIP:DMG: CommandId = 0x0, + [1670970505.888385][5742:5744] CHIP:DMG: }, + [1670970505.888692][5742:5744] CHIP:DMG: + [1670970505.888769][5742:5744] CHIP:DMG: CommandFields = + [1670970505.888852][5742:5744] CHIP:DMG: { + [1670970505.889030][5742:5744] CHIP:DMG: 0x0 = 0, + [1670970505.889183][5742:5744] CHIP:DMG: 0x1 = 1, + [1670970505.889406][5742:5744] CHIP:DMG: 0x2 = 1, + [1670970505.889515][5742:5744] CHIP:DMG: }, + [1670970505.889603][5742:5744] CHIP:DMG: }, + [1670970505.889684][5742:5744] CHIP:DMG: + [1670970505.889745][5742:5744] CHIP:DMG: }, + [1670970505.889821][5742:5744] CHIP:DMG: + [1670970505.889878][5742:5744] CHIP:DMG: ], + [1670970505.889953][5742:5744] CHIP:DMG: + [1670970505.890009][5742:5744] CHIP:DMG: InteractionModelRevision = 1 + [1670970505.890066][5742:5744] CHIP:DMG: }, + cluster: "LogCommands" + command: "UserPrompt" + PICS: S.S.C00.Rsp && PICS_SKIP_SAMPLE_APP + arguments: + values: + - name: "message" + value: + "Please execute the add scene command with + extensionfieldsets in accordance with AC1 on DUT and enter + 'y' if the command is successful" + - name: "expectedValue" + value: "y" + + - label: + "Step 6b: TH sends a ViewScene command to DUT with the GroupID field + set to G1 and the SceneID field set to 0x03." + PICS: S.S.C01.Rsp && PICS_SDK_CI_ONLY + command: "ViewScene" + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x03 + response: + values: + - name: "Status" + value: 0x00 + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x03 + - name: "TransitionTime" + value: 1000 + - name: "ExtensionFieldSets" + value: + [ + { + ClusterID: 0x0006, + AttributeValueList: + [{ AttributeID: 0x0000, AttributeValue: 0x01 }], + }, + { + ClusterID: 0x0008, + AttributeValueList: + [{ AttributeID: 0x0000, AttributeValue: 0x64 }], + }, + ] + - label: + "Step 6b: TH sends a ViewScene command to DUT with the GroupID field + set to G1 and the SceneID field set to 0x03." + PICS: S.S.C01.Rsp && PICS_SKIP_SAMPLE_APP + verification: | + ./chip-tool scenes view-scene GroupId SceneId Node-Id EndpointId + + Note: The number of ExtensionFieldSets, the value of clusterId of each ExtensionFieldSet, the number of attributes in attributeValueList and their values varies for each application + + Verify that the extension fields in the log match the ones expected and that + Status = 0x00 + GroupID = G1 + SceneID = 0x03 + TransitionTime = 0x03E8 + cluster: "LogCommands" + command: "UserPrompt" + arguments: + values: + - name: "message" + value: + "Please execute the view-scene command and verify that the + extensionfieldsets, status, groupID and SceneID are in + accordance with AC1 on DUT and enter 'y' if the command is + successful" + - name: "expectedValue" + value: "y" + + - label: + "Step 6c: TH sends a ViewScene command to group G1 with the GroupID + field set to G1 and the SceneID field set to 0x03." + PICS: S.S.C01.Rsp && PICS_SDK_CI_ONLY + command: "ViewScene" + groupId: G1 + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x03 + + - label: + "Step 6d: TH sends a RemoveScene command to group G1 with the GroupID + field set to G1 and the SceneID field set to 0x03." + PICS: S.S.C02.Rsp + command: "RemoveScene" + groupId: G1 + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x03 + + - label: "Wait 1+ s to give CI time to process the RemoveScene command." + PICS: PICS_SDK_CI_ONLY + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 1250 + + - label: + "Step 6e: TH sends a ViewScene command to DUT with the GroupID field + set to G1 and the SceneID field set to 0x03." + PICS: S.S.C01.Rsp && PICS_SDK_CI_ONLY + command: "ViewScene" + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x03 + response: + values: + - name: "Status" + value: 0x8b + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x03 + + - label: + "Step 7a: TH sends a CopyScene command to DUT with the mode field set to 0x00, the group identifier from field set to G1, the scene identifier from field set to 0x01, the group identifier to field set to G1 and the scene identifier to field set to 0x02." @@ -487,7 +757,64 @@ tests: value: 0x01 - label: - "Step 6b: TH sends a GetSceneMembership command to DUT with the + "Step 7b: TH sends a CopyScene command to DUT with the mode field set + to 0x00, the group identifier from field set to GI (Where GI is a + group currently absent from the group table), the scene identifier + from field set to 0x01, the group identifier to field set to GI and + the scene identifier to field set to 0x02." + PICS: S.S.C40.Rsp + command: "CopyScene" + arguments: + values: + - name: "Mode" + value: 0x00 + - name: "GroupIdentifierFrom" + value: GI + - name: "SceneIdentifierFrom" + value: 0x01 + - name: "GroupIdentifierTo" + value: GI + - name: "SceneIdentifierTo" + value: 0x02 + response: + values: + - name: "Status" + value: 0x85 + - name: "GroupIdentifierFrom" + value: GI + - name: "SceneIdentifierFrom" + value: 0x01 + + - label: + "Step 7c: TH sends a CopyScene command to DUT with the mode field set + to 0x00, the group identifier from field set to G1, the scene + identifier from field set to 0xFE, the group identifier to field set + to G1 and the scene identifier to field set to 0x02." + PICS: S.S.C40.Rsp + command: "CopyScene" + arguments: + values: + - name: "Mode" + value: 0x00 + - name: "GroupIdentifierFrom" + value: G1 + - name: "SceneIdentifierFrom" + value: 0xFE + - name: "GroupIdentifierTo" + value: G1 + - name: "SceneIdentifierTo" + value: 0x02 + response: + values: + - name: "Status" + value: 0x8b + - name: "GroupIdentifierFrom" + value: G1 + - name: "SceneIdentifierFrom" + value: 0xFE + + - label: + "Step 7d: TH sends a GetSceneMembership command to DUT with the GroupID field set to G1." PICS: S.S.C06.Rsp command: "GetSceneMembership" @@ -507,7 +834,179 @@ tests: value: [0x01, 0x02] - label: - "Step 7: TH removes the Group key set that was added by sending a + "Step 8a: TH sends a CopyScene command to DUT with the mode field set + to 0x01, the group identifier from field set to G1, the scene + identifier from field set to 0x01, the group identifier to field set + to G2 and the scene identifier to field set to 0x02." + PICS: S.S.C40.Rsp + command: "CopyScene" + arguments: + values: + - name: "Mode" + value: 0x01 + - name: "GroupIdentifierFrom" + value: G1 + - name: "SceneIdentifierFrom" + value: 01 + - name: "GroupIdentifierTo" + value: G2 + - name: "SceneIdentifierTo" + value: 0x02 + response: + values: + - name: "Status" + value: 0x00 + - name: "GroupIdentifierFrom" + value: G1 + - name: "SceneIdentifierFrom" + value: 0x01 + - label: + "Step 8b: TH sends a GetSceneMembership command to DUT with the + GroupID field set to G2." + PICS: S.S.C06.Rsp + command: "GetSceneMembership" + arguments: + values: + - name: "GroupID" + value: G2 + response: + values: + - name: "Status" + value: 0x00 + - name: "Capacity" + constraints: + anyOf: [fabricCapacity - 4, 0xfe, null] + - name: "GroupID" + value: G2 + - name: "SceneList" + value: [0x01, 0x02] + + - label: + "Step 8c: TH sends a CopyScene command to group G2 with the mode field + set to 0x00, the group identifier from field set to G2, the scene + identifier from field set to 0x02, the group identifier to field set + to G2 and the scene identifier to field set to 0x03." + PICS: S.S.C40.Rsp + command: "CopyScene" + groupId: G2 + arguments: + values: + - name: "Mode" + value: 0x00 + - name: "GroupIdentifierFrom" + value: G2 + - name: "SceneIdentifierFrom" + value: 02 + - name: "GroupIdentifierTo" + value: G2 + - name: "SceneIdentifierTo" + value: 0x03 + + - label: + "Step 8d: TH sends a GetSceneMembership command to DUT with the + GroupID field set to G2." + PICS: S.S.C06.Rsp + command: "GetSceneMembership" + arguments: + values: + - name: "GroupID" + value: G2 + response: + values: + - name: "Status" + value: 0x00 + - name: "Capacity" + constraints: + anyOf: [fabricCapacity - 5, 0xfe, null] + - name: "GroupID" + value: G2 + - name: "SceneList" + value: [0x01, 0x02, 0x03] + + - label: + "Step 9a: TH sends a RemoveAllScenes command to group G1 with the + GroupID field set to G1." + PICS: S.S.C03.Rsp + command: "RemoveAllScenes" + groupId: G1 + arguments: + values: + - name: "GroupID" + value: G1 + + - label: "Wait 1+ s to give CI time to process the RemoveScene command." + PICS: PICS_SDK_CI_ONLY + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 1250 + + - label: + "Step 9b: TH sends a GetSceneMembership command to DUT with the + GroupID field set to G1." + PICS: S.S.C06.Rsp + command: "GetSceneMembership" + arguments: + values: + - name: "GroupID" + value: G1 + response: + values: + - name: "Status" + value: 0x00 + - name: "Capacity" + constraints: + anyOf: [fabricCapacity - 3, 0xfe, null] + - name: "GroupID" + value: G1 + - name: "SceneList" + value: [] + + - label: + "Step 10a: TH sends a RemoveAllScenes command to group G2 with the + GroupID field set to G2." + PICS: S.S.C03.Rsp + command: "RemoveAllScenes" + groupId: G2 + arguments: + values: + - name: "GroupID" + value: G2 + + - label: "Wait 1+ s to give CI time to process the RemoveScene command." + PICS: PICS_SDK_CI_ONLY + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 1250 + + - label: + "Step 10b: TH sends a GetSceneMembership command to DUT with the + GroupID field set to G1." + PICS: S.S.C06.Rsp + command: "GetSceneMembership" + arguments: + values: + - name: "GroupID" + value: G2 + response: + values: + - name: "Status" + value: 0x00 + - name: "Capacity" + constraints: + anyOf: [fabricCapacity, 0xfe, null] + - name: "GroupID" + value: G2 + - name: "SceneList" + value: [] + + - label: + "Step 11: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1" cluster: "Group Key Management" @@ -517,3 +1016,15 @@ tests: values: - name: GroupKeySetID value: 0x01a1 + + - label: + "Step 12: TH removes the Group key set that was added by sending a + KeySetRemove command to the GroupKeyManagement cluster with the + GroupKeySetID field set to 0x01a2" + cluster: "Group Key Management" + endpoint: 0 + command: "KeySetRemove" + arguments: + values: + - name: GroupKeySetID + value: 0x01a2 diff --git a/src/app/tests/suites/certification/Test_TC_S_2_4.yaml b/src/app/tests/suites/certification/Test_TC_S_2_4.yaml index 878637d8c2dc62..eac34fdea1fee6 100644 --- a/src/app/tests/suites/certification/Test_TC_S_2_4.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_2_4.yaml @@ -42,10 +42,10 @@ tests: cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a1 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: - d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 - 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: - 2220001 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf - 8)EpochStartTime2: 2220002" + a0a1a2a3a4a5a6a7a8a9aaabacadaeaf 4)EpochStartTime0: 1110000 + 5)EpochKey1: b0b1b2b3b4b5b6b7b8b9babbbcbdbebf 6)EpochStartTime1: + 1110001 7)EpochKey2: c0c1c2c3c4c5c6c7c8c9cacbcccdcecf + 8)EpochStartTime2: 1110002" cluster: "Group Key Management" endpoint: 0 command: "KeySetWrite" @@ -76,7 +76,7 @@ tests: arguments: value: [{ FabricIndex: 1, GroupId: G1, GroupKeySetID: 0x01a1 }] - - label: "Step 0c: TH sends a RemoveAllGroups command to DUT." + - label: "Step 1: TH sends a RemoveAllGroups command to DUT." PICS: G.S.C04.Rsp cluster: "Groups" command: "RemoveAllGroups" @@ -119,7 +119,7 @@ tests: - label: "Step 3: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to - 0x4E20 (20s) and no extension fields set." + 20000 (20s) and no extension fields set." PICS: S.S.C00.Rsp command: "AddScene" arguments: @@ -129,7 +129,7 @@ tests: - name: "SceneID" value: 0x01 - name: "TransitionTime" - value: 0x4E20 + value: 20000 - name: "SceneName" value: "Scene1" - name: "ExtensionFieldSets" @@ -317,7 +317,7 @@ tests: Is DUT configured with AC2? cluster: "LogCommands" command: "UserPrompt" - PICS: PICS_SKIP_SAMPLE_APP && PICS_SC_RECALL_SCENE_TRANSITION_TIME_MS + PICS: PICS_SKIP_SAMPLE_APP arguments: values: - name: "message" @@ -330,8 +330,8 @@ tests: - label: "Step 6b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field - set to 5000 (5s)." - PICS: S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME_MS + set to 5000 5s." + PICS: S.S.C05.Rsp command: "RecallScene" arguments: values: @@ -343,7 +343,7 @@ tests: value: 5000 - label: "Wait 5s" - PICS: S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME_MS + PICS: S.S.C05.Rsp cluster: "DelayCommands" command: "WaitForMs" arguments: @@ -352,10 +352,8 @@ tests: value: 5500 - label: - "TH confirm the DUT reached AC2 (on level control cluster) after 5s" - PICS: - S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME_MS && - PICS_SDK_CI_ONLY + "TH confirm the DUT reached AC1 (on level control cluster) after 5s" + PICS: S.S.C05.Rsp && PICS_SDK_CI_ONLY cluster: "Level Control" command: "readAttribute" attribute: "CurrentLevel" @@ -424,6 +422,37 @@ tests: - name: "TransitionTime" value: null + - label: "Wait 20s" + PICS: S.S.C05.Rsp + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 20500 + + - label: + "TH confirm the DUT reached AC1 (on level control cluster) after 20s" + PICS: S.S.C05.Rsp && PICS_SDK_CI_ONLY + cluster: "Level Control" + command: "readAttribute" + attribute: "CurrentLevel" + response: + value: 100 + + - label: "DUT transitions to AC2 over 20." + verification: | + Is the transition done over 20s? + cluster: "LogCommands" + command: "UserPrompt" + PICS: PICS_SKIP_SAMPLE_APP + arguments: + values: + - name: "message" + value: "Please confirm that transition to AC2 was made over 5s" + - name: "expectedValue" + value: "y" + - label: "Step 8: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the diff --git a/src/app/tests/suites/certification/Test_TC_S_2_5.yaml b/src/app/tests/suites/certification/Test_TC_S_2_5.yaml index 633e362149c9d1..31ed8b17a2bcdb 100644 --- a/src/app/tests/suites/certification/Test_TC_S_2_5.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_2_5.yaml @@ -37,15 +37,15 @@ tests: cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: GroupKeySetID: 0x01a1 GroupKeySecurityPolicy: TrustFirst (0) EpochKey0: - d0d1d2d3d4d5d6d7d8d9dadbdcdddedf EpochStartTime0: 2220000 EpochKey1: - d1d1d2d3d4d5d6d7d8d9dadbdcdddedf EpochStartTime1: 2220001 EpochKey2: - d2d1d2d3d4d5d6d7d8d9dadbdcdddedf EpochStartTime2: 2220002" + a0a1a2a3a4a5a6a7a8a9aaabacadaeaf EpochStartTime0: 1110000 EpochKey1: + b0b1b2b3b4b5b6b7b8b9babbbcbdbebf EpochStartTime1: 1110001 EpochKey2: + c0c1c2c3c4c5c6c7c8c9cacbcccdcecf EpochStartTime2: 1110002" verification: | ./chip-tool groupkeymanagement key-set-write '{"groupKeySetID": 1, "groupKeySecurityPolicy": 0, "epochKey0": - "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf", "epochStartTime0": 2220000,"epochKey1": - "d1d1d2d3d4d5d6d7d8d9dadbdcdddedf", "epochStartTime1": 2220001,"epochKey2": - "d2d1d2d3d4d5d6d7d8d9dadbdcdddedf", "epochStartTime2": 2220002 }' 1 0 + "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf", "epochStartTime0": 1110000,"epochKey1": + "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf", "epochStartTime1": 1110001,"epochKey2": + "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf", "epochStartTime2": 1110002 }' 1 0 Verify the "status is success" on the TH(Chip-tool) Log and below is the sample log provided for the raspi platform: @@ -104,7 +104,7 @@ tests: field set to G1." PICS: S.S.C03.Rsp verification: | - ./chip-tool scenes remove-all-scenes 0x0001 1 1 + ./chip-tool scenesmanagement remove-all-scenes 0x0001 1 1 CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0003 CHIP:TOO: RemoveAllScenesResponse: { @@ -114,20 +114,79 @@ tests: disabled: true - label: "Step 4a: TH reads from the DUT the SceneTableSize attribute" - PICS: S.S.A0006 verification: | - ./chip-tool scenes read scene-table-size 1 1 + ./chip-tool scenesmanagement read scene-table-size 1 1 [1688019474.695136][1726:1728] CHIP:DMG: } [1688019474.695335][1726:1728] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Attribute 0x0000_0006 DataVersion: 1550229741 - [1688019474.695397][1726:1728] CHIP:TOO: SceneTableSize: 0 + [1688019474.695397][1726:1728] CHIP:TOO: SceneTableSize: (Default table size: 16) disabled: true - label: "Step 4b: TH sends a subscription request action for FabricSceneInfo to the DUT." - PICS: S.S.A0007 verification: | + ./chip-tool interactive start + >>> any subscribe-by-id 0x0062 0x0002 min-interval max-interval node-id endpoint + + [1706764465.493922][4438:4440] CHIP:DMG: ReportDataMessage = + [1706764465.493926][4438:4440] CHIP:DMG: { + [1706764465.493928][4438:4440] CHIP:DMG: SubscriptionId = 0x8537dfcd, + [1706764465.493931][4438:4440] CHIP:DMG: AttributeReportIBs = + [1706764465.493937][4438:4440] CHIP:DMG: [ + [1706764465.493939][4438:4440] CHIP:DMG: AttributeReportIB = + [1706764465.493944][4438:4440] CHIP:DMG: { + [1706764465.493947][4438:4440] CHIP:DMG: AttributeDataIB = + [1706764465.493949][4438:4440] CHIP:DMG: { + [1706764465.493952][4438:4440] CHIP:DMG: DataVersion = 0xec4c4ec0, + [1706764465.493955][4438:4440] CHIP:DMG: AttributePathIB = + [1706764465.493958][4438:4440] CHIP:DMG: { + [1706764465.493961][4438:4440] CHIP:DMG: Endpoint = 0x1, + [1706764465.493963][4438:4440] CHIP:DMG: Cluster = 0x62, + [1706764465.493966][4438:4440] CHIP:DMG: Attribute = 0x0000_0002, + [1706764465.493969][4438:4440] CHIP:DMG: } + [1706764465.493974][4438:4440] CHIP:DMG: + [1706764465.493979][4438:4440] CHIP:DMG: Data = [ + [1706764465.493985][4438:4440] CHIP:DMG: + [1706764465.493990][4438:4440] CHIP:DMG: { + [1706764465.493997][4438:4440] CHIP:DMG: 0x0 = 1, + [1706764465.494002][4438:4440] CHIP:DMG: 0x1 = 1, + [1706764465.494007][4438:4440] CHIP:DMG: 0x2 = 1, + [1706764465.494013][4438:4440] CHIP:DMG: 0x3 = false, + [1706764465.494018][4438:4440] CHIP:DMG: 0x4 = 6, + [1706764465.494023][4438:4440] CHIP:DMG: 0xfe = 1, + [1706764465.494029][4438:4440] CHIP:DMG: }, + [1706764465.494034][4438:4440] CHIP:DMG: ], + [1706764465.494038][4438:4440] CHIP:DMG: }, + [1706764465.494047][4438:4440] CHIP:DMG: + [1706764465.494050][4438:4440] CHIP:DMG: }, + [1706764465.494059][4438:4440] CHIP:DMG: + [1706764465.494062][4438:4440] CHIP:DMG: ], + [1706764465.494070][4438:4440] CHIP:DMG: + [1706764465.494073][4438:4440] CHIP:DMG: InteractionModelRevision = 11 + [1706764465.494077][4438:4440] CHIP:DMG: } + [1706764465.494130][4438:4440] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Attribute 0x0000_0002 DataVersion: 3964423872 + [1706764465.494142][4438:4440] CHIP:TOO: FabricSceneInfo: 1 entries + [1706764465.494152][4438:4440] CHIP:TOO: [1]: { + [1706764465.494155][4438:4440] CHIP:TOO: SceneCount: 1 + [1706764465.494158][4438:4440] CHIP:TOO: CurrentScene: 1 + [1706764465.494161][4438:4440] CHIP:TOO: CurrentGroup: 1 + [1706764465.494164][4438:4440] CHIP:TOO: SceneValid: FALSE + [1706764465.494167][4438:4440] CHIP:TOO: RemainingCapacity: 6 + [1706764465.494170][4438:4440] CHIP:TOO: FabricIndex: 1 + [1706764465.494174][4438:4440] CHIP:TOO: } + ... + [1706797894.367789][5179:5181] CHIP:DMG: Subscription established with SubscriptionID = 0x8537dfcd MinInterval = 0s MaxInterval = 60s Peer = 01:0000000000000001 + ... + [1706798074.365189][5179:5181] CHIP:EM: >>> [E:29283r S:30665 M:266174816] (S) Msg RX from 1:0000000000000001 [0714] --- Type 0001:05 (IM:ReportData) + [1706798074.365317][5179:5181] CHIP:EM: Handling via exchange: 29283r, Delegate: 0xaaaacccf2a88 + [1706798074.365449][5179:5181] CHIP:DMG: ReportDataMessage = + [1706798074.365517][5179:5181] CHIP:DMG: { + [1706798074.365576][5179:5181] CHIP:DMG: SubscriptionId = 0x8537dfcd, + [1706798074.365638][5179:5181] CHIP:DMG: InteractionModelRevision = 11 + [1706798074.365696][5179:5181] CHIP:DMG: } + [1706798074.365883][5179:5181] CHIP:DMG: Refresh LivenessCheckTime for 64224 milliseconds with SubscriptionId = 0x85 + 37dfcd Peer = 01:0000000000000001 disabled: true @@ -135,16 +194,19 @@ tests: "Step 4c: Keep subscription session active for the remainder of the test" verification: | + Confirm that the subscription session is active for the remainder of the test by the reception of Liveness checks: + + [1706798074.365883][5179:5181] CHIP:DMG: Refresh LivenessCheckTime for 64224 milliseconds with SubscriptionId = 0x8537dfcd Peer = 01:0000000000000001 disabled: true - label: "Step 5a: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set - to 0x0014 (20s) and no extension field sets." + to 20000 (20s) and no extension field sets." PICS: S.S.C00.Rsp verification: | - ./chip-tool scenes add-scene 0x0001 0x1 0x0014 scene1 [] 1 1 + ./chip-tool scenesmanagement add-scene 0x0001 0x1 20000 scene1 [] 1 1 CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0000 CHIP:TOO: AddSceneResponse: { @@ -155,12 +217,59 @@ tests: disabled: true - label: - "Step 5b: Verify that the DUT sends a report data for - RemainingCapacity after the MinIntervalFloor time; store this value - into RemainingCapacity; verify RemainingCapacity equals + "Step 5b: Verify that the DUT sends a report data for FabricSceneInfo + after the MinIntervalFloor time; store the RemainingCapacity field + from this fabric’s entry reported in FabricSceneInfo into + RemainingCapacity; verify RemainingCapacity equals (MaxRemainingCapacity-1)." - PICS: S.S.A0007 verification: | + CHIP:DMG: ReportDataMessage = + CHIP:DMG: { + CHIP:DMG: SubscriptionId = 0x8537dfcd, + CHIP:DMG: AttributeReportIBs = + CHIP:DMG: [ + CHIP:DMG: AttributeReportIB = + CHIP:DMG: { + CHIP:DMG: AttributeDataIB = + CHIP:DMG: { + CHIP:DMG: DataVersion = 0x92ecb45d, + CHIP:DMG: AttributePathIB = + CHIP:DMG: { + CHIP:DMG: Endpoint = 0x1, + CHIP:DMG: Cluster = 0x62, + CHIP:DMG: Attribute = 0x0000_0002, + CHIP:DMG: } + CHIP:DMG: + CHIP:DMG: Data = [ + CHIP:DMG: + CHIP:DMG: { + CHIP:DMG: 0x0 = 1, + CHIP:DMG: 0x1 = 0, + CHIP:DMG: 0x2 = 0, + CHIP:DMG: 0x3 = false, + CHIP:DMG: 0x4 = 6, + CHIP:DMG: 0xfe = 1, + CHIP:DMG: }, + CHIP:DMG: ], + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: ], + CHIP:DMG: + CHIP:DMG: InteractionModelRevision = 11 + CHIP:DMG: } + CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Attribute 0x0000_0002 DataVersion: + CHIP:TOO: FabricSceneInfo: 1 entries + CHIP:TOO: [1]: { + CHIP:TOO: SceneCount: 1 + CHIP:TOO: CurrentScene: 0 + CHIP:TOO: CurrentGroup: 0 + CHIP:TOO: SceneValid: FALSE + CHIP:TOO: RemainingCapacity: 6 + CHIP:TOO: FabricIndex: 1 + CHIP:TOO: } + CHIP:DMG: Refresh LivenessCheckTime for 9224 milliseconds with SubscriptionId = 0x8537dfcd Peer = 01:0000000000000001 disabled: true @@ -171,7 +280,7 @@ tests: 8a." PICS: S.S.C04.Rsp verification: | - ./chip-tool scenes add-scene 0x0001 0x2 0x0014 scene2 [] 1 1 + ./chip-tool scenesmanagement store-scene 0x0001 0x2 20000 scene2 [] 1 1 CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0000 CHIP:TOO: AddSceneResponse: { @@ -182,33 +291,125 @@ tests: disabled: true - label: - "Step 6b: Verify that the DUT sends a report data for - RemainingCapacity after the MinIntervalFloor time; store this value - into RemainingCapacity; verify RemainingCapacity equals + "Step 6b: Verify that the DUT sends a report data for FabricSceneInfo + after the MinIntervalFloor time; store the RemainingCapacity field + from this fabric’s entry reported in FabricSceneInfo into + RemainingCapacity; verify RemainingCapacity equals (MaxRemainingCapacity-2)." - PICS: S.S.A0007 verification: | - + CHIP:DMG: ReportDataMessage = + CHIP:DMG: { + CHIP:DMG: SubscriptionId = 0x8537dfcd, + CHIP:DMG: AttributeReportIBs = + CHIP:DMG: [ + CHIP:DMG: AttributeReportIB = + CHIP:DMG: { + CHIP:DMG: AttributeDataIB = + CHIP:DMG: { + CHIP:DMG: DataVersion = 0x92ecb45d, + CHIP:DMG: AttributePathIB = + CHIP:DMG: { + CHIP:DMG: Endpoint = 0x1, + CHIP:DMG: Cluster = 0x62, + CHIP:DMG: Attribute = 0x0000_0002, + CHIP:DMG: } + CHIP:DMG: + CHIP:DMG: Data = [ + CHIP:DMG: + CHIP:DMG: { + CHIP:DMG: 0x0 = 2, + CHIP:DMG: 0x1 = 2, + CHIP:DMG: 0x2 = 1, + CHIP:DMG: 0x3 = true, + CHIP:DMG: 0x4 = 5, + CHIP:DMG: 0xfe = 1, + CHIP:DMG: }, + CHIP:DMG: ], + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: ], + CHIP:DMG: + CHIP:DMG: InteractionModelRevision = 11 + CHIP:DMG: } + CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Attribute 0x0000_0002 DataVersion: + CHIP:TOO: FabricSceneInfo: 1 entries + CHIP:TOO: [1]: { + CHIP:TOO: SceneCount: 2 + CHIP:TOO: CurrentScene: 2 + CHIP:TOO: CurrentGroup: 1 + CHIP:TOO: SceneValid: TRUE + CHIP:TOO: RemainingCapacity: 5 + CHIP:TOO: FabricIndex: 1 + CHIP:TOO: } + CHIP:DMG: Refresh LivenessCheckTime for 9224 milliseconds with SubscriptionId = 0x8537dfcd Peer = 01:0000000000000001 disabled: true - label: "Step 7a: If RemainingCapacity is greater than 0, TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set - to 0x03, the TransitionTime field set to 0x0014 (20s) and no extension + to 0x03, the TransitionTime field set to 20000 (20s) and no extension field sets. If RemainingCapacity is 0, continue to Step 8a." PICS: S.S.C00.Rsp verification: | - ./chip-tool scenes add-scene 0x0001 0x3 0x0014 scene3 [] 1 1 + ./chip-tool scenesmanagement add-scene 0x0001 0x3 20000 scene3 [] 1 1 disabled: true - label: - "Step 7b: Verify that the DUT sends a report data for - RemainingCapacity after the MinIntervalFloor time; store this value - into RemainingCapacity; verify RemainingCapacity equals + "Step 7b: Verify that the DUT sends a report data for FabricSceneInfo + after the MinIntervalFloor time; store the RemainingCapacity field + from this fabric’s entry reported in FabricSceneInfo into + RemainingCapacity; verify RemainingCapacity equals (MaxRemainingCapacity-3)." - PICS: S.S.A0007 verification: | - + CHIP:DMG: ReportDataMessage = + CHIP:DMG: { + CHIP:DMG: SubscriptionId = 0x8537dfcd, + CHIP:DMG: AttributeReportIBs = + CHIP:DMG: [ + CHIP:DMG: AttributeReportIB = + CHIP:DMG: { + CHIP:DMG: AttributeDataIB = + CHIP:DMG: { + CHIP:DMG: DataVersion = 0x92ecb45d, + CHIP:DMG: AttributePathIB = + CHIP:DMG: { + CHIP:DMG: Endpoint = 0x1, + CHIP:DMG: Cluster = 0x62, + CHIP:DMG: Attribute = 0x0000_0002, + CHIP:DMG: } + CHIP:DMG: + CHIP:DMG: Data = [ + CHIP:DMG: + CHIP:DMG: { + CHIP:DMG: 0x0 = 3, + CHIP:DMG: 0x1 = 2, + CHIP:DMG: 0x2 = 1, + CHIP:DMG: 0x3 = true, + CHIP:DMG: 0x4 = 4, + CHIP:DMG: 0xfe = 1, + CHIP:DMG: }, + CHIP:DMG: ], + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: ], + CHIP:DMG: + CHIP:DMG: InteractionModelRevision = 11 + CHIP:DMG: } + CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Attribute 0x0000_0002 DataVersion: + CHIP:TOO: FabricSceneInfo: 1 entries + CHIP:TOO: [1]: { + CHIP:TOO: SceneCount: 3 + CHIP:TOO: CurrentScene: 2 + CHIP:TOO: CurrentGroup: 1 + CHIP:TOO: SceneValid: TRUE + CHIP:TOO: RemainingCapacity: 4 + CHIP:TOO: FabricIndex: 1 + CHIP:TOO: } + CHIP:DMG: Refresh LivenessCheckTime for 9224 milliseconds with SubscriptionId = 0x8537dfcd Peer = 01:0000000000000001 disabled: true - label: @@ -216,7 +417,7 @@ tests: set to G1 and the SceneID field set to 0x01." PICS: S.S.C02.Rsp verification: | - ./chip-tool scenes remove-scene 0x0001 0x1 1 1 + ./chip-tool scenesmanagement remove-scene 0x0001 0x1 1 1 CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0002 CHIP:TOO: RemoveSceneResponse: { @@ -227,13 +428,59 @@ tests: disabled: true - label: - "Step 8b: Verify that the DUT sends a report data for - RemainingCapacity after the MinIntervalFloor time; store this value - into RemainingCapacity; verify RemainingCapacity equals + "Step 8b: Verify that the DUT sends a report data for FabricSceneInfo + after the MinIntervalFloor time; store the RemainingCapacity field + from this fabric’s entry reported in FabricSceneInfo into + RemainingCapacity; verify RemainingCapacity equals (MaxRemainingCapacity-2)." - PICS: S.S.A0007 verification: | - + CHIP:DMG: ReportDataMessage = + CHIP:DMG: { + CHIP:DMG: SubscriptionId = 0x8537dfcd, + CHIP:DMG: AttributeReportIBs = + CHIP:DMG: [ + CHIP:DMG: AttributeReportIB = + CHIP:DMG: { + CHIP:DMG: AttributeDataIB = + CHIP:DMG: { + CHIP:DMG: DataVersion = 0x92ecb45d, + CHIP:DMG: AttributePathIB = + CHIP:DMG: { + CHIP:DMG: Endpoint = 0x1, + CHIP:DMG: Cluster = 0x62, + CHIP:DMG: Attribute = 0x0000_0002, + CHIP:DMG: } + CHIP:DMG: + CHIP:DMG: Data = [ + CHIP:DMG: + CHIP:DMG: { + CHIP:DMG: 0x0 = 2, + CHIP:DMG: 0x1 = 2, + CHIP:DMG: 0x2 = 1, + CHIP:DMG: 0x3 = true, + CHIP:DMG: 0x4 = 5, + CHIP:DMG: 0xfe = 1, + CHIP:DMG: }, + CHIP:DMG: ], + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: ], + CHIP:DMG: + CHIP:DMG: InteractionModelRevision = 11 + CHIP:DMG: } + CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Attribute 0x0000_0002 DataVersion: + CHIP:TOO: FabricSceneInfo: 1 entries + CHIP:TOO: [1]: { + CHIP:TOO: SceneCount: 2 + CHIP:TOO: CurrentScene: 2 + CHIP:TOO: CurrentGroup: 1 + CHIP:TOO: SceneValid: TRUE + CHIP:TOO: RemainingCapacity: 5 + CHIP:TOO: FabricIndex: 1 + CHIP:TOO: } + CHIP:DMG: Refresh LivenessCheckTime for 9224 milliseconds with SubscriptionId = 0x8537dfcd Peer = 01:0000000000000001 disabled: true - label: @@ -241,7 +488,7 @@ tests: field set to G1." PICS: S.S.C03.Rsp verification: | - ./chip-tool scenes remove-all-scenes 0x0001 1 1 + ./chip-tool scenesmanagement remove-all-scenes 0x0001 1 1 CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0003 CHIP:TOO: RemoveAllScenesResponse: { @@ -251,13 +498,59 @@ tests: disabled: true - label: - "Step 9b: Verify that the DUT sends a report data for - RemainingCapacity after the MinIntervalFloor time; store this value - into RemainingCapacity; verify RemainingCapacity equals + "Step 9b: Verify that the DUT sends a report data for FabricSceneInfo + after the MinIntervalFloor time; store the RemainingCapacity field + from this fabric’s entry reported in FabricSceneInfo into + RemainingCapacity; verify RemainingCapacity equals (MaxRemainingCapacity)." - PICS: S.S.A0007 verification: | - + CHIP:DMG: ReportDataMessage = + CHIP:DMG: { + CHIP:DMG: SubscriptionId = 0x8537dfcd, + CHIP:DMG: AttributeReportIBs = + CHIP:DMG: [ + CHIP:DMG: AttributeReportIB = + CHIP:DMG: { + CHIP:DMG: AttributeDataIB = + CHIP:DMG: { + CHIP:DMG: DataVersion = 0x92ecb45d, + CHIP:DMG: AttributePathIB = + CHIP:DMG: { + CHIP:DMG: Endpoint = 0x1, + CHIP:DMG: Cluster = 0x62, + CHIP:DMG: Attribute = 0x0000_0002, + CHIP:DMG: } + CHIP:DMG: + CHIP:DMG: Data = [ + CHIP:DMG: + CHIP:DMG: { + CHIP:DMG: 0x0 = 0, + CHIP:DMG: 0x1 = 2, + CHIP:DMG: 0x2 = 1, + CHIP:DMG: 0x3 = false, + CHIP:DMG: 0x4 = 7, + CHIP:DMG: 0xfe = 1, + CHIP:DMG: }, + CHIP:DMG: ], + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: ], + CHIP:DMG: + CHIP:DMG: InteractionModelRevision = 11 + CHIP:DMG: } + CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Attribute 0x0000_0002 DataVersion: + CHIP:TOO: FabricSceneInfo: 1 entries + CHIP:TOO: [1]: { + CHIP:TOO: SceneCount: 0 + CHIP:TOO: CurrentScene: 2 + CHIP:TOO: CurrentGroup: 1 + CHIP:TOO: SceneValid: FALSE + CHIP:TOO: RemainingCapacity: 7 + CHIP:TOO: FabricIndex: 1 + CHIP:TOO: } + CHIP:DMG: Refresh LivenessCheckTime for 9224 milliseconds with SubscriptionId = 0x8537dfcd Peer = 01:0000000000000001 disabled: true - label: diff --git a/src/app/tests/suites/certification/Test_TC_S_2_6.yaml b/src/app/tests/suites/certification/Test_TC_S_2_6.yaml index 14731c4692a6cf..2d5e5cf0df2b99 100644 --- a/src/app/tests/suites/certification/Test_TC_S_2_6.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_2_6.yaml @@ -39,7 +39,7 @@ tests: field set to 0x0000." PICS: S.S.C03.Rsp verification: | - ./chip-tool scenes remove-all-scenes 0x0000 1 1 + ./chip-tool scenesmanagement remove-all-scenes 0x0000 1 1 CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0003 CHIP:TOO: RemoveAllScenesResponse: { @@ -51,14 +51,13 @@ tests: - label: "Step 1b: Repeat Step 1a with TH2 and TH3." PICS: S.S.C03.Rsp verification: | - ./chip-tool scenes remove-all-scenes 0x0000 2 1 --commissioner-name beta - ./chip-tool scenes remove-all-scenes 0x0000 3 1 --commissioner-name gamma + ./chip-tool scenesmanagement remove-all-scenes 0x0000 2 1 --commissioner-name beta + ./chip-tool scenesmanagement remove-all-scenes 0x0000 3 1 --commissioner-name gamma disabled: true - label: "Step 2a: TH1 reads from the DUT the SceneTableSize attribute" - PICS: S.S.A0006 verification: | - ./chip-tool scenes read scene-table-size 1 1 + ./chip-tool scenesmanagement read scene-table-size 1 1 CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Attribute 0x0000_0006 DataVersion: 2793536935 CHIP:TOO: SceneTableSize: 16 @@ -67,8 +66,56 @@ tests: - label: "Step 2b: TH1 sends a subscription request action for FabricSceneInfo to the DUT." - PICS: S.S.A0007 verification: | + ./chipt-tool interactive start + any subscribe-by-id 0x0062 0x0002 0 5 1 1 + + CHIP:DMG: ReportDataMessage = + CHIP:DMG: { + CHIP:DMG: SubscriptionId = 0xce6a96bc, + CHIP:DMG: AttributeReportIBs = + CHIP:DMG: [ + CHIP:DMG: AttributeReportIB = + CHIP:DMG: { + CHIP:DMG: AttributeDataIB = + CHIP:DMG: { + CHIP:DMG: DataVersion = 0x92ecb46c, + CHIP:DMG: AttributePathIB = + CHIP:DMG: { + CHIP:DMG: Endpoint = 0x1, + CHIP:DMG: Cluster = 0x62, + CHIP:DMG: Attribute = 0x0000_0002, + CHIP:DMG: } + CHIP:DMG: + CHIP:DMG: Data = [ + CHIP:DMG: + CHIP:DMG: { + CHIP:DMG: 0x0 = 0, + CHIP:DMG: 0x1 = 0, + CHIP:DMG: 0x2 = 0, + CHIP:DMG: 0x3 = false, + CHIP:DMG: 0x4 = 7, + CHIP:DMG: 0xfe = 1, + CHIP:DMG: }, + CHIP:DMG: ], + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: ], + CHIP:DMG: + CHIP:DMG: InteractionModelRevision = 11 + CHIP:DMG: } + CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Attribute 0x0000_0002 DataVersion: 2464986220 + CHIP:TOO: FabricSceneInfo: 1 entries + CHIP:TOO: [1]: { + CHIP:TOO: SceneCount: 0 + CHIP:TOO: CurrentScene: 0 + CHIP:TOO: CurrentGroup: 0 + CHIP:TOO: SceneValid: FALSE + CHIP:TOO: RemainingCapacity: 7 + CHIP:TOO: FabricIndex: 1 + CHIP:TOO: } disabled: true @@ -76,26 +123,52 @@ tests: "Step 2c: Keep subscription session active for the remaining of the test" verification: | + Confirm that the subscription session is active for the remainder of the test by the reception of Liveness checks: + CHIP:EM: >>> [E:44665r S:45698 M:201545516] (S) Msg RX from 1:0000000000000001 [1042] --- Type 0001:05 (IM:ReportData) + CHIP:EM: Handling via exchange: 44665r, Delegate: 0xaaaaea044808 + CHIP:DMG: ReportDataMessage = + CHIP:DMG: { + CHIP:DMG: SubscriptionId = 0xce6a96bc, + CHIP:DMG: InteractionModelRevision = 11 + CHIP:DMG: } + CHIP:DMG: Refresh LivenessCheckTime for 9224 milliseconds with SubscriptionId = 0xce6a96bc Peer = 01:0000000000000001 disabled: true - label: "Step 2d: Repeat Step 2b and 2c with TH2 and TH3" verification: | TH2: CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Attribute 0x0000_0007 DataVersion: 2793536968 - CHIP:TOO: RemainingCapacity: 8 + CHIP:TOO: FabricSceneInfo: 1 entries + CHIP:TOO: [1]: { + CHIP:TOO: SceneCount: 0 + CHIP:TOO: CurrentScene: 0 + CHIP:TOO: CurrentGroup: 0 + CHIP:TOO: SceneValid: FALSE + CHIP:TOO: RemainingCapacity: 7 + CHIP:TOO: FabricIndex: 2 + CHIP:TOO: } + TH3: CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Attribute 0x0000_0007 DataVersion: 2793536968 - CHIP:TOO: RemainingCapacity: 8 + CHIP:TOO: FabricSceneInfo: 1 entries + CHIP:TOO: [1]: { + CHIP:TOO: SceneCount: 0 + CHIP:TOO: CurrentScene: 0 + CHIP:TOO: CurrentGroup: 0 + CHIP:TOO: SceneValid: FALSE + CHIP:TOO: RemainingCapacity: 7 + CHIP:TOO: FabricIndex: 3 + CHIP:TOO: } disabled: true - label: "Step 3a: TH1 sends a AddScene command to DUT with the GroupID field set to 0x0000, the SceneID field set to 0x01, the TransitionTime field - set to 0x0014 (20s) and no extension field sets." + set to 20000 (20s) and no extension field sets." PICS: S.S.C00.Rsp verification: | - ./chip-tool scenes add-scene 0x0000 0x1 0x0014 scene1 [] 1 1 + ./chip-tool scenesmanagement add-scene 0x0000 0x1 20000 scene1 [] 1 1 CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0000 CHIP:TOO: AddSceneResponse: { @@ -111,9 +184,54 @@ tests: RemainingCapacity field from this fabric’s entry reported in FabricSceneInfo into Remaining1stCapacity; verify Remaining1stCapacity equals (MaxRemainingCapacity-1)." - PICS: S.S.A0007 verification: | - + Confirm that a report data message is received with the updated data: + CHIP:DMG: ReportDataMessage = + CHIP:DMG: { + CHIP:DMG: SubscriptionId = 0xce6a96bc, + CHIP:DMG: AttributeReportIBs = + CHIP:DMG: [ + CHIP:DMG: AttributeReportIB = + CHIP:DMG: { + CHIP:DMG: AttributeDataIB = + CHIP:DMG: { + CHIP:DMG: DataVersion = 0x92ecb46e, + CHIP:DMG: AttributePathIB = + CHIP:DMG: { + CHIP:DMG: Endpoint = 0x1, + CHIP:DMG: Cluster = 0x62, + CHIP:DMG: Attribute = 0x0000_0002, + CHIP:DMG: } + CHIP:DMG: + CHIP:DMG: Data = [ + CHIP:DMG: + CHIP:DMG: { + CHIP:DMG: 0x0 = 1, + CHIP:DMG: 0x1 = 0, + CHIP:DMG: 0x2 = 0, + CHIP:DMG: 0x3 = false, + CHIP:DMG: 0x4 = 6, + CHIP:DMG: 0xfe = 1, + CHIP:DMG: }, + CHIP:DMG: ], + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: ], + CHIP:DMG: + CHIP:DMG: InteractionModelRevision = 11 + CHIP:DMG: } + CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Attribute 0x0000_0002 DataVersion: 2464986222 + CHIP:TOO: FabricSceneInfo: 1 entries + CHIP:TOO: [1]: { + CHIP:TOO: SceneCount: 0 + CHIP:TOO: CurrentScene: 0 + CHIP:TOO: CurrentGroup: 0 + CHIP:TOO: SceneValid: FALSE + CHIP:TOO: RemainingCapacity: 6 + CHIP:TOO: FabricIndex: 1 + CHIP:TOO: } disabled: true - label: @@ -122,44 +240,73 @@ tests: Remaining1stCapacity more times until reported value to TH1 (after MinIntervalFloor) for RemainingCapacity field from FabricSceneInfo becomes 0." - PICS: S.S.C00.Rsp && S.S.A0007 + PICS: S.S.C00.Rsp verification: | + ./chip-tool scenesmanagement add-scene 0x0000 0x02 20000 scene2 [] 1 1 + + CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0000 + CHIP:TOO: AddSceneResponse: { + CHIP:TOO: status: 0 + CHIP:TOO: groupID: 0 + CHIP:TOO: sceneID: 2 + CHIP:TOO: } + . + . + . + ./chip-tool scenesmanagement add-scene 0x0000 0x07 20000 scene2 [] 1 1 + CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0000 + CHIP:TOO: AddSceneResponse: { + CHIP:TOO: status: 0 + CHIP:TOO: groupID: 0 + CHIP:TOO: sceneID: 7 + CHIP:TOO: } + + You should see the following data in the next report: + CHIP:TOO: FabricSceneInfo: 1 entries + CHIP:TOO: [1]: { + CHIP:TOO: SceneCount: 7 + CHIP:TOO: CurrentScene: 0 + CHIP:TOO: CurrentGroup: 0 + CHIP:TOO: SceneValid: FALSE + CHIP:TOO: RemainingCapacity: 0 + CHIP:TOO: FabricIndex: 1 + CHIP:TOO: } disabled: true - label: "Step 4b: TH1 sends a AddScene command to DUT with the GroupID field set to 0x0000, the SceneID field set to 1 more than last value used in - step 4a, the TransitionTime field set to 0x0014 (20s) and no extension + step 4a, the TransitionTime field set to 20000 (20s) and no extension field sets." PICS: S.S.C00.Rsp verification: | - ./chip-tool scenes add-scene 0x0000 0x10 0x0014 scene101 [] 1 1 + ./chip-tool scenesmanagement add-scene 0x0000 0x08 20000 scene101 [] 1 1 CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0000 CHIP:TOO: AddSceneResponse: { CHIP:TOO: status: 137 CHIP:TOO: groupID: 0 - CHIP:TOO: sceneID: 16 + CHIP:TOO: sceneID: 8 CHIP:TOO: } disabled: true - label: "Step 5a: Repeat Step 4a with TH2" - PICS: S.S.C00.Rsp && S.S.A0007 + PICS: S.S.C00.Rsp verification: | - ./chip-tool scenes add-scene 0x0000 0x1 0x0014 scene1 [] 2 1 --commissioner-name beta + ./chip-tool scenesmanagement add-scene 0x0000 0x2 20000 scene1 [] 2 1 --commissioner-name beta CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0000 CHIP:TOO: AddSceneResponse: { CHIP:TOO: status: 0 CHIP:TOO: groupID: 0 - CHIP:TOO: sceneID: 1 + CHIP:TOO: sceneID: 2 CHIP:TOO: } disabled: true - label: "Step 5b: Repeat Step 4b with TH2" PICS: S.S.C00.Rsp verification: | - ./chip-tool scenes add-scene 0x0000 0x11 0x0014 scene201 [] 2 1 --commissioner-name beta + ./chip-tool scenesmanagement add-scene 0x0000 0x11 20000 scene201 [] 2 1 --commissioner-name beta CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0000 CHIP:TOO: AddSceneResponse: { @@ -169,28 +316,72 @@ tests: CHIP:TOO: } disabled: true + - label: "Step 6a: Repeat Step 4a with TH3" + PICS: S.S.C00.Rsp + verification: | + ./chip-tool scenesmanagement add-scene 0x0000 0x3 20000 scene1 [] 2 1 --commissioner-name gamma + CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0000 + CHIP:TOO: AddSceneResponse: { + CHIP:TOO: status: 0 + CHIP:TOO: groupID: 0 + CHIP:TOO: sceneID: 3 + CHIP:TOO: } + disabled: true + - label: - "Step 6: TH3 sends a AddScene command to DUT with the GroupID field + "Step 6b: TH3 sends a AddScene command to DUT with the GroupID field set to 0x0000, the SceneID field set to 0x01, the TransitionTime field - set to 0x0014 (20s) and no extension field sets." + set to 20000 20s and no extension field sets." PICS: S.S.C00.Rsp verification: | - ./chip-tool scenes add-scene 0x0000 0x12 0x0014 scene301 [] 3 1 --commissioner-name gamma + ./chip-tool scenesmanagement add-scene 0x0000 0x01 20000 scene301 [] 3 1 --commissioner-name gamma CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0000 CHIP:TOO: AddSceneResponse: { CHIP:TOO: status: 137 CHIP:TOO: groupID: 0 - CHIP:TOO: sceneID: 18 + CHIP:TOO: sceneID: 1 + CHIP:TOO: } + disabled: true + + - label: + "Step 7: TH3 sends a StoreScene command to DUT with the GroupID field + set to 0x0000, the SceneID field set to 0x01." + PICS: S.S.C04.Rsp + verification: | + ./chip-tool scenesmanagement store-scene 0x0000 0xFE 20000 sceneFE [] 1 1 + + CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0004 + CHIP:TOO: StoreSceneResponse: { + CHIP:TOO: status: 137 + CHIP:TOO: groupID: 0 + CHIP:TOO: sceneID: 0xFE CHIP:TOO: } disabled: true - label: - "Step 7a: TH1 sends a RemoveAllScenes command to DUT with the GroupID + "TH sends a CopyScene command to DUT with the mode field set to 0x00, + the group identifier from field set to 0x0000, the scene identifier + from field set to 0x01, the group identifier to field set to 0x0000 + and the scene identifier to field set to 0xFE." + PICS: S.S.C40.Rsp + verification: | + ./chip-tool scenesmanagement copy-scene 0 0x0000 0x01 0x4E20 sceneFE [] 1 1 + + CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0040 + CHIP:TOO: CopySceneResponse: { + CHIP:TOO: status: 137 + CHIP:TOO: groupID: 0 + CHIP:TOO: sceneID: 0xFE + CHIP:TOO: } + disabled: true + + - label: + "Step 9a: TH1 sends a RemoveAllScenes command to DUT with the GroupID field set to 0x0000." PICS: S.S.C03.Rsp verification: | - ./chip-tool scenes remove-all-scenes 0x0000 1 1 + ./chip-tool scenesmanagement remove-all-scenes 0x0000 1 1 CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0003 CHIP:TOO: RemoveAllScenesResponse: { @@ -199,13 +390,16 @@ tests: CHIP:TOO: } disabled: true - - label: - "Step 7b: Verify that the DUT sends a report data to TH1 for + - label: "Step 9b: Verify that the DUT sends a report data to TH1 for FabricSceneInfo after the MinIntervalFloor time; store the - RemainingCapacity field from this fabrics entry the reported in + RemainingCapacity field from this fabric’s entry the reported in FabricSceneInfo into Remaining1stCapacity; verify Remaining1stCapacity - equals (MaxRemainingCapacity)." - PICS: S.S.A0007 + equals (MaxRemainingCapacity). + + Verify that the DUT does not send report data to TH2 for + FabricSceneInfo after the MinIntervalFloor time with updated value (it + should send 'empty' report data since there is no update for this + attribute for TH2)." verification: | CHIP:DMG: ReportDataMessage = CHIP:DMG: { @@ -215,11 +409,11 @@ tests: disabled: true - label: - "Step 8a: TH2 sends a RemoveAllScenes command to DUT with the GroupID + "Step 10a: TH2 sends a RemoveAllScenes command to DUT with the GroupID field set to 0x0000." PICS: S.S.C03.Rsp verification: | - ./chip-tool scenes remove-all-scenes 0x0000 2 1 --commissioner-name beta + ./chip-tool scenesmanagement remove-all-scenes 0x0000 2 1 --commissioner-name beta CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0005 Command 0x0000_0003 CHIP:TOO: RemoveAllScenesResponse: { @@ -229,11 +423,57 @@ tests: disabled: true - label: - "Step 8b: Verify that the DUT sends a report data to TH2 for - RemainingCapacity after the MinIntervalFloor time; store this value - into RemainingCapacity2; verify RemainingCapacity2 equals - (MaxRemainingCapacity)." - PICS: S.S.A0007 + Verify that the DUT sends a report data to TH2 for FabricSceneInfo + after the MinIntervalFloor time; store the RemainingCapacity field + from this fabric’s entry reported in FabricSceneInfo into + Remaining2ndCapacity; verify Remaining2ndCapacity equals + (MaxRemainingCapacity). verification: | - + CHIP:DMG: ReportDataMessage = + CHIP:DMG: { + CHIP:DMG: SubscriptionId = 0x7049d607, + CHIP:DMG: AttributeReportIBs = + CHIP:DMG: [ + CHIP:DMG: AttributeReportIB = + CHIP:DMG: { + CHIP:DMG: AttributeDataIB = + CHIP:DMG: { + CHIP:DMG: DataVersion = 0x92ecb45d, + CHIP:DMG: AttributePathIB = + CHIP:DMG: { + CHIP:DMG: Endpoint = 0x1, + CHIP:DMG: Cluster = 0x62, + CHIP:DMG: Attribute = 0x0000_0002, + CHIP:DMG: } + CHIP:DMG: + CHIP:DMG: Data = [ + CHIP:DMG: + CHIP:DMG: { + CHIP:DMG: 0x0 = 4, + CHIP:DMG: 0x1 = 4, + CHIP:DMG: 0x2 = 0, + CHIP:DMG: 0x3 = false, + CHIP:DMG: 0x4 = 3, + CHIP:DMG: 0xfe = 1, + CHIP:DMG: }, + CHIP:DMG: ], + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: }, + CHIP:DMG: + CHIP:DMG: ], + CHIP:DMG: + CHIP:DMG: InteractionModelRevision = 11 + CHIP:DMG: } + CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Attribute 0x0000_0002 DataVersion: 2464986205 + CHIP:TOO: FabricSceneInfo: 1 entries + CHIP:TOO: [1]: { + CHIP:TOO: SceneCount: 4 + CHIP:TOO: CurrentScene: 4 + CHIP:TOO: CurrentGroup: 0 + CHIP:TOO: SceneValid: FALSE + CHIP:TOO: RemainingCapacity: 7 + CHIP:TOO: FabricIndex: 1 + CHIP:TOO: } + CHIP:DMG: Refresh LivenessCheckTime for 9224 milliseconds with SubscriptionId = 0x7049d607 Peer = 01:0000000000000001 disabled: true diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index 907b0024709c4c..465041b9f9af73 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -679,7 +679,6 @@ S.S.C40.Rsp=1 S.S.AM=0 S.S.AO=0 S.S.F00=1 -PICS_SC_RECALL_SCENE_TRANSITION_TIME_MS=1 S.C=0 S.C.C00.Tx=0 diff --git a/src/app/tests/suites/commands/delay/BUILD.gn b/src/app/tests/suites/commands/delay/BUILD.gn index b744edcf7a8cbb..de0babc859026f 100644 --- a/src/app/tests/suites/commands/delay/BUILD.gn +++ b/src/app/tests/suites/commands/delay/BUILD.gn @@ -26,6 +26,7 @@ static_library("delay") { cflags = [ "-Wconversion" ] public_deps = [ + "${chip_root}/src/app/common:simulated", "${chip_root}/src/lib/support", "${chip_root}/src/platform", "${chip_root}/src/system", diff --git a/src/app/tests/suites/commands/discovery/BUILD.gn b/src/app/tests/suites/commands/discovery/BUILD.gn index da1196f9db395e..169e9a91609183 100644 --- a/src/app/tests/suites/commands/discovery/BUILD.gn +++ b/src/app/tests/suites/commands/discovery/BUILD.gn @@ -29,6 +29,7 @@ static_library("discovery") { public_deps = [ "${chip_root}/src/app", + "${chip_root}/src/app/common:simulated", "${chip_root}/src/lib/address_resolve", "${chip_root}/src/lib/support", ] diff --git a/src/app/tests/suites/commands/log/BUILD.gn b/src/app/tests/suites/commands/log/BUILD.gn index c0f2ffa3eb6b55..b873bf1c38d96d 100644 --- a/src/app/tests/suites/commands/log/BUILD.gn +++ b/src/app/tests/suites/commands/log/BUILD.gn @@ -25,5 +25,8 @@ static_library("log") { cflags = [ "-Wconversion" ] - public_deps = [ "${chip_root}/src/lib/support" ] + public_deps = [ + "${chip_root}/src/app/common:simulated", + "${chip_root}/src/lib/support", + ] } diff --git a/src/app/tests/suites/commands/system/BUILD.gn b/src/app/tests/suites/commands/system/BUILD.gn index 4843944f3a8b1e..df9972388b1f33 100644 --- a/src/app/tests/suites/commands/system/BUILD.gn +++ b/src/app/tests/suites/commands/system/BUILD.gn @@ -25,5 +25,8 @@ static_library("system") { cflags = [ "-Wconversion" ] - public_deps = [ "${chip_root}/src/lib/support" ] + public_deps = [ + "${chip_root}/src/app/common:simulated", + "${chip_root}/src/lib/support", + ] } diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index e66ce70d7cdf9b..fb166ff72453bd 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -163,6 +163,8 @@ void MatterDishwasherAlarmPluginServerInitCallback() {} void MatterMicrowaveOvenModePluginServerInitCallback() {} void MatterDeviceEnergyManagementModePluginServerInitCallback() {} void MatterEnergyEvseModePluginServerInitCallback() {} +void MatterElectricalEnergyMeasurementPluginServerInitCallback() {} +void MatterElectricalPowerMeasurementPluginServerInitCallback() {} // **************************************** // Print out information about each cluster // **************************************** diff --git a/src/app/zap-templates/partials/cluster-enums-enum.zapt b/src/app/zap-templates/partials/cluster-enums-enum.zapt new file mode 100644 index 00000000000000..43aac026a5b488 --- /dev/null +++ b/src/app/zap-templates/partials/cluster-enums-enum.zapt @@ -0,0 +1,19 @@ +// Enum for {{label}} +enum class {{asType label}} : {{asUnderlyingZclType name}} { +{{#zcl_enum_items}} +k{{asUpperCamelCase label}} = {{asHex value 2}}, +{{/zcl_enum_items}} +{{#unless (isInConfigList (concat ns "::" label) "EnumsNotUsedAsTypeInXML")}} +// All received enum values that are not listed above will be mapped +// to kUnknownEnumValue. This is a helper enum value that should only +// be used by code to process how it handles receiving and unknown +// enum value. This specific should never be transmitted. +kUnknownEnumValue = {{first_unused_enum_value mode="first_unused"}}, +{{else}} +// kUnknownEnumValue intentionally not defined. This enum never goes +// through DataModel::Decode, likely because it is a part of a derived +// cluster. As a result having kUnknownEnumValue in this enum is error +// prone, and was removed. See +// src/app/common/templates/config-data.yaml. +{{/unless}} +}; \ No newline at end of file diff --git a/src/app/zap-templates/templates/app/cluster-enums-check.zapt b/src/app/zap-templates/templates/app/cluster-enums-check.zapt index cb263c05153db1..c5acb97314f4ff 100644 --- a/src/app/zap-templates/templates/app/cluster-enums-check.zapt +++ b/src/app/zap-templates/templates/app/cluster-enums-check.zapt @@ -7,8 +7,28 @@ namespace chip { namespace app { namespace Clusters { +{{#zcl_enums}} +{{#if has_more_than_one_cluster}} +{{#unless (isInConfigList (concat "::" label) "EnumsNotUsedAsTypeInXML")}} +static auto __attribute__((unused)) EnsureKnownEnumValue(detail::{{asType label}} val) +{ + using EnumType = detail::{{asType label}}; + switch (val) { + {{#zcl_enum_items}} + case EnumType::k{{asUpperCamelCase label}}: + {{/zcl_enum_items}} + return val; + default: + return EnumType::kUnknownEnumValue; + } +} +{{/unless}} +{{/if}} +{{/zcl_enums}} + {{#zcl_clusters}} {{#zcl_enums}} +{{#unless has_more_than_one_cluster}} {{#unless (isInConfigList (concat (asUpperCamelCase ../name) "::" label) "EnumsNotUsedAsTypeInXML")}} static auto __attribute__((unused)) EnsureKnownEnumValue({{asUpperCamelCase ../name}}::{{asType label}} val) { @@ -19,10 +39,11 @@ static auto __attribute__((unused)) EnsureKnownEnumValue({{asUpperCamelCase ../n {{/zcl_enum_items}} return val; default: - return static_cast({{first_unused_enum_value mode="first_unused"}}); + return EnumType::kUnknownEnumValue; } } {{/unless}} +{{/unless}} {{/zcl_enums}} {{/zcl_clusters}} diff --git a/src/app/zap-templates/templates/app/cluster-enums.zapt b/src/app/zap-templates/templates/app/cluster-enums.zapt index 34092a124f519e..612b3dd6a29d4b 100644 --- a/src/app/zap-templates/templates/app/cluster-enums.zapt +++ b/src/app/zap-templates/templates/app/cluster-enums.zapt @@ -9,38 +9,58 @@ namespace chip { namespace app { namespace Clusters { +namespace detail { +// Enums shared across multiple clusters. +{{#zcl_enums}} + +{{#if has_more_than_one_cluster}} + +{{> cluster_enums_enum ns=""}} + +{{/if}} +{{/zcl_enums}} + +// Bitmaps shared across multiple clusters. +{{#zcl_bitmaps}} + +{{#if has_more_than_one_cluster}} + +// Bitmap for {{label}} +enum class {{asType label}} : {{asUnderlyingZclType name}} { +{{#zcl_bitmap_items}} +k{{asUpperCamelCase label}} = {{asHex mask}}, +{{/zcl_bitmap_items}} +}; + +{{/if}} +{{/zcl_bitmaps}} + +} // namespace detail + + {{#zcl_clusters}} namespace {{asUpperCamelCase name}} { {{#zcl_enums}} -// Enum for {{label}} -enum class {{asType label}} : {{asUnderlyingZclType name}} { -{{#zcl_enum_items}} -k{{asUpperCamelCase label}} = {{asHex value 2}}, -{{/zcl_enum_items}} -{{#unless (isInConfigList (concat (asUpperCamelCase ../name) "::" label) "EnumsNotUsedAsTypeInXML")}} -// All received enum values that are not listed above will be mapped -// to kUnknownEnumValue. This is a helper enum value that should only -// be used by code to process how it handles receiving and unknown -// enum value. This specific should never be transmitted. -kUnknownEnumValue = {{first_unused_enum_value mode="first_unused"}}, +{{#if has_more_than_one_cluster}} +using {{asUpperCamelCase name}} = Clusters::detail::{{asUpperCamelCase name}}; {{else}} -// kUnknownEnumValue intentionally not defined. This enum never goes -// through DataModel::Decode, likely because it is a part of a derived -// cluster. As a result having kUnknownEnumValue in this enum is error -// prone, and was removed. See -// src/app/common/templates/config-data.yaml. -{{/unless}} -}; +{{> cluster_enums_enum ns=(asUpperCamelCase ../name)}} + +{{/if}} {{/zcl_enums}} {{#zcl_bitmaps}} +{{#if has_more_than_one_cluster}} +using {{asUpperCamelCase name}} = Clusters::detail::{{asUpperCamelCase name}}; +{{else}} // Bitmap for {{label}} enum class {{asType label}} : {{asUnderlyingZclType name}} { {{#zcl_bitmap_items}} k{{asUpperCamelCase label}} = {{asHex mask}}, {{/zcl_bitmap_items}} }; +{{/if}} {{/zcl_bitmaps}} } // namespace {{asUpperCamelCase name}} diff --git a/src/app/zap-templates/templates/app/cluster-objects.zapt b/src/app/zap-templates/templates/app/cluster-objects.zapt index 4e17d227629f34..1453523b1b7986 100644 --- a/src/app/zap-templates/templates/app/cluster-objects.zapt +++ b/src/app/zap-templates/templates/app/cluster-objects.zapt @@ -25,6 +25,7 @@ namespace Clusters { namespace detail { // Structs shared across multiple clusters. namespace Structs { + {{#zcl_structs}} {{#if has_more_than_one_cluster}} {{> cluster_objects_struct header=true}} diff --git a/src/app/zap-templates/zcl/data-model/all.xml b/src/app/zap-templates/zcl/data-model/all.xml index ac22765069d4d6..255be8b0328e1b 100644 --- a/src/app/zap-templates/zcl/data-model/all.xml +++ b/src/app/zap-templates/zcl/data-model/all.xml @@ -27,6 +27,9 @@ + + + diff --git a/src/app/zap-templates/zcl/data-model/chip/drlc-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/drlc-cluster.xml index fdffc7d58d051c..dce7ff59f3fdac 100644 --- a/src/app/zap-templates/zcl/data-model/chip/drlc-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/drlc-cluster.xml @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - + @@ -177,7 +177,7 @@ limitations under the License. Demand Response Load Control - Energy + Energy Management This cluster provides an interface to the functionality of Smart Energy Demand Response and Load Control. 0x0096 DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER diff --git a/src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml index 6271b56d235a61..55a298ee596e53 100644 --- a/src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml @@ -15,93 +15,58 @@ See the License for the specific language governing permissions and limitations under the License. --> - - + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Electrical Energy Measurement Measurement & Sensing - This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. 0x0091 ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER - true - true - - - Accuracy - CumulativeEnergyImported - CumulativeEnergyExported - PeriodicEnergyImported - PeriodicEnergyExported - - - This event SHALL be generated when the server takes a snapshot of the cumulative energy imported by the server, exported from the server of both. + true + true + + This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. + + Accuracy + CumulativeEnergyImported + + CumulativeEnergyExported + + PeriodicEnergyImported + + PeriodicEnergyExported + CumulativeEnergyReset + + + CumulativeEnergyMeasured - - - This event SHALL be generated when the server reaches the end of a reporting period for imported energy, exported energy, or both. + + PeriodicEnergyMeasured - + + + + + + + + + + + + + + + diff --git a/src/app/zap-templates/zcl/data-model/chip/electrical-power-measurement-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/electrical-power-measurement-cluster.xml new file mode 100644 index 00000000000000..e723982ee0ffe8 --- /dev/null +++ b/src/app/zap-templates/zcl/data-model/chip/electrical-power-measurement-cluster.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + Electrical Power Measurement + Measurement & Sensing + 0x0090 + ELECTRICAL_POWER_MEASUREMENT_CLUSTER + true + true + + This cluster provides a mechanism for querying data about electrical power as measured by the server. + + PowerMode + NumberOfMeasurementTypes + Accuracy + Ranges + Voltage + + ActiveCurrent + + ReactiveCurrent + ApparentCurrent + + ActivePower + + ReactivePower + + ApparentPower + + RMSVoltage + + RMSCurrent + + RMSPower + + Frequency + + HarmonicCurrents + + HarmonicPhases + + PowerFactor + NeutralCurrent + + MeasurementPeriodRanges + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/app/zap-templates/zcl/data-model/chip/general-diagnostics-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/general-diagnostics-cluster.xml index 5e1ec18a71f345..26e14006a6cca8 100644 --- a/src/app/zap-templates/zcl/data-model/chip/general-diagnostics-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/general-diagnostics-cluster.xml @@ -16,6 +16,12 @@ limitations under the License. --> + + + + + + @@ -122,6 +128,18 @@ limitations under the License. + + Request a variable length payload response. + + + + + + + Response for the PayloadTestRequest command. + + + Indicate a change in the set of hardware faults currently detected by the Node. diff --git a/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml b/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml index 31ff5abbbc2460..66fcb0d9b48821 100644 --- a/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml +++ b/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml @@ -107,6 +107,20 @@ limitations under the License. + + MA-electricalsensor + CHIP + Matter Electrical Sensor + 0x0103 + 0x0510 + Utility + Node + + + + + + MA-otarequestor CHIP @@ -2379,4 +2393,22 @@ limitations under the License. + + Energy EVSE + CHIP + Matter EVSE + Simple + 0x0103 + 0x050C + + + + + + + + + + + diff --git a/src/app/zap-templates/zcl/data-model/chip/measurement-and-sensing.xml b/src/app/zap-templates/zcl/data-model/chip/measurement-and-sensing.xml new file mode 100644 index 00000000000000..bef6dd86091676 --- /dev/null +++ b/src/app/zap-templates/zcl/data-model/chip/measurement-and-sensing.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/app/zap-templates/zcl/data-model/chip/power-topology-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/power-topology-cluster.xml new file mode 100644 index 00000000000000..fb27062b26cfbe --- /dev/null +++ b/src/app/zap-templates/zcl/data-model/chip/power-topology-cluster.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + Measurement & Sensing + Power Topology + 0x009C + POWER_TOPOLOGY_CLUSTER + The Power Topology Cluster provides a mechanism for expressing how power is flowing between endpoints. + true + true + + AvailableEndpoints + ActiveEndpoints + + diff --git a/src/app/zap-templates/zcl/zcl-with-test-extensions.json b/src/app/zap-templates/zcl/zcl-with-test-extensions.json index 4512f11959822c..2800e14197008c 100644 --- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json +++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json @@ -49,6 +49,7 @@ "energy-preference-cluster.xml", "electrical-energy-measurement-cluster.xml", "electrical-measurement-cluster.xml", + "electrical-power-measurement-cluster.xml", "energy-evse-cluster.xml", "energy-evse-mode-cluster.xml", "ethernet-network-diagnostics-cluster.xml", @@ -71,6 +72,7 @@ "level-control-cluster.xml", "localization-configuration-cluster.xml", "low-power-cluster.xml", + "measurement-and-sensing.xml", "media-input-cluster.xml", "media-playback-cluster.xml", "messages-cluster.xml", @@ -86,6 +88,7 @@ "operational-state-oven-cluster.xml", "operational-state-rvc-cluster.xml", "oven-mode-cluster.xml", + "power-topology-cluster.xml", "pressure-measurement-cluster.xml", "power-source-cluster.xml", "power-source-configuration-cluster.xml", @@ -249,7 +252,9 @@ "RebootCount", "UpTime", "TotalOperationalHours", - "BootReason" + "BootReason", + "FeatureMap", + "ClusterRevision" ], "Group Key Management": [ "ClusterRevision", @@ -599,7 +604,31 @@ "CumulativeEnergyImported", "CumulativeEnergyExported", "PeriodicEnergyImported", - "PeriodicEnergyExported" + "PeriodicEnergyExported", + "CumulativeEnergyReset", + "FeatureMap" + ], + "Electrical Power Measurement": [ + "PowerMode", + "NumberOfMeasurementTypes", + "Accuracy", + "Ranges", + "Voltage", + "ActiveCurrent", + "ReactiveCurrent", + "ApparentCurrent", + "ActivePower", + "ReactivePower", + "ApparentPower", + "RMSVoltage", + "RMSCurrent", + "RMSPower", + "Frequency", + "HarmonicCurrents", + "HarmonicPhases", + "PowerFactor", + "NeutralCurrent", + "FeatureMap" ], "Valve Configuration and Control": ["RemainingDuration"], "Boolean State Configuration": ["CurrentSensitivityLevel"] diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index 12ed5d6cd2142d..b9e0142011022a 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -43,9 +43,10 @@ "dishwasher-mode-cluster.xml", "microwave-oven-mode-cluster.xml", "door-lock-cluster.xml", - "electrical-energy-measurement-cluster.xml", "drlc-cluster.xml", + "electrical-energy-measurement-cluster.xml", "electrical-measurement-cluster.xml", + "electrical-power-measurement-cluster.xml", "energy-evse-cluster.xml", "energy-evse-mode-cluster.xml", "energy-preference-cluster.xml", @@ -69,6 +70,7 @@ "level-control-cluster.xml", "localization-configuration-cluster.xml", "low-power-cluster.xml", + "measurement-and-sensing.xml", "media-input-cluster.xml", "media-playback-cluster.xml", "messages-cluster.xml", @@ -83,6 +85,7 @@ "operational-state-oven-cluster.xml", "operational-state-rvc-cluster.xml", "oven-mode-cluster.xml", + "power-topology-cluster.xml", "pressure-measurement-cluster.xml", "power-source-cluster.xml", "power-source-configuration-cluster.xml", @@ -247,7 +250,9 @@ "RebootCount", "UpTime", "TotalOperationalHours", - "BootReason" + "BootReason", + "FeatureMap", + "ClusterRevision" ], "Group Key Management": [ "ClusterRevision", @@ -597,7 +602,31 @@ "CumulativeEnergyImported", "CumulativeEnergyExported", "PeriodicEnergyImported", - "PeriodicEnergyExported" + "PeriodicEnergyExported", + "CumulativeEnergyReset", + "FeatureMap" + ], + "Electrical Power Measurement": [ + "PowerMode", + "NumberOfMeasurementTypes", + "Accuracy", + "Ranges", + "Voltage", + "ActiveCurrent", + "ReactiveCurrent", + "ApparentCurrent", + "ActivePower", + "ReactivePower", + "ApparentPower", + "RMSVoltage", + "RMSCurrent", + "RMSPower", + "Frequency", + "HarmonicCurrents", + "HarmonicPhases", + "PowerFactor", + "NeutralCurrent", + "FeatureMap" ], "Valve Configuration and Control": ["RemainingDuration"], "Boolean State Configuration": ["CurrentSensitivityLevel"] diff --git a/src/app/zap_cluster_list.json b/src/app/zap_cluster_list.json index 8c496c03782325..db22d6c2ab5e77 100644 --- a/src/app/zap_cluster_list.json +++ b/src/app/zap_cluster_list.json @@ -38,6 +38,7 @@ "DOOR_LOCK_CLUSTER": [], "ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER": [], "ELECTRICAL_MEASUREMENT_CLUSTER": [], + "ELECTRICAL_POWER_MEASUREMENT_CLUSTER": [], "ENERGY_EVSE_CLUSTER": [], "ENERGY_EVSE_MODE_CLUSTER": [], "ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER": [], @@ -67,6 +68,7 @@ "MESSAGES_CLUSTER": [], "MODE_SELECT_CLUSTER": [], "NETWORK_COMMISSIONING_CLUSTER": [], + "POWER_TOPOLOGY_CLUSTER": [], "SAMPLE_MEI_CLUSTER": [], "NITROGEN_DIOXIDE_CONCENTRATION_MEASUREMENT_CLUSTER": [], "OCCUPANCY_SENSING_CLUSTER": ["occupancy-sensor-server"], @@ -182,6 +184,9 @@ "electrical-energy-measurement-server" ], "ELECTRICAL_MEASUREMENT_CLUSTER": [], + "ELECTRICAL_POWER_MEASUREMENT_CLUSTER": [ + "electrical-power-measurement-server" + ], "ENERGY_EVSE_CLUSTER": ["energy-evse-server"], "ENERGY_EVSE_MODE_CLUSTER": ["mode-base-server"], "ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER": [ @@ -223,6 +228,7 @@ "SAMPLE_MEI_CLUSTER": ["sample-mei-server"], "OCCUPANCY_SENSING_CLUSTER": ["occupancy-sensor-server"], "ON_OFF_CLUSTER": ["on-off-server"], + "POWER_TOPOLOGY_CLUSTER": [], "ON_OFF_SWITCH_CONFIGURATION_CLUSTER": [], "OPERATIONAL_CREDENTIALS_CLUSTER": ["operational-credentials-server"], "OPERATIONAL_STATE_CLUSTER": ["operational-state-server"], diff --git a/src/app/zap_cluster_list.py b/src/app/zap_cluster_list.py index d27293f0c12b28..24c480ffebbf25 100755 --- a/src/app/zap_cluster_list.py +++ b/src/app/zap_cluster_list.py @@ -23,7 +23,7 @@ def get_cluster_sources(clusters: typing.Set[str], for cluster in clusters: if cluster not in source_map: raise ValueError("Unhandled %s cluster: %s" - " (hint: add to src/app/zap_cluster_list.py)" % (side, cluster)) + " (hint: add to src/app/zap_cluster_list.json)" % (side, cluster)) cluster_sources.update(source_map[cluster]) diff --git a/src/controller/BUILD.gn b/src/controller/BUILD.gn index 435e405c299c97..b06b2defecb8f2 100644 --- a/src/controller/BUILD.gn +++ b/src/controller/BUILD.gn @@ -24,40 +24,87 @@ source_set("nodatamodel") { public_deps = [ "${chip_root}/src/app" ] } +CHIP_CONTROLLER_HEADERS = [ "ExampleOperationalCredentialsIssuer.h" ] +CHIP_READ_CLIENT_HEADERS = [ + "CommissioningWindowOpener.h", + "CurrentFabricRemover.h", +] + +# This source set exists specifically to deny including them without dependencies +# if "controller" sources do not contain them +# +# They are NOT intended to be used directly. +# +# The intent for this is to force gn to be aware that these files are known and +# error out as `include not allowed due to missing dependency` even if +# controller is built without these sources +source_set("gen_check_chip_controller_headers") { + sources = CHIP_CONTROLLER_HEADERS +} + +source_set("gen_check_chip_read_client_headers") { + sources = CHIP_READ_CLIENT_HEADERS +} + +source_set("delegates") { + sources = [ "OperationalCredentialsDelegate.h" ] +} + static_library("controller") { output_name = "libChipController" - sources = [ "CHIPCluster.h" ] + sources = [ + # TODO: these dependencies are broken. Specifically: + # a) ChipDeviceControllerFactory.h includes CHIPDeviceController.h + # b) CHIPDeviceController.cpp is only compiled for read_client + # These conditionals are NOT ok and should have been solved with separate + # source sets - either include some functionality or do not + # + # Then CHIPDeviceController.h pulls in AbstractDnssdDiscoveryController and everything + # cascades. In the end it looks like basically every header file is pulled in. + # + # Unfortunately this is hard to fix in one go, hence these odd list of header-only + # dependencies + "AbstractDnssdDiscoveryController.h", + "AutoCommissioner.h", + "CHIPCluster.h", + "CHIPCommissionableNodeController.h", + "CHIPDeviceController.h", + "CHIPDeviceControllerSystemState.h", + "CommandSenderAllocator.h", + "CommissioneeDeviceProxy.h", + "CommissioningDelegate.h", + "DeviceDiscoveryDelegate.h", + "DevicePairingDelegate.h", + "InvokeInteraction.h", + "ReadInteraction.h", + "SetUpCodePairer.h", + "TypedCommandCallback.h", + "TypedReadCallback.h", + "WriteInteraction.h", + ] if (chip_controller && chip_build_controller) { + sources += CHIP_CONTROLLER_HEADERS sources += [ "AbstractDnssdDiscoveryController.cpp", "AutoCommissioner.cpp", - "AutoCommissioner.h", "CHIPCommissionableNodeController.cpp", - "CHIPCommissionableNodeController.h", "CHIPDeviceControllerFactory.cpp", "CHIPDeviceControllerFactory.h", "CommissioneeDeviceProxy.cpp", - "CommissioneeDeviceProxy.h", "CommissionerDiscoveryController.cpp", "CommissionerDiscoveryController.h", "CommissioningDelegate.cpp", - "DeviceDiscoveryDelegate.h", - "DevicePairingDelegate.h", "ExampleOperationalCredentialsIssuer.cpp", - "ExampleOperationalCredentialsIssuer.h", "SetUpCodePairer.cpp", - "SetUpCodePairer.h", ] if (chip_enable_read_client) { + sources += CHIP_READ_CLIENT_HEADERS sources += [ "CHIPDeviceController.cpp", - "CHIPDeviceController.h", "CommissioningWindowOpener.cpp", - "CommissioningWindowOpener.h", "CurrentFabricRemover.cpp", - "CurrentFabricRemover.h", ] } } @@ -81,5 +128,10 @@ static_library("controller") { deps = [ "${chip_root}/src/lib/address_resolve" ] - defines = [] + if (chip_controller && chip_build_controller) { + # ExampleOperationalCredentialsIssuer uses TestGroupData + deps += [ "${chip_root}/src/lib/support:testing" ] + } + + public_configs = [ "${chip_root}/src:includes" ] } diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index dbad9659e2f85f..0fa33ae945da3b 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -1637,6 +1637,10 @@ cluster GeneralDiagnostics = 51 { kEthernetFault = 6; } + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + struct NetworkInterface { char_string<32> name = 0; boolean isOperational = 1; @@ -1693,10 +1697,22 @@ cluster GeneralDiagnostics = 51 { nullable posix_ms posixTimeMs = 1; } + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + /** Provide a means for certification tests to trigger some test-plan-specific events */ command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; /** Take a snapshot of system time and epoch time. */ command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } /** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ @@ -4091,6 +4107,111 @@ provisional cluster ValveConfigurationAndControl = 129 { command Close(): DefaultSuccess = 1; } +/** This cluster provides a mechanism for querying data about electrical power as measured by the server. */ +provisional cluster ElectricalPowerMeasurement = 144 { + revision 1; + + enum MeasurementTypeEnum : enum16 { + kUnspecified = 0; + kVoltage = 1; + kActiveCurrent = 2; + kReactiveCurrent = 3; + kApparentCurrent = 4; + kActivePower = 5; + kReactivePower = 6; + kApparentPower = 7; + kRMSVoltage = 8; + kRMSCurrent = 9; + kRMSPower = 10; + kFrequency = 11; + kPowerFactor = 12; + kNeutralCurrent = 13; + kElectricalEnergy = 14; + } + + enum PowerModeEnum : enum8 { + kUnknown = 0; + kDC = 1; + kAC = 2; + } + + bitmap Feature : bitmap32 { + kDirectCurrent = 0x1; + kAlternatingCurrent = 0x2; + kPolyphasePower = 0x4; + kHarmonics = 0x8; + kPowerQuality = 0x10; + } + + struct MeasurementAccuracyRangeStruct { + int64s rangeMin = 0; + int64s rangeMax = 1; + optional percent100ths percentMax = 2; + optional percent100ths percentMin = 3; + optional percent100ths percentTypical = 4; + optional int64u fixedMax = 5; + optional int64u fixedMin = 6; + optional int64u fixedTypical = 7; + } + + struct MeasurementAccuracyStruct { + MeasurementTypeEnum measurementType = 0; + boolean measured = 1; + int64s minMeasuredValue = 2; + int64s maxMeasuredValue = 3; + MeasurementAccuracyRangeStruct accuracyRanges[] = 4; + } + + struct HarmonicMeasurementStruct { + int8u order = 0; + nullable int64s measurement = 1; + } + + struct MeasurementRangeStruct { + MeasurementTypeEnum measurementType = 0; + int64s min = 1; + int64s max = 2; + optional epoch_s startTimestamp = 3; + optional epoch_s endTimestamp = 4; + optional epoch_s minTimestamp = 5; + optional epoch_s maxTimestamp = 6; + optional systime_ms startSystime = 7; + optional systime_ms endSystime = 8; + optional systime_ms minSystime = 9; + optional systime_ms maxSystime = 10; + } + + info event MeasurementPeriodRanges = 0 { + MeasurementRangeStruct ranges[] = 0; + } + + readonly attribute PowerModeEnum powerMode = 0; + readonly attribute int8u numberOfMeasurementTypes = 1; + readonly attribute MeasurementAccuracyStruct accuracy[] = 2; + readonly attribute optional MeasurementRangeStruct ranges[] = 3; + readonly attribute optional nullable voltage_mv voltage = 4; + readonly attribute optional nullable amperage_ma activeCurrent = 5; + readonly attribute optional nullable amperage_ma reactiveCurrent = 6; + readonly attribute optional nullable amperage_ma apparentCurrent = 7; + readonly attribute nullable power_mw activePower = 8; + readonly attribute optional nullable power_mw reactivePower = 9; + readonly attribute optional nullable power_mw apparentPower = 10; + readonly attribute optional nullable voltage_mv RMSVoltage = 11; + readonly attribute optional nullable amperage_ma RMSCurrent = 12; + readonly attribute optional nullable power_mw RMSPower = 13; + readonly attribute optional nullable int64s frequency = 14; + readonly attribute optional nullable HarmonicMeasurementStruct harmonicCurrents[] = 15; + readonly attribute optional nullable HarmonicMeasurementStruct harmonicPhases[] = 16; + readonly attribute optional nullable int64s powerFactor = 17; + readonly attribute optional nullable amperage_ma neutralCurrent = 18; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + /** This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. */ provisional cluster ElectricalEnergyMeasurement = 145 { revision 1; @@ -4139,8 +4260,15 @@ provisional cluster ElectricalEnergyMeasurement = 145 { MeasurementAccuracyRangeStruct accuracyRanges[] = 4; } + struct CumulativeEnergyResetStruct { + optional nullable epoch_s importedResetTimestamp = 0; + optional nullable epoch_s exportedResetTimestamp = 1; + optional nullable systime_ms importedResetSystime = 2; + optional nullable systime_ms exportedResetSystime = 3; + } + struct EnergyMeasurementStruct { - int64s energy = 0; + energy_mwh energy = 0; optional epoch_s startTimestamp = 1; optional epoch_s endTimestamp = 2; optional systime_ms startSystime = 3; @@ -4162,6 +4290,7 @@ provisional cluster ElectricalEnergyMeasurement = 145 { readonly attribute optional nullable EnergyMeasurementStruct cumulativeEnergyExported = 2; readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyImported = 3; readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyExported = 4; + readonly attribute optional nullable CumulativeEnergyResetStruct cumulativeEnergyReset = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -4881,6 +5010,27 @@ cluster EnergyPreference = 155 { readonly attribute int16u clusterRevision = 65533; } +/** The Power Topology Cluster provides a mechanism for expressing how power is flowing between endpoints. */ +cluster PowerTopology = 156 { + revision 1; + + bitmap Feature : bitmap32 { + kNodeTopology = 0x1; + kTreeTopology = 0x2; + kSetTopology = 0x4; + kDynamicPowerFlow = 0x8; + } + + readonly attribute optional endpoint_no availableEndpoints[] = 0; + readonly attribute optional endpoint_no activeEndpoints[] = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + /** Attributes and commands for selecting a mode from a list of supported options. */ provisional cluster EnergyEvseMode = 157 { revision 1; diff --git a/src/controller/data_model/controller-clusters.zap b/src/controller/data_model/controller-clusters.zap index 727872d00da0a6..df0b178cad6397 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -3124,6 +3124,92 @@ } ] }, + { + "name": "Electrical Power Measurement", + "code": 144, + "mfgCode": null, + "define": "ELECTRICAL_POWER_MEASUREMENT_CLUSTER", + "side": "client", + "enabled": 1, + "apiMaturity": "provisional", + "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": "Electrical Energy Measurement", + "code": 145, + "mfgCode": null, + "define": "ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER", + "side": "client", + "enabled": 1, + "apiMaturity": "provisional", + "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": "Device Energy Management", "code": 152, diff --git a/src/controller/java/AndroidDeviceControllerWrapper.cpp b/src/controller/java/AndroidDeviceControllerWrapper.cpp index 29f055560527d6..b02e93ba48c8a7 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.cpp +++ b/src/controller/java/AndroidDeviceControllerWrapper.cpp @@ -104,7 +104,8 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew( #endif jobject keypairDelegate, jbyteArray rootCertificate, jbyteArray intermediateCertificate, jbyteArray nodeOperationalCertificate, jbyteArray ipkEpochKey, uint16_t listenPort, uint16_t controllerVendorId, uint16_t failsafeTimerSeconds, - bool attemptNetworkScanWiFi, bool attemptNetworkScanThread, bool skipCommissioningComplete, CHIP_ERROR * errInfoOnFailure) + bool attemptNetworkScanWiFi, bool attemptNetworkScanThread, bool skipCommissioningComplete, + bool skipAttestationCertificateValidation, CHIP_ERROR * errInfoOnFailure) { if (errInfoOnFailure == nullptr) { @@ -168,8 +169,15 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew( #endif // Initialize device attestation verifier - const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); - chip::Credentials::SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore)); + if (skipAttestationCertificateValidation) + { + chip::Credentials::SetDeviceAttestationVerifier(wrapper->GetPartialDACVerifier()); + } + else + { + const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); + chip::Credentials::SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore)); + } *errInfoOnFailure = wrapper->mICDClientStorage.Init(wrapperStorage, &wrapper->mSessionKeystore); if (*errInfoOnFailure != CHIP_NO_ERROR) diff --git a/src/controller/java/AndroidDeviceControllerWrapper.h b/src/controller/java/AndroidDeviceControllerWrapper.h index 69a7fe75c0bf0b..d5b07cf7164a75 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.h +++ b/src/controller/java/AndroidDeviceControllerWrapper.h @@ -184,7 +184,7 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel jobject keypairDelegate, jbyteArray rootCertificate, jbyteArray intermediateCertificate, jbyteArray nodeOperationalCertificate, jbyteArray ipkEpochKey, uint16_t listenPort, uint16_t controllerVendorId, uint16_t failsafeTimerSeconds, bool attemptNetworkScanWiFi, bool attemptNetworkScanThread, - bool skipCommissioningComplete, CHIP_ERROR * errInfoOnFailure); + bool skipCommissioningComplete, bool skipAttestationCertificateValidation, CHIP_ERROR * errInfoOnFailure); void Shutdown(); diff --git a/src/controller/java/AndroidOperationalCredentialsIssuer.cpp b/src/controller/java/AndroidOperationalCredentialsIssuer.cpp index f63f1a46ecbbe3..af9e8adc8621a0 100644 --- a/src/controller/java/AndroidOperationalCredentialsIssuer.cpp +++ b/src/controller/java/AndroidOperationalCredentialsIssuer.cpp @@ -135,10 +135,8 @@ CHIP_ERROR AndroidOperationalCredentialsIssuer::GenerateNOCChain(const ByteSpan { return CallbackGenerateNOCChain(csrElements, csrNonce, attestationSignature, attestationChallenge, DAC, PAI, onCompletion); } - else - { - return LocalGenerateNOCChain(csrElements, csrNonce, attestationSignature, attestationChallenge, DAC, PAI, onCompletion); - } + + return LocalGenerateNOCChain(csrElements, csrNonce, attestationSignature, attestationChallenge, DAC, PAI, onCompletion); } CHIP_ERROR AndroidOperationalCredentialsIssuer::CallbackGenerateNOCChain(const ByteSpan & csrElements, const ByteSpan & csrNonce, diff --git a/src/controller/java/CHIPDefaultCallbacks.cpp b/src/controller/java/CHIPDefaultCallbacks.cpp deleted file mode 100644 index 4600c5c9877a14..00000000000000 --- a/src/controller/java/CHIPDefaultCallbacks.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include "CHIPDefaultCallbacks.h" -#include "AndroidClusterExceptions.h" - -#include -#include -#include -#include - -chip::CHIPDefaultSuccessCallback::CHIPDefaultSuccessCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -chip::CHIPDefaultSuccessCallback::~CHIPDefaultSuccessCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -} - -void chip::CHIPDefaultSuccessCallback::CallbackFn(void * context) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - jmethodID javaMethod; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - CHIPDefaultSuccessCallback * cppCallback = nullptr; - - VerifyOrExit(env != nullptr, err = CHIP_JNI_ERROR_NO_ENV); - - cppCallback = reinterpret_cast(context); - VerifyOrExit(cppCallback != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. - javaCallbackRef = cppCallback->javaCallbackRef; - VerifyOrExit(javaCallbackRef != nullptr, err = CHIP_NO_ERROR); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "()V", &javaMethod); - SuccessOrExit(err); - - env->ExceptionClear(); - env->CallVoidMethod(javaCallbackRef, javaMethod); - -exit: - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error invoking Java callback: %" CHIP_ERROR_FORMAT, err.Format()); - } - if (cppCallback != nullptr) - { - cppCallback->Cancel(); - delete cppCallback; - } -} - -chip::CHIPDefaultFailureCallback::CHIPDefaultFailureCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -chip::CHIPDefaultFailureCallback::~CHIPDefaultFailureCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -} - -void chip::CHIPDefaultFailureCallback::CallbackFn(void * context, CHIP_ERROR error) -{ - chip::app::StatusIB status(error); - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - jmethodID javaMethod; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceScope scope(env); - - jobject javaCallbackRef; - jthrowable exception; - CHIPDefaultFailureCallback * cppCallback = nullptr; - - VerifyOrExit(env != nullptr, err = CHIP_JNI_ERROR_NO_ENV); - - cppCallback = reinterpret_cast(context); - VerifyOrExit(cppCallback != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. - javaCallbackRef = cppCallback->javaCallbackRef; - VerifyOrExit(javaCallbackRef != nullptr, err = CHIP_NO_ERROR); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onError", "(Ljava/lang/Exception;)V", &javaMethod); - SuccessOrExit(err); - - // TODO: Figure out what to do with the non-StatusIB cases and the cases - // when we have a cluster status? - err = chip::AndroidClusterExceptions::GetInstance().CreateChipClusterException(env, chip::to_underlying(status.mStatus), - exception); - SuccessOrExit(err); - - env->ExceptionClear(); - env->CallVoidMethod(javaCallbackRef, javaMethod, exception); -exit: - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error invoking Java callback: %" CHIP_ERROR_FORMAT, err.Format()); - } - if (cppCallback != nullptr) - { - cppCallback->Cancel(); - delete cppCallback; - } -} diff --git a/src/controller/java/CHIPDefaultCallbacks.h b/src/controller/java/CHIPDefaultCallbacks.h deleted file mode 100644 index 8256bf6a38e035..00000000000000 --- a/src/controller/java/CHIPDefaultCallbacks.h +++ /dev/null @@ -1,38 +0,0 @@ -#include - -#include -#include - -#include - -namespace chip { - -/** A success callback that delegates to the Java DefaultClusterCallback.onSuccess(). */ -class CHIPDefaultSuccessCallback : public Callback::Callback -{ -public: - CHIPDefaultSuccessCallback(jobject javaCallback); - - ~CHIPDefaultSuccessCallback(); - - static void CallbackFn(void * context); - -private: - jobject javaCallbackRef; -}; - -/** A failure callback that delegates to the Java DefaultClusterCallback.onError(). */ -class CHIPDefaultFailureCallback : public Callback::Callback -{ -public: - CHIPDefaultFailureCallback(jobject javaCallback); - - ~CHIPDefaultFailureCallback(); - - static void CallbackFn(void * context, CHIP_ERROR error); - -private: - jobject javaCallbackRef; -}; - -} // namespace chip diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index b32c207fcf92f9..29cab3b22424e3 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -106,7 +106,7 @@ JavaVM * sJVM; pthread_t sIOThread = PTHREAD_NULL; -jclass sChipDeviceControllerExceptionCls = NULL; +jclass sChipDeviceControllerExceptionCls = nullptr; } // namespace @@ -131,7 +131,7 @@ jint JNI_OnLoad(JavaVM * jvm, void * reserved) // Get a JNI environment object. env = JniReferences::GetInstance().GetEnvForCurrentThread(); - VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV); + VerifyOrExit(env != nullptr, err = CHIP_JNI_ERROR_NO_ENV); ChipLogProgress(Controller, "Loading Java class references."); @@ -171,7 +171,7 @@ void JNI_OnUnload(JavaVM * jvm, void * reserved) // should be stopped before the library is unloaded. StopIOThread(); - sJVM = NULL; + sJVM = nullptr; chip::Platform::MemoryShutdown(); } @@ -280,7 +280,7 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - AndroidDeviceControllerWrapper * wrapper = NULL; + AndroidDeviceControllerWrapper * wrapper = nullptr; jlong result = 0; ChipLogProgress(Controller, "newDeviceController() called"); @@ -323,6 +323,11 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr &getSkipCommissioningComplete); SuccessOrExit(err); + jmethodID getSkipAttestationCertificateValidation; + err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getSkipAttestationCertificateValidation", "()Z", + &getSkipAttestationCertificateValidation); + SuccessOrExit(err); + jmethodID getCountryCode; err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getCountryCode", "()Ljava/util/Optional;", &getCountryCode); @@ -372,9 +377,11 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr uint16_t failsafeTimerSeconds = static_cast(env->CallIntMethod(controllerParams, getFailsafeTimerSeconds)); uint16_t caseFailsafeTimerSeconds = static_cast(env->CallIntMethod(controllerParams, getCASEFailsafeTimerSeconds)); - bool attemptNetworkScanWiFi = env->CallBooleanMethod(controllerParams, getAttemptNetworkScanWiFi); - bool attemptNetworkScanThread = env->CallBooleanMethod(controllerParams, getAttemptNetworkScanThread); - bool skipCommissioningComplete = env->CallBooleanMethod(controllerParams, getSkipCommissioningComplete); + bool attemptNetworkScanWiFi = env->CallBooleanMethod(controllerParams, getAttemptNetworkScanWiFi); + bool attemptNetworkScanThread = env->CallBooleanMethod(controllerParams, getAttemptNetworkScanThread); + bool skipCommissioningComplete = env->CallBooleanMethod(controllerParams, getSkipCommissioningComplete); + bool skipAttestationCertificateValidation = + env->CallBooleanMethod(controllerParams, getSkipAttestationCertificateValidation); uint64_t adminSubject = static_cast(env->CallLongMethod(controllerParams, getAdminSubject)); jobject countryCodeOptional = env->CallObjectMethod(controllerParams, getCountryCode); jobject regulatoryLocationOptional = env->CallObjectMethod(controllerParams, getRegulatoryLocation); @@ -390,7 +397,8 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr sJVM, self, kLocalDeviceId, fabricId, chip::kUndefinedCATs, &DeviceLayer::SystemLayer(), DeviceLayer::TCPEndPointManager(), DeviceLayer::UDPEndPointManager(), std::move(opCredsIssuer), keypairDelegate, rootCertificate, intermediateCertificate, operationalCertificate, ipk, listenPort, controllerVendorId, - failsafeTimerSeconds, attemptNetworkScanWiFi, attemptNetworkScanThread, skipCommissioningComplete, &err); + failsafeTimerSeconds, attemptNetworkScanWiFi, attemptNetworkScanThread, skipCommissioningComplete, + skipAttestationCertificateValidation, &err); SuccessOrExit(err); if (caseFailsafeTimerSeconds > 0) @@ -470,7 +478,7 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr // Create and start the IO thread. Must be called after Controller()->Init if (sIOThread == PTHREAD_NULL) { - int pthreadErr = pthread_create(&sIOThread, NULL, IOThreadMain, NULL); + int pthreadErr = pthread_create(&sIOThread, nullptr, IOThreadMain, nullptr); VerifyOrExit(pthreadErr == 0, err = CHIP_ERROR_POSIX(pthreadErr)); } @@ -479,7 +487,7 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr exit: if (err != CHIP_NO_ERROR) { - if (wrapper != NULL) + if (wrapper != nullptr) { delete wrapper; } @@ -1383,7 +1391,7 @@ JNI_METHOD(void, releaseOperationalDevicePointer)(JNIEnv * env, jobject self, jl { chip::DeviceLayer::StackLock lock; OperationalDeviceProxy * device = reinterpret_cast(devicePtr); - if (device != NULL) + if (device != nullptr) { delete device; } @@ -1414,7 +1422,7 @@ JNI_METHOD(void, releaseGroupDevicePointer)(JNIEnv * env, jobject self, jlong de { chip::DeviceLayer::StackLock lock; GroupDeviceProxy * device = reinterpret_cast(devicePtr); - if (device != NULL) + if (device != nullptr) { delete device; } @@ -1902,6 +1910,7 @@ JNI_METHOD(jobject, getDiscoveredDevice)(JNIEnv * env, jobject self, jlong handl if (data == nullptr) { + ChipLogError(Controller, "GetDiscoveredDevice - not found"); return nullptr; } @@ -1910,6 +1919,7 @@ JNI_METHOD(jobject, getDiscoveredDevice)(JNIEnv * env, jobject self, jlong handl jfieldID discrminatorID = env->GetFieldID(discoveredDeviceCls, "discriminator", "J"); jfieldID ipAddressID = env->GetFieldID(discoveredDeviceCls, "ipAddress", "Ljava/lang/String;"); + jfieldID portID = env->GetFieldID(discoveredDeviceCls, "port", "I"); jobject discoveredObj = env->NewObject(discoveredDeviceCls, constructor); @@ -1918,12 +1928,10 @@ JNI_METHOD(jobject, getDiscoveredDevice)(JNIEnv * env, jobject self, jlong handl char ipAddress[100]; data->resolutionData.ipAddress[0].ToString(ipAddress, 100); jstring jniipAdress = env->NewStringUTF(ipAddress); + env->SetObjectField(discoveredObj, ipAddressID, jniipAdress); + env->SetIntField(discoveredObj, portID, static_cast(data->resolutionData.port)); - if (data == nullptr) - { - ChipLogError(Controller, "GetDiscoveredDevice - not found"); - } return discoveredObj; } @@ -2109,7 +2117,7 @@ JNI_METHOD(void, deleteDeviceController)(JNIEnv * env, jobject self, jlong handl ChipLogProgress(Controller, "deleteDeviceController() called"); - if (wrapper != NULL) + if (wrapper != nullptr) { delete wrapper; } @@ -2156,6 +2164,33 @@ JNI_METHOD(jobject, computePaseVerifier) return nullptr; } +JNI_METHOD(jbyteArray, validateAndExtractCSR)(JNIEnv * env, jclass clazz, jbyteArray jCsrElements, jbyteArray jCsrNonce) +{ + + chip::JniByteArray csrElements(env, jCsrElements); + chip::JniByteArray csrNonce(env, jCsrNonce); + + chip::ByteSpan csrSpan; + chip::ByteSpan csrNonceSpan; + chip::ByteSpan vendor_reserved1, vendor_reserved2, vendor_reserved3; + CHIP_ERROR err = chip::Credentials::DeconstructNOCSRElements(csrElements.byteSpan(), csrSpan, csrNonceSpan, vendor_reserved1, + vendor_reserved2, vendor_reserved3); + + VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, + ChipLogError(Controller, "CsrElement decoding error: %" CHIP_ERROR_FORMAT, err.Format())); + VerifyOrReturnValue(csrNonceSpan.size() == Controller::kCSRNonceLength, nullptr, + ChipLogError(Controller, "csrNonce size is invalid")); + + // Verify that Nonce matches with what we sent + VerifyOrReturnValue(csrNonceSpan.data_equal(csrNonce.byteSpan()), nullptr, + ChipLogError(Controller, "csrNonce is not matched!")); + + jbyteArray javaCsr; + chip::JniReferences::GetInstance().N2J_ByteArray(chip::JniReferences::GetInstance().GetEnvForCurrentThread(), csrSpan.data(), + static_cast(csrSpan.size()), javaCsr); + return javaCsr; +} + JNI_METHOD(jobject, getICDClientInfo)(JNIEnv * env, jobject self, jlong handle, jint jFabricIndex) { chip::DeviceLayer::StackLock lock; @@ -3032,7 +3067,7 @@ void * IOThreadMain(void * arg) // This allows the JVM to shutdown without waiting for this thread to exit. attachArgs.version = JNI_VERSION_1_6; attachArgs.name = (char *) "CHIP Device Controller IO Thread"; - attachArgs.group = NULL; + attachArgs.group = nullptr; #ifdef __ANDROID__ sJVM->AttachCurrentThreadAsDaemon(&env, (void *) &attachArgs); #else @@ -3046,7 +3081,7 @@ void * IOThreadMain(void * arg) // Detach the thread from the JVM. sJVM->DetachCurrentThread(); - return NULL; + return nullptr; } // NOTE: This function SHALL be called with the stack lock held. @@ -3059,7 +3094,7 @@ CHIP_ERROR StopIOThread() chip::DeviceLayer::PlatformMgr().StopEventLoopTask(); - pthread_join(sIOThread, NULL); + pthread_join(sIOThread, nullptr); sIOThread = PTHREAD_NULL; } diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java index 262059e5f3b85f..6e479c5f37094c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java @@ -161,7 +161,6 @@ protected void invoke( @Deprecated public void deleteCluster(long chipClusterPtr) {} - @SuppressWarnings("deprecation") protected void finalize() throws Throwable { super.finalize(); @@ -316,12 +315,12 @@ public void identify(DefaultClusterCallback callback, Integer identifyTime, int BaseTLVType identifyTimetlvValue = new UIntType(identifyTime); elements.add(new StructElement(identifyTimeFieldID, identifyTimetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void triggerEffect(DefaultClusterCallback callback, Integer effectIdentifier, Integer effectVariant) { @@ -340,12 +339,12 @@ public void triggerEffect(DefaultClusterCallback callback, Integer effectIdentif BaseTLVType effectVarianttlvValue = new UIntType(effectVariant); elements.add(new StructElement(effectVariantFieldID, effectVarianttlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { @@ -611,7 +610,7 @@ public void addGroup(AddGroupResponseCallback callback, Integer groupID, String BaseTLVType groupNametlvValue = new StringType(groupName); elements.add(new StructElement(groupNameFieldID, groupNametlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -633,7 +632,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, groupID); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void viewGroup(ViewGroupResponseCallback callback, Integer groupID) { @@ -648,7 +647,7 @@ public void viewGroup(ViewGroupResponseCallback callback, Integer groupID, int t BaseTLVType groupIDtlvValue = new UIntType(groupID); elements.add(new StructElement(groupIDFieldID, groupIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -677,7 +676,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, groupID, groupName); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void getGroupMembership(GetGroupMembershipResponseCallback callback, ArrayList groupList) { @@ -692,7 +691,7 @@ public void getGroupMembership(GetGroupMembershipResponseCallback callback, Arra BaseTLVType groupListtlvValue = ArrayType.generateArrayType(groupList, (elementgroupList) -> new UIntType(elementgroupList)); elements.add(new StructElement(groupListFieldID, groupListtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -714,7 +713,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(capacity, groupList); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void removeGroup(RemoveGroupResponseCallback callback, Integer groupID) { @@ -729,7 +728,7 @@ public void removeGroup(RemoveGroupResponseCallback callback, Integer groupID, i BaseTLVType groupIDtlvValue = new UIntType(groupID); elements.add(new StructElement(groupIDFieldID, groupIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -751,7 +750,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, groupID); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void removeAllGroups(DefaultClusterCallback callback) { @@ -762,12 +761,12 @@ public void removeAllGroups(DefaultClusterCallback callback, int timedInvokeTime final long commandId = 4L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void addGroupIfIdentifying(DefaultClusterCallback callback, Integer groupID, String groupName) { @@ -786,12 +785,12 @@ public void addGroupIfIdentifying(DefaultClusterCallback callback, Integer group BaseTLVType groupNametlvValue = new StringType(groupName); elements.add(new StructElement(groupNameFieldID, groupNametlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface AddGroupResponseCallback extends BaseClusterCallback { @@ -1035,12 +1034,12 @@ public void off(DefaultClusterCallback callback, int timedInvokeTimeoutMs) { final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void on(DefaultClusterCallback callback) { @@ -1051,12 +1050,12 @@ public void on(DefaultClusterCallback callback, int timedInvokeTimeoutMs) { final long commandId = 1L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void toggle(DefaultClusterCallback callback) { @@ -1067,12 +1066,12 @@ public void toggle(DefaultClusterCallback callback, int timedInvokeTimeoutMs) { final long commandId = 2L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void offWithEffect(DefaultClusterCallback callback, Integer effectIdentifier, Integer effectVariant) { @@ -1091,12 +1090,12 @@ public void offWithEffect(DefaultClusterCallback callback, Integer effectIdentif BaseTLVType effectVarianttlvValue = new UIntType(effectVariant); elements.add(new StructElement(effectVariantFieldID, effectVarianttlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void onWithRecallGlobalScene(DefaultClusterCallback callback) { @@ -1107,12 +1106,12 @@ public void onWithRecallGlobalScene(DefaultClusterCallback callback, int timedIn final long commandId = 65L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void onWithTimedOff(DefaultClusterCallback callback, Integer onOffControl, Integer onTime, Integer offWaitTime) { @@ -1135,12 +1134,12 @@ public void onWithTimedOff(DefaultClusterCallback callback, Integer onOffControl BaseTLVType offWaitTimetlvValue = new UIntType(offWaitTime); elements.add(new StructElement(offWaitTimeFieldID, offWaitTimetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface StartUpOnOffAttributeCallback extends BaseAttributeCallback { @@ -1772,12 +1771,12 @@ public void moveToLevel(DefaultClusterCallback callback, Integer level, @Nullabl BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void move(DefaultClusterCallback callback, Integer moveMode, @Nullable Integer rate, Integer optionsMask, Integer optionsOverride) { @@ -1804,12 +1803,12 @@ public void move(DefaultClusterCallback callback, Integer moveMode, @Nullable In BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void step(DefaultClusterCallback callback, Integer stepMode, Integer stepSize, @Nullable Integer transitionTime, Integer optionsMask, Integer optionsOverride) { @@ -1840,12 +1839,12 @@ public void step(DefaultClusterCallback callback, Integer stepMode, Integer step BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stop(DefaultClusterCallback callback, Integer optionsMask, Integer optionsOverride) { @@ -1864,12 +1863,12 @@ public void stop(DefaultClusterCallback callback, Integer optionsMask, Integer o BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void moveToLevelWithOnOff(DefaultClusterCallback callback, Integer level, @Nullable Integer transitionTime, Integer optionsMask, Integer optionsOverride) { @@ -1896,12 +1895,12 @@ public void moveToLevelWithOnOff(DefaultClusterCallback callback, Integer level, BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void moveWithOnOff(DefaultClusterCallback callback, Integer moveMode, @Nullable Integer rate, Integer optionsMask, Integer optionsOverride) { @@ -1928,12 +1927,12 @@ public void moveWithOnOff(DefaultClusterCallback callback, Integer moveMode, @Nu BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stepWithOnOff(DefaultClusterCallback callback, Integer stepMode, Integer stepSize, @Nullable Integer transitionTime, Integer optionsMask, Integer optionsOverride) { @@ -1964,12 +1963,12 @@ public void stepWithOnOff(DefaultClusterCallback callback, Integer stepMode, Int BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stopWithOnOff(DefaultClusterCallback callback, Integer optionsMask, Integer optionsOverride) { @@ -1988,12 +1987,12 @@ public void stopWithOnOff(DefaultClusterCallback callback, Integer optionsMask, BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void moveToClosestFrequency(DefaultClusterCallback callback, Integer frequency) { @@ -2008,12 +2007,12 @@ public void moveToClosestFrequency(DefaultClusterCallback callback, Integer freq BaseTLVType frequencytlvValue = new UIntType(frequency); elements.add(new StructElement(frequencyFieldID, frequencytlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface CurrentLevelAttributeCallback extends BaseAttributeCallback { @@ -4242,12 +4241,12 @@ public void instantAction(DefaultClusterCallback callback, Integer actionID, Opt BaseTLVType invokeIDtlvValue = invokeID.map((nonOptionalinvokeID) -> new UIntType(nonOptionalinvokeID)).orElse(new EmptyType()); elements.add(new StructElement(invokeIDFieldID, invokeIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void instantActionWithTransition(DefaultClusterCallback callback, Integer actionID, Optional invokeID, Integer transitionTime) { @@ -4270,12 +4269,12 @@ public void instantActionWithTransition(DefaultClusterCallback callback, Integer BaseTLVType transitionTimetlvValue = new UIntType(transitionTime); elements.add(new StructElement(transitionTimeFieldID, transitionTimetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void startAction(DefaultClusterCallback callback, Integer actionID, Optional invokeID) { @@ -4294,12 +4293,12 @@ public void startAction(DefaultClusterCallback callback, Integer actionID, Optio BaseTLVType invokeIDtlvValue = invokeID.map((nonOptionalinvokeID) -> new UIntType(nonOptionalinvokeID)).orElse(new EmptyType()); elements.add(new StructElement(invokeIDFieldID, invokeIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void startActionWithDuration(DefaultClusterCallback callback, Integer actionID, Optional invokeID, Long duration) { @@ -4322,12 +4321,12 @@ public void startActionWithDuration(DefaultClusterCallback callback, Integer act BaseTLVType durationtlvValue = new UIntType(duration); elements.add(new StructElement(durationFieldID, durationtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stopAction(DefaultClusterCallback callback, Integer actionID, Optional invokeID) { @@ -4346,12 +4345,12 @@ public void stopAction(DefaultClusterCallback callback, Integer actionID, Option BaseTLVType invokeIDtlvValue = invokeID.map((nonOptionalinvokeID) -> new UIntType(nonOptionalinvokeID)).orElse(new EmptyType()); elements.add(new StructElement(invokeIDFieldID, invokeIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void pauseAction(DefaultClusterCallback callback, Integer actionID, Optional invokeID) { @@ -4370,12 +4369,12 @@ public void pauseAction(DefaultClusterCallback callback, Integer actionID, Optio BaseTLVType invokeIDtlvValue = invokeID.map((nonOptionalinvokeID) -> new UIntType(nonOptionalinvokeID)).orElse(new EmptyType()); elements.add(new StructElement(invokeIDFieldID, invokeIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void pauseActionWithDuration(DefaultClusterCallback callback, Integer actionID, Optional invokeID, Long duration) { @@ -4398,12 +4397,12 @@ public void pauseActionWithDuration(DefaultClusterCallback callback, Integer act BaseTLVType durationtlvValue = new UIntType(duration); elements.add(new StructElement(durationFieldID, durationtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void resumeAction(DefaultClusterCallback callback, Integer actionID, Optional invokeID) { @@ -4422,12 +4421,12 @@ public void resumeAction(DefaultClusterCallback callback, Integer actionID, Opti BaseTLVType invokeIDtlvValue = invokeID.map((nonOptionalinvokeID) -> new UIntType(nonOptionalinvokeID)).orElse(new EmptyType()); elements.add(new StructElement(invokeIDFieldID, invokeIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void enableAction(DefaultClusterCallback callback, Integer actionID, Optional invokeID) { @@ -4446,12 +4445,12 @@ public void enableAction(DefaultClusterCallback callback, Integer actionID, Opti BaseTLVType invokeIDtlvValue = invokeID.map((nonOptionalinvokeID) -> new UIntType(nonOptionalinvokeID)).orElse(new EmptyType()); elements.add(new StructElement(invokeIDFieldID, invokeIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void enableActionWithDuration(DefaultClusterCallback callback, Integer actionID, Optional invokeID, Long duration) { @@ -4474,12 +4473,12 @@ public void enableActionWithDuration(DefaultClusterCallback callback, Integer ac BaseTLVType durationtlvValue = new UIntType(duration); elements.add(new StructElement(durationFieldID, durationtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void disableAction(DefaultClusterCallback callback, Integer actionID, Optional invokeID) { @@ -4498,12 +4497,12 @@ public void disableAction(DefaultClusterCallback callback, Integer actionID, Opt BaseTLVType invokeIDtlvValue = invokeID.map((nonOptionalinvokeID) -> new UIntType(nonOptionalinvokeID)).orElse(new EmptyType()); elements.add(new StructElement(invokeIDFieldID, invokeIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void disableActionWithDuration(DefaultClusterCallback callback, Integer actionID, Optional invokeID, Long duration) { @@ -4526,12 +4525,12 @@ public void disableActionWithDuration(DefaultClusterCallback callback, Integer a BaseTLVType durationtlvValue = new UIntType(duration); elements.add(new StructElement(durationFieldID, durationtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ActionListAttributeCallback extends BaseAttributeCallback { @@ -4835,12 +4834,12 @@ public void mfgSpecificPing(DefaultClusterCallback callback, int timedInvokeTime final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface CapabilityMinimaAttributeCallback extends BaseAttributeCallback { @@ -5680,7 +5679,7 @@ public void queryImage(QueryImageResponseCallback callback, Integer vendorID, In BaseTLVType metadataForProvidertlvValue = metadataForProvider.map((nonOptionalmetadataForProvider) -> new ByteArrayType(nonOptionalmetadataForProvider)).orElse(new EmptyType()); elements.add(new StructElement(metadataForProviderFieldID, metadataForProvidertlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -5744,7 +5743,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, delayedActionTime, imageURI, softwareVersion, softwareVersionString, updateToken, userConsentNeeded, metadataForRequestor); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void applyUpdateRequest(ApplyUpdateResponseCallback callback, byte[] updateToken, Long newVersion) { @@ -5763,7 +5762,7 @@ public void applyUpdateRequest(ApplyUpdateResponseCallback callback, byte[] upda BaseTLVType newVersiontlvValue = new UIntType(newVersion); elements.add(new StructElement(newVersionFieldID, newVersiontlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -5785,7 +5784,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(action, delayedActionTime); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void notifyUpdateApplied(DefaultClusterCallback callback, byte[] updateToken, Long softwareVersion) { @@ -5804,12 +5803,12 @@ public void notifyUpdateApplied(DefaultClusterCallback callback, byte[] updateTo BaseTLVType softwareVersiontlvValue = new UIntType(softwareVersion); elements.add(new StructElement(softwareVersionFieldID, softwareVersiontlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface QueryImageResponseCallback extends BaseClusterCallback { @@ -6039,12 +6038,12 @@ public void announceOTAProvider(DefaultClusterCallback callback, Long providerNo BaseTLVType endpointtlvValue = new UIntType(endpoint); elements.add(new StructElement(endpointFieldID, endpointtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface DefaultOTAProvidersAttributeCallback extends BaseAttributeCallback { @@ -8422,7 +8421,7 @@ public void armFailSafe(ArmFailSafeResponseCallback callback, Integer expiryLeng BaseTLVType breadcrumbtlvValue = new UIntType(breadcrumb); elements.add(new StructElement(breadcrumbFieldID, breadcrumbtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -8444,7 +8443,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(errorCode, debugText); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setRegulatoryConfig(SetRegulatoryConfigResponseCallback callback, Integer newRegulatoryConfig, String countryCode, Long breadcrumb) { @@ -8467,7 +8466,7 @@ public void setRegulatoryConfig(SetRegulatoryConfigResponseCallback callback, In BaseTLVType breadcrumbtlvValue = new UIntType(breadcrumb); elements.add(new StructElement(breadcrumbFieldID, breadcrumbtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -8489,7 +8488,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(errorCode, debugText); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void commissioningComplete(CommissioningCompleteResponseCallback callback) { @@ -8500,7 +8499,7 @@ public void commissioningComplete(CommissioningCompleteResponseCallback callback final long commandId = 4L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -8522,7 +8521,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(errorCode, debugText); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ArmFailSafeResponseCallback extends BaseClusterCallback { @@ -8889,7 +8888,7 @@ public void scanNetworks(ScanNetworksResponseCallback callback, @Nullable Option BaseTLVType breadcrumbtlvValue = breadcrumb.map((nonOptionalbreadcrumb) -> new UIntType(nonOptionalbreadcrumb)).orElse(new EmptyType()); elements.add(new StructElement(breadcrumbFieldID, breadcrumbtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -8925,7 +8924,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(networkingStatus, debugText, wiFiScanResults, threadScanResults); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void addOrUpdateWiFiNetwork(NetworkConfigResponseCallback callback, byte[] ssid, byte[] credentials, Optional breadcrumb, Optional networkIdentity, Optional clientIdentifier, Optional possessionNonce) { @@ -8960,7 +8959,7 @@ public void addOrUpdateWiFiNetwork(NetworkConfigResponseCallback callback, byte[ BaseTLVType possessionNoncetlvValue = possessionNonce.map((nonOptionalpossessionNonce) -> new ByteArrayType(nonOptionalpossessionNonce)).orElse(new EmptyType()); elements.add(new StructElement(possessionNonceFieldID, possessionNoncetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -9003,7 +9002,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(networkingStatus, debugText, networkIndex, clientIdentity, possessionSignature); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void addOrUpdateThreadNetwork(NetworkConfigResponseCallback callback, byte[] operationalDataset, Optional breadcrumb) { @@ -9022,7 +9021,7 @@ public void addOrUpdateThreadNetwork(NetworkConfigResponseCallback callback, byt BaseTLVType breadcrumbtlvValue = breadcrumb.map((nonOptionalbreadcrumb) -> new UIntType(nonOptionalbreadcrumb)).orElse(new EmptyType()); elements.add(new StructElement(breadcrumbFieldID, breadcrumbtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -9065,7 +9064,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(networkingStatus, debugText, networkIndex, clientIdentity, possessionSignature); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void removeNetwork(NetworkConfigResponseCallback callback, byte[] networkID, Optional breadcrumb) { @@ -9084,7 +9083,7 @@ public void removeNetwork(NetworkConfigResponseCallback callback, byte[] network BaseTLVType breadcrumbtlvValue = breadcrumb.map((nonOptionalbreadcrumb) -> new UIntType(nonOptionalbreadcrumb)).orElse(new EmptyType()); elements.add(new StructElement(breadcrumbFieldID, breadcrumbtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -9127,7 +9126,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(networkingStatus, debugText, networkIndex, clientIdentity, possessionSignature); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void connectNetwork(ConnectNetworkResponseCallback callback, byte[] networkID, Optional breadcrumb) { @@ -9146,7 +9145,7 @@ public void connectNetwork(ConnectNetworkResponseCallback callback, byte[] netwo BaseTLVType breadcrumbtlvValue = breadcrumb.map((nonOptionalbreadcrumb) -> new UIntType(nonOptionalbreadcrumb)).orElse(new EmptyType()); elements.add(new StructElement(breadcrumbFieldID, breadcrumbtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -9175,7 +9174,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(networkingStatus, debugText, errorValue); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void reorderNetwork(NetworkConfigResponseCallback callback, byte[] networkID, Integer networkIndex, Optional breadcrumb) { @@ -9198,7 +9197,7 @@ public void reorderNetwork(NetworkConfigResponseCallback callback, byte[] networ BaseTLVType breadcrumbtlvValue = breadcrumb.map((nonOptionalbreadcrumb) -> new UIntType(nonOptionalbreadcrumb)).orElse(new EmptyType()); elements.add(new StructElement(breadcrumbFieldID, breadcrumbtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -9241,7 +9240,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(networkingStatus, debugText, networkIndex, clientIdentity, possessionSignature); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void queryIdentity(QueryIdentityResponseCallback callback, byte[] keyIdentifier, Optional possessionNonce) { @@ -9260,7 +9259,7 @@ public void queryIdentity(QueryIdentityResponseCallback callback, byte[] keyIden BaseTLVType possessionNoncetlvValue = possessionNonce.map((nonOptionalpossessionNonce) -> new ByteArrayType(nonOptionalpossessionNonce)).orElse(new EmptyType()); elements.add(new StructElement(possessionNonceFieldID, possessionNoncetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -9282,7 +9281,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(identity, possessionSignature); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ScanNetworksResponseCallback extends BaseClusterCallback { @@ -9812,7 +9811,7 @@ public void retrieveLogsRequest(RetrieveLogsResponseCallback callback, Integer i BaseTLVType transferFileDesignatortlvValue = transferFileDesignator.map((nonOptionaltransferFileDesignator) -> new StringType(nonOptionaltransferFileDesignator)).orElse(new EmptyType()); elements.add(new StructElement(transferFileDesignatorFieldID, transferFileDesignatortlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -9848,7 +9847,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, logContent, UTCTimeStamp, timeSinceBoot); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface RetrieveLogsResponseCallback extends BaseClusterCallback { @@ -10067,12 +10066,12 @@ public void testEventTrigger(DefaultClusterCallback callback, byte[] enableKey, BaseTLVType eventTriggertlvValue = new UIntType(eventTrigger); elements.add(new StructElement(eventTriggerFieldID, eventTriggertlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void timeSnapshot(TimeSnapshotResponseCallback callback) { @@ -10083,7 +10082,7 @@ public void timeSnapshot(TimeSnapshotResponseCallback callback, int timedInvokeT final long commandId = 1L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -10105,13 +10104,55 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(systemTimeMs, posixTimeMs); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); + } + + public void payloadTestRequest(PayloadTestResponseCallback callback, byte[] enableKey, Integer value, Integer count) { + payloadTestRequest(callback, enableKey, value, count, 0); + } + + public void payloadTestRequest(PayloadTestResponseCallback callback, byte[] enableKey, Integer value, Integer count, int timedInvokeTimeoutMs) { + final long commandId = 3L; + + ArrayList elements = new ArrayList<>(); + final long enableKeyFieldID = 0L; + BaseTLVType enableKeytlvValue = new ByteArrayType(enableKey); + elements.add(new StructElement(enableKeyFieldID, enableKeytlvValue)); + + final long valueFieldID = 1L; + BaseTLVType valuetlvValue = new UIntType(value); + elements.add(new StructElement(valueFieldID, valuetlvValue)); + + final long countFieldID = 2L; + BaseTLVType counttlvValue = new UIntType(count); + elements.add(new StructElement(countFieldID, counttlvValue)); + + StructType commandArgs = new StructType(elements); + invoke(new InvokeCallbackImpl(callback) { + @Override + public void onResponse(StructType invokeStructValue) { + final long payloadFieldID = 0L; + byte[] payload = null; + for (StructElement element: invokeStructValue.value()) { + if (element.contextTagNum() == payloadFieldID) { + if (element.value(BaseTLVType.class).type() == TLVType.ByteArray) { + ByteArrayType castingValue = element.value(ByteArrayType.class); + payload = castingValue.value(byte[].class); + } + } + } + callback.onSuccess(payload); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface TimeSnapshotResponseCallback extends BaseClusterCallback { void onSuccess(Long systemTimeMs, @Nullable Long posixTimeMs); } + public interface PayloadTestResponseCallback extends BaseClusterCallback { + void onSuccess(byte[] payload); + } + public interface NetworkInterfacesAttributeCallback extends BaseAttributeCallback { void onSuccess(List value); } @@ -10552,12 +10593,12 @@ public void resetWatermarks(DefaultClusterCallback callback, int timedInvokeTime final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ThreadMetricsAttributeCallback extends BaseAttributeCallback { @@ -10922,12 +10963,12 @@ public void resetCounts(DefaultClusterCallback callback, int timedInvokeTimeoutM final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ChannelAttributeCallback extends BaseAttributeCallback { @@ -12793,12 +12834,12 @@ public void resetCounts(DefaultClusterCallback callback, int timedInvokeTimeoutM final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface BssidAttributeCallback extends BaseAttributeCallback { @@ -13382,12 +13423,12 @@ public void resetCounts(DefaultClusterCallback callback, int timedInvokeTimeoutM final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface PHYRateAttributeCallback extends BaseAttributeCallback { @@ -13847,12 +13888,12 @@ public void setUTCTime(DefaultClusterCallback callback, Long UTCTime, Integer gr BaseTLVType timeSourcetlvValue = timeSource.map((nonOptionaltimeSource) -> new UIntType(nonOptionaltimeSource)).orElse(new EmptyType()); elements.add(new StructElement(timeSourceFieldID, timeSourcetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setTrustedTimeSource(DefaultClusterCallback callback, @Nullable ChipStructs.TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct trustedTimeSource) { @@ -13867,12 +13908,12 @@ public void setTrustedTimeSource(DefaultClusterCallback callback, @Nullable Chip BaseTLVType trustedTimeSourcetlvValue = trustedTimeSource != null ? trustedTimeSource.encodeTlv() : new NullType(); elements.add(new StructElement(trustedTimeSourceFieldID, trustedTimeSourcetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setTimeZone(SetTimeZoneResponseCallback callback, ArrayList timeZone) { @@ -13887,7 +13928,7 @@ public void setTimeZone(SetTimeZoneResponseCallback callback, ArrayList elementtimeZone.encodeTlv()); elements.add(new StructElement(timeZoneFieldID, timeZonetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -13902,7 +13943,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(DSTOffsetRequired); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setDSTOffset(DefaultClusterCallback callback, ArrayList DSTOffset) { @@ -13917,12 +13958,12 @@ public void setDSTOffset(DefaultClusterCallback callback, ArrayList elementDSTOffset.encodeTlv()); elements.add(new StructElement(DSTOffsetFieldID, DSTOffsettlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setDefaultNTP(DefaultClusterCallback callback, @Nullable String defaultNTP) { @@ -13937,12 +13978,12 @@ public void setDefaultNTP(DefaultClusterCallback callback, @Nullable String defa BaseTLVType defaultNTPtlvValue = defaultNTP != null ? new StringType(defaultNTP) : new NullType(); elements.add(new StructElement(defaultNTPFieldID, defaultNTPtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface SetTimeZoneResponseCallback extends BaseClusterCallback { @@ -15394,12 +15435,12 @@ public void openCommissioningWindow(DefaultClusterCallback callback, Integer com BaseTLVType salttlvValue = new ByteArrayType(salt); elements.add(new StructElement(saltFieldID, salttlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -15411,12 +15452,12 @@ public void openBasicCommissioningWindow(DefaultClusterCallback callback, Intege BaseTLVType commissioningTimeouttlvValue = new UIntType(commissioningTimeout); elements.add(new StructElement(commissioningTimeoutFieldID, commissioningTimeouttlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -15424,12 +15465,12 @@ public void revokeCommissioning(DefaultClusterCallback callback, int timedInvoke final long commandId = 2L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface AdminFabricIndexAttributeCallback extends BaseAttributeCallback { @@ -15720,7 +15761,7 @@ public void attestationRequest(AttestationResponseCallback callback, byte[] atte BaseTLVType attestationNoncetlvValue = new ByteArrayType(attestationNonce); elements.add(new StructElement(attestationNonceFieldID, attestationNoncetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -15742,7 +15783,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(attestationElements, attestationSignature); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void certificateChainRequest(CertificateChainResponseCallback callback, Integer certificateType) { @@ -15757,7 +15798,7 @@ public void certificateChainRequest(CertificateChainResponseCallback callback, I BaseTLVType certificateTypetlvValue = new UIntType(certificateType); elements.add(new StructElement(certificateTypeFieldID, certificateTypetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -15772,7 +15813,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(certificate); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void CSRRequest(CSRResponseCallback callback, byte[] CSRNonce, Optional isForUpdateNOC) { @@ -15791,7 +15832,7 @@ public void CSRRequest(CSRResponseCallback callback, byte[] CSRNonce, Optionalmap((nonOptionalisForUpdateNOC) -> new BooleanType(nonOptionalisForUpdateNOC)).orElse(new EmptyType()); elements.add(new StructElement(isForUpdateNOCFieldID, isForUpdateNOCtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -15813,7 +15854,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(NOCSRElements, attestationSignature); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void addNOC(NOCResponseCallback callback, byte[] NOCValue, Optional ICACValue, byte[] IPKValue, Long caseAdminSubject, Integer adminVendorId) { @@ -15844,7 +15885,7 @@ public void addNOC(NOCResponseCallback callback, byte[] NOCValue, Optional ICACValue) { @@ -15892,7 +15933,7 @@ public void updateNOC(NOCResponseCallback callback, byte[] NOCValue, Optionalmap((nonOptionalICACValue) -> new ByteArrayType(nonOptionalICACValue)).orElse(new EmptyType()); elements.add(new StructElement(ICACValueFieldID, ICACValuetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -15921,7 +15962,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(statusCode, fabricIndex, debugText); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void updateFabricLabel(NOCResponseCallback callback, String label) { @@ -15936,7 +15977,7 @@ public void updateFabricLabel(NOCResponseCallback callback, String label, int ti BaseTLVType labeltlvValue = new StringType(label); elements.add(new StructElement(labelFieldID, labeltlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -15965,7 +16006,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(statusCode, fabricIndex, debugText); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void removeFabric(NOCResponseCallback callback, Integer fabricIndex) { @@ -15980,7 +16021,7 @@ public void removeFabric(NOCResponseCallback callback, Integer fabricIndex, int BaseTLVType fabricIndextlvValue = new UIntType(fabricIndex); elements.add(new StructElement(fabricIndexFieldID, fabricIndextlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -16009,7 +16050,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(statusCode, fabricIndex, debugText); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void addTrustedRootCertificate(DefaultClusterCallback callback, byte[] rootCACertificate) { @@ -16024,12 +16065,12 @@ public void addTrustedRootCertificate(DefaultClusterCallback callback, byte[] ro BaseTLVType rootCACertificatetlvValue = new ByteArrayType(rootCACertificate); elements.add(new StructElement(rootCACertificateFieldID, rootCACertificatetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface AttestationResponseCallback extends BaseClusterCallback { @@ -16423,12 +16464,12 @@ public void keySetWrite(DefaultClusterCallback callback, ChipStructs.GroupKeyMan BaseTLVType groupKeySettlvValue = groupKeySet.encodeTlv(); elements.add(new StructElement(groupKeySetFieldID, groupKeySettlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void keySetRead(KeySetReadResponseCallback callback, Integer groupKeySetID) { @@ -16443,7 +16484,7 @@ public void keySetRead(KeySetReadResponseCallback callback, Integer groupKeySetI BaseTLVType groupKeySetIDtlvValue = new UIntType(groupKeySetID); elements.add(new StructElement(groupKeySetIDFieldID, groupKeySetIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -16458,7 +16499,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(groupKeySet); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void keySetRemove(DefaultClusterCallback callback, Integer groupKeySetID) { @@ -16473,12 +16514,12 @@ public void keySetRemove(DefaultClusterCallback callback, Integer groupKeySetID, BaseTLVType groupKeySetIDtlvValue = new UIntType(groupKeySetID); elements.add(new StructElement(groupKeySetIDFieldID, groupKeySetIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void keySetReadAllIndices(KeySetReadAllIndicesResponseCallback callback) { @@ -16489,7 +16530,7 @@ public void keySetReadAllIndices(KeySetReadAllIndicesResponseCallback callback, final long commandId = 4L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -16504,7 +16545,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(groupKeySetIDs); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface KeySetReadResponseCallback extends BaseClusterCallback { @@ -18079,7 +18120,7 @@ public void registerClient(RegisterClientResponseCallback callback, Long checkIn BaseTLVType verificationKeytlvValue = verificationKey.map((nonOptionalverificationKey) -> new ByteArrayType(nonOptionalverificationKey)).orElse(new EmptyType()); elements.add(new StructElement(verificationKeyFieldID, verificationKeytlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -18094,7 +18135,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(ICDCounter); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void unregisterClient(DefaultClusterCallback callback, Long checkInNodeID, Optional verificationKey) { @@ -18113,12 +18154,12 @@ public void unregisterClient(DefaultClusterCallback callback, Long checkInNodeID BaseTLVType verificationKeytlvValue = verificationKey.map((nonOptionalverificationKey) -> new ByteArrayType(nonOptionalverificationKey)).orElse(new EmptyType()); elements.add(new StructElement(verificationKeyFieldID, verificationKeytlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stayActiveRequest(StayActiveResponseCallback callback) { @@ -18129,7 +18170,7 @@ public void stayActiveRequest(StayActiveResponseCallback callback, int timedInvo final long commandId = 3L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -18144,7 +18185,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(promisedActiveDuration); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface RegisterClientResponseCallback extends BaseClusterCallback { @@ -18591,12 +18632,12 @@ public void setTimer(DefaultClusterCallback callback, Long newTime, int timedInv BaseTLVType newTimetlvValue = new UIntType(newTime); elements.add(new StructElement(newTimeFieldID, newTimetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void resetTimer(DefaultClusterCallback callback) { @@ -18607,12 +18648,12 @@ public void resetTimer(DefaultClusterCallback callback, int timedInvokeTimeoutMs final long commandId = 1L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void addTime(DefaultClusterCallback callback, Long additionalTime) { @@ -18627,12 +18668,12 @@ public void addTime(DefaultClusterCallback callback, Long additionalTime, int ti BaseTLVType additionalTimetlvValue = new UIntType(additionalTime); elements.add(new StructElement(additionalTimeFieldID, additionalTimetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void reduceTime(DefaultClusterCallback callback, Long timeReduction) { @@ -18647,12 +18688,12 @@ public void reduceTime(DefaultClusterCallback callback, Long timeReduction, int BaseTLVType timeReductiontlvValue = new UIntType(timeReduction); elements.add(new StructElement(timeReductionFieldID, timeReductiontlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { @@ -18931,7 +18972,7 @@ public void pause(OperationalCommandResponseCallback callback, int timedInvokeTi final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -18946,7 +18987,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(commandResponseState); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stop(OperationalCommandResponseCallback callback) { @@ -18957,7 +18998,7 @@ public void stop(OperationalCommandResponseCallback callback, int timedInvokeTim final long commandId = 1L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -18972,7 +19013,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(commandResponseState); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void start(OperationalCommandResponseCallback callback) { @@ -18983,7 +19024,7 @@ public void start(OperationalCommandResponseCallback callback, int timedInvokeTi final long commandId = 2L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -18998,7 +19039,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(commandResponseState); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void resume(OperationalCommandResponseCallback callback) { @@ -19009,7 +19050,7 @@ public void resume(OperationalCommandResponseCallback callback, int timedInvokeT final long commandId = 3L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -19024,7 +19065,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(commandResponseState); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface OperationalCommandResponseCallback extends BaseClusterCallback { @@ -19404,7 +19445,7 @@ public void changeToMode(ChangeToModeResponseCallback callback, Integer newMode, BaseTLVType newModetlvValue = new UIntType(newMode); elements.add(new StructElement(newModeFieldID, newModetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -19426,7 +19467,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, statusText); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ChangeToModeResponseCallback extends BaseClusterCallback { @@ -20024,12 +20065,12 @@ public void changeToMode(DefaultClusterCallback callback, Integer newMode, int t BaseTLVType newModetlvValue = new UIntType(newMode); elements.add(new StructElement(newModeFieldID, newModetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface StandardNamespaceAttributeCallback extends BaseAttributeCallback { @@ -20419,7 +20460,7 @@ public void changeToMode(ChangeToModeResponseCallback callback, Integer newMode, BaseTLVType newModetlvValue = new UIntType(newMode); elements.add(new StructElement(newModeFieldID, newModetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -20441,7 +20482,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, statusText); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ChangeToModeResponseCallback extends BaseClusterCallback { @@ -20781,7 +20822,7 @@ public void changeToMode(ChangeToModeResponseCallback callback, Integer newMode, BaseTLVType newModetlvValue = new UIntType(newMode); elements.add(new StructElement(newModeFieldID, newModetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -20803,7 +20844,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, statusText); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ChangeToModeResponseCallback extends BaseClusterCallback { @@ -21462,7 +21503,7 @@ public void changeToMode(ChangeToModeResponseCallback callback, Integer newMode, BaseTLVType newModetlvValue = new UIntType(newMode); elements.add(new StructElement(newModeFieldID, newModetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -21484,7 +21525,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, statusText); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ChangeToModeResponseCallback extends BaseClusterCallback { @@ -21746,7 +21787,7 @@ public void changeToMode(ChangeToModeResponseCallback callback, Integer newMode, BaseTLVType newModetlvValue = new UIntType(newMode); elements.add(new StructElement(newModeFieldID, newModetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -21768,7 +21809,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, statusText); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ChangeToModeResponseCallback extends BaseClusterCallback { @@ -22038,12 +22079,12 @@ public void setTemperature(DefaultClusterCallback callback, Optional ta BaseTLVType targetTemperatureLeveltlvValue = targetTemperatureLevel.map((nonOptionaltargetTemperatureLevel) -> new UIntType(nonOptionaltargetTemperatureLevel)).orElse(new EmptyType()); elements.add(new StructElement(targetTemperatureLevelFieldID, targetTemperatureLeveltlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface SupportedTemperatureLevelsAttributeCallback extends BaseAttributeCallback { @@ -22668,7 +22709,7 @@ public void changeToMode(ChangeToModeResponseCallback callback, Integer newMode, BaseTLVType newModetlvValue = new UIntType(newMode); elements.add(new StructElement(newModeFieldID, newModetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -22690,7 +22731,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, statusText); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ChangeToModeResponseCallback extends BaseClusterCallback { @@ -23248,12 +23289,12 @@ public void selfTestRequest(DefaultClusterCallback callback, int timedInvokeTime final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { @@ -23793,12 +23834,12 @@ public void reset(DefaultClusterCallback callback, Long alarms, int timedInvokeT BaseTLVType alarmstlvValue = new UIntType(alarms); elements.add(new StructElement(alarmsFieldID, alarmstlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void modifyEnabledAlarms(DefaultClusterCallback callback, Long mask) { @@ -23813,12 +23854,12 @@ public void modifyEnabledAlarms(DefaultClusterCallback callback, Long mask, int BaseTLVType masktlvValue = new UIntType(mask); elements.add(new StructElement(maskFieldID, masktlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { @@ -24388,12 +24429,12 @@ public void setCookingParameters(DefaultClusterCallback callback, Optionalmap((nonOptionalstartAfterSetting) -> new BooleanType(nonOptionalstartAfterSetting)).orElse(new EmptyType()); elements.add(new StructElement(startAfterSettingFieldID, startAfterSettingtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void addMoreTime(DefaultClusterCallback callback, Long timeToAdd) { @@ -24408,12 +24449,12 @@ public void addMoreTime(DefaultClusterCallback callback, Long timeToAdd, int tim BaseTLVType timeToAddtlvValue = new UIntType(timeToAdd); elements.add(new StructElement(timeToAddFieldID, timeToAddtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface SupportedWattsAttributeCallback extends BaseAttributeCallback { @@ -24846,7 +24887,7 @@ public void pause(OperationalCommandResponseCallback callback, int timedInvokeTi final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -24861,7 +24902,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(commandResponseState); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stop(OperationalCommandResponseCallback callback) { @@ -24872,7 +24913,7 @@ public void stop(OperationalCommandResponseCallback callback, int timedInvokeTim final long commandId = 1L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -24887,7 +24928,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(commandResponseState); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void start(OperationalCommandResponseCallback callback) { @@ -24898,7 +24939,7 @@ public void start(OperationalCommandResponseCallback callback, int timedInvokeTi final long commandId = 2L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -24913,7 +24954,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(commandResponseState); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void resume(OperationalCommandResponseCallback callback) { @@ -24924,7 +24965,7 @@ public void resume(OperationalCommandResponseCallback callback, int timedInvokeT final long commandId = 3L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -24939,7 +24980,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(commandResponseState); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface OperationalCommandResponseCallback extends BaseClusterCallback { @@ -25317,7 +25358,7 @@ public void pause(OperationalCommandResponseCallback callback, int timedInvokeTi final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -25332,7 +25373,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(commandResponseState); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void resume(OperationalCommandResponseCallback callback) { @@ -25343,7 +25384,7 @@ public void resume(OperationalCommandResponseCallback callback, int timedInvokeT final long commandId = 3L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -25358,7 +25399,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(commandResponseState); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void goHome(OperationalCommandResponseCallback callback) { @@ -25369,7 +25410,7 @@ public void goHome(OperationalCommandResponseCallback callback, int timedInvokeT final long commandId = 128L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -25384,7 +25425,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(commandResponseState); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface OperationalCommandResponseCallback extends BaseClusterCallback { @@ -25779,7 +25820,7 @@ public void addScene(AddSceneResponseCallback callback, Integer groupID, Integer BaseTLVType extensionFieldSetstlvValue = ArrayType.generateArrayType(extensionFieldSets, (elementextensionFieldSets) -> elementextensionFieldSets.encodeTlv()); elements.add(new StructElement(extensionFieldSetsFieldID, extensionFieldSetstlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -25808,7 +25849,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, groupID, sceneID); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void viewScene(ViewSceneResponseCallback callback, Integer groupID, Integer sceneID) { @@ -25827,7 +25868,7 @@ public void viewScene(ViewSceneResponseCallback callback, Integer groupID, Integ BaseTLVType sceneIDtlvValue = new UIntType(sceneID); elements.add(new StructElement(sceneIDFieldID, sceneIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -25877,7 +25918,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, groupID, sceneID, transitionTime, sceneName, extensionFieldSets); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void removeScene(RemoveSceneResponseCallback callback, Integer groupID, Integer sceneID) { @@ -25896,7 +25937,7 @@ public void removeScene(RemoveSceneResponseCallback callback, Integer groupID, I BaseTLVType sceneIDtlvValue = new UIntType(sceneID); elements.add(new StructElement(sceneIDFieldID, sceneIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -25925,7 +25966,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, groupID, sceneID); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void removeAllScenes(RemoveAllScenesResponseCallback callback, Integer groupID) { @@ -25940,7 +25981,7 @@ public void removeAllScenes(RemoveAllScenesResponseCallback callback, Integer gr BaseTLVType groupIDtlvValue = new UIntType(groupID); elements.add(new StructElement(groupIDFieldID, groupIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -25962,7 +26003,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, groupID); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void storeScene(StoreSceneResponseCallback callback, Integer groupID, Integer sceneID) { @@ -25981,7 +26022,7 @@ public void storeScene(StoreSceneResponseCallback callback, Integer groupID, Int BaseTLVType sceneIDtlvValue = new UIntType(sceneID); elements.add(new StructElement(sceneIDFieldID, sceneIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -26010,7 +26051,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, groupID, sceneID); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void recallScene(DefaultClusterCallback callback, Integer groupID, Integer sceneID, @Nullable Optional transitionTime) { @@ -26033,12 +26074,12 @@ public void recallScene(DefaultClusterCallback callback, Integer groupID, Intege BaseTLVType transitionTimetlvValue = transitionTime != null ? transitionTime.map((nonOptionaltransitionTime) -> new UIntType(nonOptionaltransitionTime)).orElse(new EmptyType()) : new NullType(); elements.add(new StructElement(transitionTimeFieldID, transitionTimetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void getSceneMembership(GetSceneMembershipResponseCallback callback, Integer groupID) { @@ -26053,7 +26094,7 @@ public void getSceneMembership(GetSceneMembershipResponseCallback callback, Inte BaseTLVType groupIDtlvValue = new UIntType(groupID); elements.add(new StructElement(groupIDFieldID, groupIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -26089,7 +26130,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, capacity, groupID, sceneList); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void copyScene(CopySceneResponseCallback callback, Integer mode, Integer groupIdentifierFrom, Integer sceneIdentifierFrom, Integer groupIdentifierTo, Integer sceneIdentifierTo) { @@ -26120,7 +26161,7 @@ public void copyScene(CopySceneResponseCallback callback, Integer mode, Integer BaseTLVType sceneIdentifierTotlvValue = new UIntType(sceneIdentifierTo); elements.add(new StructElement(sceneIdentifierToFieldID, sceneIdentifierTotlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -26149,7 +26190,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, groupIdentifierFrom, sceneIdentifierFrom); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface AddSceneResponseCallback extends BaseClusterCallback { @@ -26469,12 +26510,12 @@ public void resetCondition(DefaultClusterCallback callback, int timedInvokeTimeo final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface LastChangedTimeAttributeCallback extends BaseAttributeCallback { @@ -26845,12 +26886,12 @@ public void resetCondition(DefaultClusterCallback callback, int timedInvokeTimeo final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface LastChangedTimeAttributeCallback extends BaseAttributeCallback { @@ -27227,12 +27268,12 @@ public void suppressAlarm(DefaultClusterCallback callback, Integer alarmsToSuppr BaseTLVType alarmsToSuppresstlvValue = new UIntType(alarmsToSuppress); elements.add(new StructElement(alarmsToSuppressFieldID, alarmsToSuppresstlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void enableDisableAlarm(DefaultClusterCallback callback, Integer alarmsToEnableDisable) { @@ -27247,12 +27288,12 @@ public void enableDisableAlarm(DefaultClusterCallback callback, Integer alarmsTo BaseTLVType alarmsToEnableDisabletlvValue = new UIntType(alarmsToEnableDisable); elements.add(new StructElement(alarmsToEnableDisableFieldID, alarmsToEnableDisabletlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { @@ -27678,12 +27719,12 @@ public void open(DefaultClusterCallback callback, @Nullable Optional openD BaseTLVType targetLeveltlvValue = targetLevel.map((nonOptionaltargetLevel) -> new UIntType(nonOptionaltargetLevel)).orElse(new EmptyType()); elements.add(new StructElement(targetLevelFieldID, targetLeveltlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void close(DefaultClusterCallback callback) { @@ -27694,12 +27735,12 @@ public void close(DefaultClusterCallback callback, int timedInvokeTimeoutMs) { final long commandId = 1L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface OpenDurationAttributeCallback extends BaseAttributeCallback { @@ -28194,14 +28235,28 @@ public void onSuccess(byte[] tlv) { } } - public static class ElectricalEnergyMeasurementCluster extends BaseChipCluster { - public static final long CLUSTER_ID = 145L; - - private static final long ACCURACY_ATTRIBUTE_ID = 0L; - private static final long CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID = 1L; - private static final long CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID = 2L; - private static final long PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID = 3L; - private static final long PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID = 4L; + public static class ElectricalPowerMeasurementCluster extends BaseChipCluster { + public static final long CLUSTER_ID = 144L; + + private static final long POWER_MODE_ATTRIBUTE_ID = 0L; + private static final long NUMBER_OF_MEASUREMENT_TYPES_ATTRIBUTE_ID = 1L; + private static final long ACCURACY_ATTRIBUTE_ID = 2L; + private static final long RANGES_ATTRIBUTE_ID = 3L; + private static final long VOLTAGE_ATTRIBUTE_ID = 4L; + private static final long ACTIVE_CURRENT_ATTRIBUTE_ID = 5L; + private static final long REACTIVE_CURRENT_ATTRIBUTE_ID = 6L; + private static final long APPARENT_CURRENT_ATTRIBUTE_ID = 7L; + private static final long ACTIVE_POWER_ATTRIBUTE_ID = 8L; + private static final long REACTIVE_POWER_ATTRIBUTE_ID = 9L; + private static final long APPARENT_POWER_ATTRIBUTE_ID = 10L; + private static final long R_M_S_VOLTAGE_ATTRIBUTE_ID = 11L; + private static final long R_M_S_CURRENT_ATTRIBUTE_ID = 12L; + private static final long R_M_S_POWER_ATTRIBUTE_ID = 13L; + private static final long FREQUENCY_ATTRIBUTE_ID = 14L; + private static final long HARMONIC_CURRENTS_ATTRIBUTE_ID = 15L; + private static final long HARMONIC_PHASES_ATTRIBUTE_ID = 16L; + private static final long POWER_FACTOR_ATTRIBUTE_ID = 17L; + private static final long NEUTRAL_CURRENT_ATTRIBUTE_ID = 18L; private static final long GENERATED_COMMAND_LIST_ATTRIBUTE_ID = 65528L; private static final long ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID = 65529L; private static final long EVENT_LIST_ATTRIBUTE_ID = 65530L; @@ -28209,7 +28264,7 @@ public static class ElectricalEnergyMeasurementCluster extends BaseChipCluster { private static final long FEATURE_MAP_ATTRIBUTE_ID = 65532L; private static final long CLUSTER_REVISION_ATTRIBUTE_ID = 65533L; - public ElectricalEnergyMeasurementCluster(long devicePtr, int endpointId) { + public ElectricalPowerMeasurementCluster(long devicePtr, int endpointId) { super(devicePtr, endpointId, CLUSTER_ID); } @@ -28220,23 +28275,71 @@ public long initWithDevice(long devicePtr, int endpointId) { } public interface AccuracyAttributeCallback extends BaseAttributeCallback { - void onSuccess(ChipStructs.ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct value); + void onSuccess(List value); } - public interface CumulativeEnergyImportedAttributeCallback extends BaseAttributeCallback { - void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value); + public interface RangesAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); } - public interface CumulativeEnergyExportedAttributeCallback extends BaseAttributeCallback { - void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value); + public interface VoltageAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); } - public interface PeriodicEnergyImportedAttributeCallback extends BaseAttributeCallback { - void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value); + public interface ActiveCurrentAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); } - public interface PeriodicEnergyExportedAttributeCallback extends BaseAttributeCallback { - void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value); + public interface ReactiveCurrentAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); + } + + public interface ApparentCurrentAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); + } + + public interface ActivePowerAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); + } + + public interface ReactivePowerAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); + } + + public interface ApparentPowerAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); + } + + public interface RMSVoltageAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); + } + + public interface RMSCurrentAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); + } + + public interface RMSPowerAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); + } + + public interface FrequencyAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); + } + + public interface HarmonicCurrentsAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable List value); + } + + public interface HarmonicPhasesAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable List value); + } + + public interface PowerFactorAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); + } + + public interface NeutralCurrentAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); } public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { @@ -28255,6 +28358,56 @@ public interface AttributeListAttributeCallback extends BaseAttributeCallback { void onSuccess(List value); } + public void readPowerModeAttribute( + IntegerAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, POWER_MODE_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, POWER_MODE_ATTRIBUTE_ID, true); + } + + public void subscribePowerModeAttribute( + IntegerAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, POWER_MODE_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, POWER_MODE_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readNumberOfMeasurementTypesAttribute( + IntegerAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NUMBER_OF_MEASUREMENT_TYPES_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, NUMBER_OF_MEASUREMENT_TYPES_ATTRIBUTE_ID, true); + } + + public void subscribeNumberOfMeasurementTypesAttribute( + IntegerAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NUMBER_OF_MEASUREMENT_TYPES_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, NUMBER_OF_MEASUREMENT_TYPES_ATTRIBUTE_ID, minInterval, maxInterval); + } + public void readAccuracyAttribute( AccuracyAttributeCallback callback) { ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCURACY_ATTRIBUTE_ID); @@ -28262,7 +28415,7 @@ public void readAccuracyAttribute( readAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - ChipStructs.ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); callback.onSuccess(value); } }, ACCURACY_ATTRIBUTE_ID, true); @@ -28275,109 +28428,776 @@ public void subscribeAccuracyAttribute( subscribeAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - ChipStructs.ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); } }, ACCURACY_ATTRIBUTE_ID, minInterval, maxInterval); } - public void readCumulativeEnergyImportedAttribute( - CumulativeEnergyImportedAttributeCallback callback) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID); + public void readRangesAttribute( + RangesAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, RANGES_ATTRIBUTE_ID); readAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); callback.onSuccess(value); } - }, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID, true); + }, RANGES_ATTRIBUTE_ID, true); } - public void subscribeCumulativeEnergyImportedAttribute( - CumulativeEnergyImportedAttributeCallback callback, int minInterval, int maxInterval) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID); + public void subscribeRangesAttribute( + RangesAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, RANGES_ATTRIBUTE_ID); subscribeAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); } - }, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + }, RANGES_ATTRIBUTE_ID, minInterval, maxInterval); } - public void readCumulativeEnergyExportedAttribute( - CumulativeEnergyExportedAttributeCallback callback) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID); + public void readVoltageAttribute( + VoltageAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, VOLTAGE_ATTRIBUTE_ID); readAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); callback.onSuccess(value); } - }, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID, true); + }, VOLTAGE_ATTRIBUTE_ID, true); } - public void subscribeCumulativeEnergyExportedAttribute( - CumulativeEnergyExportedAttributeCallback callback, int minInterval, int maxInterval) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID); + public void subscribeVoltageAttribute( + VoltageAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, VOLTAGE_ATTRIBUTE_ID); subscribeAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); } - }, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + }, VOLTAGE_ATTRIBUTE_ID, minInterval, maxInterval); } - public void readPeriodicEnergyImportedAttribute( - PeriodicEnergyImportedAttributeCallback callback) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID); + public void readActiveCurrentAttribute( + ActiveCurrentAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACTIVE_CURRENT_ATTRIBUTE_ID); readAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); callback.onSuccess(value); } - }, PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID, true); + }, ACTIVE_CURRENT_ATTRIBUTE_ID, true); } - public void subscribePeriodicEnergyImportedAttribute( - PeriodicEnergyImportedAttributeCallback callback, int minInterval, int maxInterval) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID); + public void subscribeActiveCurrentAttribute( + ActiveCurrentAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACTIVE_CURRENT_ATTRIBUTE_ID); subscribeAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); } - }, PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + }, ACTIVE_CURRENT_ATTRIBUTE_ID, minInterval, maxInterval); } - public void readPeriodicEnergyExportedAttribute( - PeriodicEnergyExportedAttributeCallback callback) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID); + public void readReactiveCurrentAttribute( + ReactiveCurrentAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, REACTIVE_CURRENT_ATTRIBUTE_ID); readAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); callback.onSuccess(value); } - }, PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID, true); + }, REACTIVE_CURRENT_ATTRIBUTE_ID, true); } - public void subscribePeriodicEnergyExportedAttribute( - PeriodicEnergyExportedAttributeCallback callback, int minInterval, int maxInterval) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID); + public void subscribeReactiveCurrentAttribute( + ReactiveCurrentAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, REACTIVE_CURRENT_ATTRIBUTE_ID); subscribeAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); } - }, PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + }, REACTIVE_CURRENT_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readApparentCurrentAttribute( + ApparentCurrentAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, APPARENT_CURRENT_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, APPARENT_CURRENT_ATTRIBUTE_ID, true); + } + + public void subscribeApparentCurrentAttribute( + ApparentCurrentAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, APPARENT_CURRENT_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, APPARENT_CURRENT_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readActivePowerAttribute( + ActivePowerAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACTIVE_POWER_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, ACTIVE_POWER_ATTRIBUTE_ID, true); + } + + public void subscribeActivePowerAttribute( + ActivePowerAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACTIVE_POWER_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, ACTIVE_POWER_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readReactivePowerAttribute( + ReactivePowerAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, REACTIVE_POWER_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, REACTIVE_POWER_ATTRIBUTE_ID, true); + } + + public void subscribeReactivePowerAttribute( + ReactivePowerAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, REACTIVE_POWER_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, REACTIVE_POWER_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readApparentPowerAttribute( + ApparentPowerAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, APPARENT_POWER_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, APPARENT_POWER_ATTRIBUTE_ID, true); + } + + public void subscribeApparentPowerAttribute( + ApparentPowerAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, APPARENT_POWER_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, APPARENT_POWER_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readRMSVoltageAttribute( + RMSVoltageAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, R_M_S_VOLTAGE_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, R_M_S_VOLTAGE_ATTRIBUTE_ID, true); + } + + public void subscribeRMSVoltageAttribute( + RMSVoltageAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, R_M_S_VOLTAGE_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, R_M_S_VOLTAGE_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readRMSCurrentAttribute( + RMSCurrentAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, R_M_S_CURRENT_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, R_M_S_CURRENT_ATTRIBUTE_ID, true); + } + + public void subscribeRMSCurrentAttribute( + RMSCurrentAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, R_M_S_CURRENT_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, R_M_S_CURRENT_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readRMSPowerAttribute( + RMSPowerAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, R_M_S_POWER_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, R_M_S_POWER_ATTRIBUTE_ID, true); + } + + public void subscribeRMSPowerAttribute( + RMSPowerAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, R_M_S_POWER_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, R_M_S_POWER_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readFrequencyAttribute( + FrequencyAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, FREQUENCY_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, FREQUENCY_ATTRIBUTE_ID, true); + } + + public void subscribeFrequencyAttribute( + FrequencyAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, FREQUENCY_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, FREQUENCY_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readHarmonicCurrentsAttribute( + HarmonicCurrentsAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, HARMONIC_CURRENTS_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, HARMONIC_CURRENTS_ATTRIBUTE_ID, true); + } + + public void subscribeHarmonicCurrentsAttribute( + HarmonicCurrentsAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, HARMONIC_CURRENTS_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, HARMONIC_CURRENTS_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readHarmonicPhasesAttribute( + HarmonicPhasesAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, HARMONIC_PHASES_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, HARMONIC_PHASES_ATTRIBUTE_ID, true); + } + + public void subscribeHarmonicPhasesAttribute( + HarmonicPhasesAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, HARMONIC_PHASES_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, HARMONIC_PHASES_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readPowerFactorAttribute( + PowerFactorAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, POWER_FACTOR_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, POWER_FACTOR_ATTRIBUTE_ID, true); + } + + public void subscribePowerFactorAttribute( + PowerFactorAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, POWER_FACTOR_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, POWER_FACTOR_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readNeutralCurrentAttribute( + NeutralCurrentAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NEUTRAL_CURRENT_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, NEUTRAL_CURRENT_ATTRIBUTE_ID, true); + } + + public void subscribeNeutralCurrentAttribute( + NeutralCurrentAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NEUTRAL_CURRENT_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, NEUTRAL_CURRENT_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readGeneratedCommandListAttribute( + GeneratedCommandListAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, GENERATED_COMMAND_LIST_ATTRIBUTE_ID, true); + } + + public void subscribeGeneratedCommandListAttribute( + GeneratedCommandListAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, GENERATED_COMMAND_LIST_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readAcceptedCommandListAttribute( + AcceptedCommandListAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID, true); + } + + public void subscribeAcceptedCommandListAttribute( + AcceptedCommandListAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readEventListAttribute( + EventListAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, EVENT_LIST_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, EVENT_LIST_ATTRIBUTE_ID, true); + } + + public void subscribeEventListAttribute( + EventListAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, EVENT_LIST_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, EVENT_LIST_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readAttributeListAttribute( + AttributeListAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ATTRIBUTE_LIST_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, ATTRIBUTE_LIST_ATTRIBUTE_ID, true); + } + + public void subscribeAttributeListAttribute( + AttributeListAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ATTRIBUTE_LIST_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, ATTRIBUTE_LIST_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readFeatureMapAttribute( + LongAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, FEATURE_MAP_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, FEATURE_MAP_ATTRIBUTE_ID, true); + } + + public void subscribeFeatureMapAttribute( + LongAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, FEATURE_MAP_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, FEATURE_MAP_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readClusterRevisionAttribute( + IntegerAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CLUSTER_REVISION_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, CLUSTER_REVISION_ATTRIBUTE_ID, true); + } + + public void subscribeClusterRevisionAttribute( + IntegerAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CLUSTER_REVISION_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, CLUSTER_REVISION_ATTRIBUTE_ID, minInterval, maxInterval); + } + } + + public static class ElectricalEnergyMeasurementCluster extends BaseChipCluster { + public static final long CLUSTER_ID = 145L; + + private static final long ACCURACY_ATTRIBUTE_ID = 0L; + private static final long CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID = 1L; + private static final long CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID = 2L; + private static final long PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID = 3L; + private static final long PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID = 4L; + private static final long CUMULATIVE_ENERGY_RESET_ATTRIBUTE_ID = 5L; + private static final long GENERATED_COMMAND_LIST_ATTRIBUTE_ID = 65528L; + private static final long ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID = 65529L; + private static final long EVENT_LIST_ATTRIBUTE_ID = 65530L; + private static final long ATTRIBUTE_LIST_ATTRIBUTE_ID = 65531L; + private static final long FEATURE_MAP_ATTRIBUTE_ID = 65532L; + private static final long CLUSTER_REVISION_ATTRIBUTE_ID = 65533L; + + public ElectricalEnergyMeasurementCluster(long devicePtr, int endpointId) { + super(devicePtr, endpointId, CLUSTER_ID); + } + + @Override + @Deprecated + public long initWithDevice(long devicePtr, int endpointId) { + return 0L; + } + + public interface AccuracyAttributeCallback extends BaseAttributeCallback { + void onSuccess(ChipStructs.ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct value); + } + + public interface CumulativeEnergyImportedAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value); + } + + public interface CumulativeEnergyExportedAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value); + } + + public interface PeriodicEnergyImportedAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value); + } + + public interface PeriodicEnergyExportedAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value); + } + + public interface CumulativeEnergyResetAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct value); + } + + public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); + } + + public interface AcceptedCommandListAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); + } + + public interface EventListAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); + } + + public interface AttributeListAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); + } + + public void readAccuracyAttribute( + AccuracyAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCURACY_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + ChipStructs.ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, ACCURACY_ATTRIBUTE_ID, true); + } + + public void subscribeAccuracyAttribute( + AccuracyAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCURACY_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + ChipStructs.ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, ACCURACY_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readCumulativeEnergyImportedAttribute( + CumulativeEnergyImportedAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID, true); + } + + public void subscribeCumulativeEnergyImportedAttribute( + CumulativeEnergyImportedAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readCumulativeEnergyExportedAttribute( + CumulativeEnergyExportedAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID, true); + } + + public void subscribeCumulativeEnergyExportedAttribute( + CumulativeEnergyExportedAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readPeriodicEnergyImportedAttribute( + PeriodicEnergyImportedAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID, true); + } + + public void subscribePeriodicEnergyImportedAttribute( + PeriodicEnergyImportedAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readPeriodicEnergyExportedAttribute( + PeriodicEnergyExportedAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID, true); + } + + public void subscribePeriodicEnergyExportedAttribute( + PeriodicEnergyExportedAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readCumulativeEnergyResetAttribute( + CumulativeEnergyResetAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_RESET_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, CUMULATIVE_ENERGY_RESET_ATTRIBUTE_ID, true); + } + + public void subscribeCumulativeEnergyResetAttribute( + CumulativeEnergyResetAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_RESET_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, CUMULATIVE_ENERGY_RESET_ATTRIBUTE_ID, minInterval, maxInterval); } public void readGeneratedCommandListAttribute( @@ -28571,12 +29391,12 @@ public void registerLoadControlProgramRequest(DefaultClusterCallback callback, C BaseTLVType loadControlProgramtlvValue = loadControlProgram.encodeTlv(); elements.add(new StructElement(loadControlProgramFieldID, loadControlProgramtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void unregisterLoadControlProgramRequest(DefaultClusterCallback callback, byte[] loadControlProgramID) { @@ -28591,12 +29411,12 @@ public void unregisterLoadControlProgramRequest(DefaultClusterCallback callback, BaseTLVType loadControlProgramIDtlvValue = new ByteArrayType(loadControlProgramID); elements.add(new StructElement(loadControlProgramIDFieldID, loadControlProgramIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void addLoadControlEventRequest(DefaultClusterCallback callback, ChipStructs.DemandResponseLoadControlClusterLoadControlEventStruct event) { @@ -28611,12 +29431,12 @@ public void addLoadControlEventRequest(DefaultClusterCallback callback, ChipStru BaseTLVType eventtlvValue = event.encodeTlv(); elements.add(new StructElement(eventFieldID, eventtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void removeLoadControlEventRequest(DefaultClusterCallback callback, byte[] eventID, Integer cancelControl) { @@ -28635,12 +29455,12 @@ public void removeLoadControlEventRequest(DefaultClusterCallback callback, byte[ BaseTLVType cancelControltlvValue = new UIntType(cancelControl); elements.add(new StructElement(cancelControlFieldID, cancelControltlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void clearLoadControlEventsRequest(DefaultClusterCallback callback) { @@ -28651,12 +29471,12 @@ public void clearLoadControlEventsRequest(DefaultClusterCallback callback, int t final long commandId = 4L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface LoadControlProgramsAttributeCallback extends BaseAttributeCallback { @@ -29114,12 +29934,12 @@ public void presentMessagesRequest(DefaultClusterCallback callback, byte[] messa BaseTLVType responsestlvValue = responses.map((nonOptionalresponses) -> ArrayType.generateArrayType(nonOptionalresponses, (elementnonOptionalresponses) -> elementnonOptionalresponses.encodeTlv())).orElse(new EmptyType()); elements.add(new StructElement(responsesFieldID, responsestlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void cancelMessagesRequest(DefaultClusterCallback callback, ArrayList messageIDs) { @@ -29134,12 +29954,12 @@ public void cancelMessagesRequest(DefaultClusterCallback callback, ArrayList new ByteArrayType(elementmessageIDs)); elements.add(new StructElement(messageIDsFieldID, messageIDstlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface MessagesAttributeCallback extends BaseAttributeCallback { @@ -29415,12 +30235,12 @@ public void powerAdjustRequest(DefaultClusterCallback callback, Long power, Long BaseTLVType causetlvValue = new UIntType(cause); elements.add(new StructElement(causeFieldID, causetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void cancelPowerAdjustRequest(DefaultClusterCallback callback) { @@ -29431,12 +30251,12 @@ public void cancelPowerAdjustRequest(DefaultClusterCallback callback, int timedI final long commandId = 1L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void startTimeAdjustRequest(DefaultClusterCallback callback, Long requestedStartTime, Integer cause) { @@ -29455,12 +30275,12 @@ public void startTimeAdjustRequest(DefaultClusterCallback callback, Long request BaseTLVType causetlvValue = new UIntType(cause); elements.add(new StructElement(causeFieldID, causetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void pauseRequest(DefaultClusterCallback callback, Long duration, Integer cause) { @@ -29479,12 +30299,12 @@ public void pauseRequest(DefaultClusterCallback callback, Long duration, Integer BaseTLVType causetlvValue = new UIntType(cause); elements.add(new StructElement(causeFieldID, causetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void resumeRequest(DefaultClusterCallback callback) { @@ -29495,12 +30315,12 @@ public void resumeRequest(DefaultClusterCallback callback, int timedInvokeTimeou final long commandId = 4L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void modifyForecastRequest(DefaultClusterCallback callback, Long forecastId, ArrayList slotAdjustments, Integer cause) { @@ -29523,12 +30343,12 @@ public void modifyForecastRequest(DefaultClusterCallback callback, Long forecast BaseTLVType causetlvValue = new UIntType(cause); elements.add(new StructElement(causeFieldID, causetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void requestConstraintBasedForecast(DefaultClusterCallback callback, ArrayList constraints, Integer cause) { @@ -29547,12 +30367,12 @@ public void requestConstraintBasedForecast(DefaultClusterCallback callback, Arra BaseTLVType causetlvValue = new UIntType(cause); elements.add(new StructElement(causeFieldID, causetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void cancelRequest(DefaultClusterCallback callback) { @@ -29563,12 +30383,12 @@ public void cancelRequest(DefaultClusterCallback callback, int timedInvokeTimeou final long commandId = 7L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface PowerAdjustmentCapabilityAttributeCallback extends BaseAttributeCallback { @@ -29994,12 +30814,12 @@ public void disable(DefaultClusterCallback callback, int timedInvokeTimeoutMs) { final long commandId = 1L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -30019,12 +30839,12 @@ public void enableCharging(DefaultClusterCallback callback, @Nullable Long charg BaseTLVType maximumChargeCurrenttlvValue = new IntType(maximumChargeCurrent); elements.add(new StructElement(maximumChargeCurrentFieldID, maximumChargeCurrenttlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -30040,12 +30860,12 @@ public void enableDischarging(DefaultClusterCallback callback, @Nullable Long di BaseTLVType maximumDischargeCurrenttlvValue = new IntType(maximumDischargeCurrent); elements.add(new StructElement(maximumDischargeCurrentFieldID, maximumDischargeCurrenttlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -30053,12 +30873,12 @@ public void startDiagnostics(DefaultClusterCallback callback, int timedInvokeTim final long commandId = 4L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -30070,12 +30890,12 @@ public void setTargets(DefaultClusterCallback callback, ArrayList elementchargingTargetSchedules.encodeTlv()); elements.add(new StructElement(chargingTargetSchedulesFieldID, chargingTargetSchedulestlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -30083,7 +30903,7 @@ public void getTargets(GetTargetsResponseCallback callback, int timedInvokeTimeo final long commandId = 6L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -30098,7 +30918,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(chargingTargetSchedules); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -30106,12 +30926,12 @@ public void clearTargets(DefaultClusterCallback callback, int timedInvokeTimeout final long commandId = 7L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface GetTargetsResponseCallback extends BaseClusterCallback { @@ -31294,6 +32114,253 @@ public void onSuccess(byte[] tlv) { } } + public static class PowerTopologyCluster extends BaseChipCluster { + public static final long CLUSTER_ID = 156L; + + private static final long AVAILABLE_ENDPOINTS_ATTRIBUTE_ID = 0L; + private static final long ACTIVE_ENDPOINTS_ATTRIBUTE_ID = 1L; + private static final long GENERATED_COMMAND_LIST_ATTRIBUTE_ID = 65528L; + private static final long ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID = 65529L; + private static final long EVENT_LIST_ATTRIBUTE_ID = 65530L; + private static final long ATTRIBUTE_LIST_ATTRIBUTE_ID = 65531L; + private static final long FEATURE_MAP_ATTRIBUTE_ID = 65532L; + private static final long CLUSTER_REVISION_ATTRIBUTE_ID = 65533L; + + public PowerTopologyCluster(long devicePtr, int endpointId) { + super(devicePtr, endpointId, CLUSTER_ID); + } + + @Override + @Deprecated + public long initWithDevice(long devicePtr, int endpointId) { + return 0L; + } + + public interface AvailableEndpointsAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); + } + + public interface ActiveEndpointsAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); + } + + public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); + } + + public interface AcceptedCommandListAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); + } + + public interface EventListAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); + } + + public interface AttributeListAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); + } + + public void readAvailableEndpointsAttribute( + AvailableEndpointsAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, AVAILABLE_ENDPOINTS_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, AVAILABLE_ENDPOINTS_ATTRIBUTE_ID, true); + } + + public void subscribeAvailableEndpointsAttribute( + AvailableEndpointsAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, AVAILABLE_ENDPOINTS_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, AVAILABLE_ENDPOINTS_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readActiveEndpointsAttribute( + ActiveEndpointsAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACTIVE_ENDPOINTS_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, ACTIVE_ENDPOINTS_ATTRIBUTE_ID, true); + } + + public void subscribeActiveEndpointsAttribute( + ActiveEndpointsAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACTIVE_ENDPOINTS_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, ACTIVE_ENDPOINTS_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readGeneratedCommandListAttribute( + GeneratedCommandListAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, GENERATED_COMMAND_LIST_ATTRIBUTE_ID, true); + } + + public void subscribeGeneratedCommandListAttribute( + GeneratedCommandListAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, GENERATED_COMMAND_LIST_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readAcceptedCommandListAttribute( + AcceptedCommandListAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID, true); + } + + public void subscribeAcceptedCommandListAttribute( + AcceptedCommandListAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readEventListAttribute( + EventListAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, EVENT_LIST_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, EVENT_LIST_ATTRIBUTE_ID, true); + } + + public void subscribeEventListAttribute( + EventListAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, EVENT_LIST_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, EVENT_LIST_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readAttributeListAttribute( + AttributeListAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ATTRIBUTE_LIST_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, ATTRIBUTE_LIST_ATTRIBUTE_ID, true); + } + + public void subscribeAttributeListAttribute( + AttributeListAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ATTRIBUTE_LIST_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, ATTRIBUTE_LIST_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readFeatureMapAttribute( + LongAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, FEATURE_MAP_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, FEATURE_MAP_ATTRIBUTE_ID, true); + } + + public void subscribeFeatureMapAttribute( + LongAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, FEATURE_MAP_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, FEATURE_MAP_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readClusterRevisionAttribute( + IntegerAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CLUSTER_REVISION_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, CLUSTER_REVISION_ATTRIBUTE_ID, true); + } + + public void subscribeClusterRevisionAttribute( + IntegerAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CLUSTER_REVISION_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, CLUSTER_REVISION_ATTRIBUTE_ID, minInterval, maxInterval); + } + } + public static class EnergyEvseModeCluster extends BaseChipCluster { public static final long CLUSTER_ID = 157L; @@ -31330,7 +32397,7 @@ public void changeToMode(ChangeToModeResponseCallback callback, Integer newMode, BaseTLVType newModetlvValue = new UIntType(newMode); elements.add(new StructElement(newModeFieldID, newModetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -31352,7 +32419,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, statusText); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ChangeToModeResponseCallback extends BaseClusterCallback { @@ -31692,7 +32759,7 @@ public void changeToMode(ChangeToModeResponseCallback callback, Integer newMode, BaseTLVType newModetlvValue = new UIntType(newMode); elements.add(new StructElement(newModeFieldID, newModetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -31714,7 +32781,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, statusText); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ChangeToModeResponseCallback extends BaseClusterCallback { @@ -32092,12 +33159,12 @@ public void lockDoor(DefaultClusterCallback callback, Optional PINCode, BaseTLVType PINCodetlvValue = PINCode.map((nonOptionalPINCode) -> new ByteArrayType(nonOptionalPINCode)).orElse(new EmptyType()); elements.add(new StructElement(PINCodeFieldID, PINCodetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -32109,12 +33176,12 @@ public void unlockDoor(DefaultClusterCallback callback, Optional PINCode BaseTLVType PINCodetlvValue = PINCode.map((nonOptionalPINCode) -> new ByteArrayType(nonOptionalPINCode)).orElse(new EmptyType()); elements.add(new StructElement(PINCodeFieldID, PINCodetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -32130,12 +33197,12 @@ public void unlockWithTimeout(DefaultClusterCallback callback, Integer timeout, BaseTLVType PINCodetlvValue = PINCode.map((nonOptionalPINCode) -> new ByteArrayType(nonOptionalPINCode)).orElse(new EmptyType()); elements.add(new StructElement(PINCodeFieldID, PINCodetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setWeekDaySchedule(DefaultClusterCallback callback, Integer weekDayIndex, Integer userIndex, Integer daysMask, Integer startHour, Integer startMinute, Integer endHour, Integer endMinute) { @@ -32174,12 +33241,12 @@ public void setWeekDaySchedule(DefaultClusterCallback callback, Integer weekDayI BaseTLVType endMinutetlvValue = new UIntType(endMinute); elements.add(new StructElement(endMinuteFieldID, endMinutetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void getWeekDaySchedule(GetWeekDayScheduleResponseCallback callback, Integer weekDayIndex, Integer userIndex) { @@ -32198,7 +33265,7 @@ public void getWeekDaySchedule(GetWeekDayScheduleResponseCallback callback, Inte BaseTLVType userIndextlvValue = new UIntType(userIndex); elements.add(new StructElement(userIndexFieldID, userIndextlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -32262,7 +33329,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(weekDayIndex, userIndex, status, daysMask, startHour, startMinute, endHour, endMinute); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void clearWeekDaySchedule(DefaultClusterCallback callback, Integer weekDayIndex, Integer userIndex) { @@ -32281,12 +33348,12 @@ public void clearWeekDaySchedule(DefaultClusterCallback callback, Integer weekDa BaseTLVType userIndextlvValue = new UIntType(userIndex); elements.add(new StructElement(userIndexFieldID, userIndextlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setYearDaySchedule(DefaultClusterCallback callback, Integer yearDayIndex, Integer userIndex, Long localStartTime, Long localEndTime) { @@ -32313,12 +33380,12 @@ public void setYearDaySchedule(DefaultClusterCallback callback, Integer yearDayI BaseTLVType localEndTimetlvValue = new UIntType(localEndTime); elements.add(new StructElement(localEndTimeFieldID, localEndTimetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void getYearDaySchedule(GetYearDayScheduleResponseCallback callback, Integer yearDayIndex, Integer userIndex) { @@ -32337,7 +33404,7 @@ public void getYearDaySchedule(GetYearDayScheduleResponseCallback callback, Inte BaseTLVType userIndextlvValue = new UIntType(userIndex); elements.add(new StructElement(userIndexFieldID, userIndextlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -32380,7 +33447,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(yearDayIndex, userIndex, status, localStartTime, localEndTime); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void clearYearDaySchedule(DefaultClusterCallback callback, Integer yearDayIndex, Integer userIndex) { @@ -32399,12 +33466,12 @@ public void clearYearDaySchedule(DefaultClusterCallback callback, Integer yearDa BaseTLVType userIndextlvValue = new UIntType(userIndex); elements.add(new StructElement(userIndexFieldID, userIndextlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setHolidaySchedule(DefaultClusterCallback callback, Integer holidayIndex, Long localStartTime, Long localEndTime, Integer operatingMode) { @@ -32431,12 +33498,12 @@ public void setHolidaySchedule(DefaultClusterCallback callback, Integer holidayI BaseTLVType operatingModetlvValue = new UIntType(operatingMode); elements.add(new StructElement(operatingModeFieldID, operatingModetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void getHolidaySchedule(GetHolidayScheduleResponseCallback callback, Integer holidayIndex) { @@ -32451,7 +33518,7 @@ public void getHolidaySchedule(GetHolidayScheduleResponseCallback callback, Inte BaseTLVType holidayIndextlvValue = new UIntType(holidayIndex); elements.add(new StructElement(holidayIndexFieldID, holidayIndextlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -32494,7 +33561,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(holidayIndex, status, localStartTime, localEndTime, operatingMode); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void clearHolidaySchedule(DefaultClusterCallback callback, Integer holidayIndex) { @@ -32509,12 +33576,12 @@ public void clearHolidaySchedule(DefaultClusterCallback callback, Integer holida BaseTLVType holidayIndextlvValue = new UIntType(holidayIndex); elements.add(new StructElement(holidayIndexFieldID, holidayIndextlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -32550,12 +33617,12 @@ public void setUser(DefaultClusterCallback callback, Integer operationType, Inte BaseTLVType credentialRuletlvValue = credentialRule != null ? new UIntType(credentialRule) : new NullType(); elements.add(new StructElement(credentialRuleFieldID, credentialRuletlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void getUser(GetUserResponseCallback callback, Integer userIndex) { @@ -32570,7 +33637,7 @@ public void getUser(GetUserResponseCallback callback, Integer userIndex, int tim BaseTLVType userIndextlvValue = new UIntType(userIndex); elements.add(new StructElement(userIndexFieldID, userIndextlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -32648,7 +33715,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(userIndex, userName, userUniqueID, userStatus, userType, credentialRule, credentials, creatorFabricIndex, lastModifiedFabricIndex, nextUserIndex); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -32660,12 +33727,12 @@ public void clearUser(DefaultClusterCallback callback, Integer userIndex, int ti BaseTLVType userIndextlvValue = new UIntType(userIndex); elements.add(new StructElement(userIndexFieldID, userIndextlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -32697,7 +33764,7 @@ public void setCredential(SetCredentialResponseCallback callback, Integer operat BaseTLVType userTypetlvValue = userType != null ? new UIntType(userType) : new NullType(); elements.add(new StructElement(userTypeFieldID, userTypetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -32726,7 +33793,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, userIndex, nextCredentialIndex); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void getCredentialStatus(GetCredentialStatusResponseCallback callback, ChipStructs.DoorLockClusterCredentialStruct credential) { @@ -32741,7 +33808,7 @@ public void getCredentialStatus(GetCredentialStatusResponseCallback callback, Ch BaseTLVType credentialtlvValue = credential.encodeTlv(); elements.add(new StructElement(credentialFieldID, credentialtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -32784,7 +33851,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(credentialExists, userIndex, creatorFabricIndex, lastModifiedFabricIndex, nextCredentialIndex); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -32796,12 +33863,12 @@ public void clearCredential(DefaultClusterCallback callback, @Nullable ChipStruc BaseTLVType credentialtlvValue = credential != null ? credential.encodeTlv() : new NullType(); elements.add(new StructElement(credentialFieldID, credentialtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -32813,12 +33880,12 @@ public void unboltDoor(DefaultClusterCallback callback, Optional PINCode BaseTLVType PINCodetlvValue = PINCode.map((nonOptionalPINCode) -> new ByteArrayType(nonOptionalPINCode)).orElse(new EmptyType()); elements.add(new StructElement(PINCodeFieldID, PINCodetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -32842,12 +33909,12 @@ public void setAliroReaderConfig(DefaultClusterCallback callback, byte[] signing BaseTLVType groupResolvingKeytlvValue = groupResolvingKey.map((nonOptionalgroupResolvingKey) -> new ByteArrayType(nonOptionalgroupResolvingKey)).orElse(new EmptyType()); elements.add(new StructElement(groupResolvingKeyFieldID, groupResolvingKeytlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -32855,12 +33922,12 @@ public void clearAliroReaderConfig(DefaultClusterCallback callback, int timedInv final long commandId = 41L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface GetWeekDayScheduleResponseCallback extends BaseClusterCallback { @@ -34419,12 +35486,12 @@ public void upOrOpen(DefaultClusterCallback callback, int timedInvokeTimeoutMs) final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void downOrClose(DefaultClusterCallback callback) { @@ -34435,12 +35502,12 @@ public void downOrClose(DefaultClusterCallback callback, int timedInvokeTimeoutM final long commandId = 1L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stopMotion(DefaultClusterCallback callback) { @@ -34451,12 +35518,12 @@ public void stopMotion(DefaultClusterCallback callback, int timedInvokeTimeoutMs final long commandId = 2L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void goToLiftValue(DefaultClusterCallback callback, Integer liftValue) { @@ -34471,12 +35538,12 @@ public void goToLiftValue(DefaultClusterCallback callback, Integer liftValue, in BaseTLVType liftValuetlvValue = new UIntType(liftValue); elements.add(new StructElement(liftValueFieldID, liftValuetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void goToLiftPercentage(DefaultClusterCallback callback, Integer liftPercent100thsValue) { @@ -34491,12 +35558,12 @@ public void goToLiftPercentage(DefaultClusterCallback callback, Integer liftPerc BaseTLVType liftPercent100thsValuetlvValue = new UIntType(liftPercent100thsValue); elements.add(new StructElement(liftPercent100thsValueFieldID, liftPercent100thsValuetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void goToTiltValue(DefaultClusterCallback callback, Integer tiltValue) { @@ -34511,12 +35578,12 @@ public void goToTiltValue(DefaultClusterCallback callback, Integer tiltValue, in BaseTLVType tiltValuetlvValue = new UIntType(tiltValue); elements.add(new StructElement(tiltValueFieldID, tiltValuetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void goToTiltPercentage(DefaultClusterCallback callback, Integer tiltPercent100thsValue) { @@ -34531,12 +35598,12 @@ public void goToTiltPercentage(DefaultClusterCallback callback, Integer tiltPerc BaseTLVType tiltPercent100thsValuetlvValue = new UIntType(tiltPercent100thsValue); elements.add(new StructElement(tiltPercent100thsValueFieldID, tiltPercent100thsValuetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface CurrentPositionLiftAttributeCallback extends BaseAttributeCallback { @@ -35339,12 +36406,12 @@ public void barrierControlGoToPercent(DefaultClusterCallback callback, Integer p BaseTLVType percentOpentlvValue = new UIntType(percentOpen); elements.add(new StructElement(percentOpenFieldID, percentOpentlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void barrierControlStop(DefaultClusterCallback callback) { @@ -35355,12 +36422,12 @@ public void barrierControlStop(DefaultClusterCallback callback, int timedInvokeT final long commandId = 1L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { @@ -36826,12 +37893,12 @@ public void setpointRaiseLower(DefaultClusterCallback callback, Integer mode, In BaseTLVType amounttlvValue = new IntType(amount); elements.add(new StructElement(amountFieldID, amounttlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setWeeklySchedule(DefaultClusterCallback callback, Integer numberOfTransitionsForSequence, Integer dayOfWeekForSequence, Integer modeForSequence, ArrayList transitions) { @@ -36858,12 +37925,12 @@ public void setWeeklySchedule(DefaultClusterCallback callback, Integer numberOfT BaseTLVType transitionstlvValue = ArrayType.generateArrayType(transitions, (elementtransitions) -> elementtransitions.encodeTlv()); elements.add(new StructElement(transitionsFieldID, transitionstlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void getWeeklySchedule(GetWeeklyScheduleResponseCallback callback, Integer daysToReturn, Integer modeToReturn) { @@ -36882,7 +37949,7 @@ public void getWeeklySchedule(GetWeeklyScheduleResponseCallback callback, Intege BaseTLVType modeToReturntlvValue = new UIntType(modeToReturn); elements.add(new StructElement(modeToReturnFieldID, modeToReturntlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -36918,7 +37985,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(numberOfTransitionsForSequence, dayOfWeekForSequence, modeForSequence, transitions); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void clearWeeklySchedule(DefaultClusterCallback callback) { @@ -36929,12 +37996,12 @@ public void clearWeeklySchedule(DefaultClusterCallback callback, int timedInvoke final long commandId = 3L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setActiveScheduleRequest(DefaultClusterCallback callback, byte[] scheduleHandle) { @@ -36949,12 +38016,12 @@ public void setActiveScheduleRequest(DefaultClusterCallback callback, byte[] sch BaseTLVType scheduleHandletlvValue = new ByteArrayType(scheduleHandle); elements.add(new StructElement(scheduleHandleFieldID, scheduleHandletlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setActivePresetRequest(DefaultClusterCallback callback, byte[] presetHandle, Optional delayMinutes) { @@ -36973,12 +38040,12 @@ public void setActivePresetRequest(DefaultClusterCallback callback, byte[] prese BaseTLVType delayMinutestlvValue = delayMinutes.map((nonOptionaldelayMinutes) -> new UIntType(nonOptionaldelayMinutes)).orElse(new EmptyType()); elements.add(new StructElement(delayMinutesFieldID, delayMinutestlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void startPresetsSchedulesEditRequest(DefaultClusterCallback callback, Integer timeoutSeconds) { @@ -36993,12 +38060,12 @@ public void startPresetsSchedulesEditRequest(DefaultClusterCallback callback, In BaseTLVType timeoutSecondstlvValue = new UIntType(timeoutSeconds); elements.add(new StructElement(timeoutSecondsFieldID, timeoutSecondstlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void cancelPresetsSchedulesEditRequest(DefaultClusterCallback callback) { @@ -37009,12 +38076,12 @@ public void cancelPresetsSchedulesEditRequest(DefaultClusterCallback callback, i final long commandId = 8L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void commitPresetsSchedulesRequest(DefaultClusterCallback callback) { @@ -37025,12 +38092,12 @@ public void commitPresetsSchedulesRequest(DefaultClusterCallback callback, int t final long commandId = 9L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void cancelSetActivePresetRequest(DefaultClusterCallback callback) { @@ -37041,12 +38108,12 @@ public void cancelSetActivePresetRequest(DefaultClusterCallback callback, int ti final long commandId = 10L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setTemperatureSetpointHoldPolicy(DefaultClusterCallback callback, Integer temperatureSetpointHoldPolicy) { @@ -37061,12 +38128,12 @@ public void setTemperatureSetpointHoldPolicy(DefaultClusterCallback callback, In BaseTLVType temperatureSetpointHoldPolicytlvValue = new UIntType(temperatureSetpointHoldPolicy); elements.add(new StructElement(temperatureSetpointHoldPolicyFieldID, temperatureSetpointHoldPolicytlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface GetWeeklyScheduleResponseCallback extends BaseClusterCallback { @@ -39208,12 +40275,12 @@ public void step(DefaultClusterCallback callback, Integer direction, Optionalmap((nonOptionallowestOff) -> new BooleanType(nonOptionallowestOff)).orElse(new EmptyType()); elements.add(new StructElement(lowestOffFieldID, lowestOfftlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface PercentSettingAttributeCallback extends BaseAttributeCallback { @@ -40137,12 +41204,12 @@ public void moveToHue(DefaultClusterCallback callback, Integer hue, Integer dire BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void moveHue(DefaultClusterCallback callback, Integer moveMode, Integer rate, Integer optionsMask, Integer optionsOverride) { @@ -40169,12 +41236,12 @@ public void moveHue(DefaultClusterCallback callback, Integer moveMode, Integer r BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stepHue(DefaultClusterCallback callback, Integer stepMode, Integer stepSize, Integer transitionTime, Integer optionsMask, Integer optionsOverride) { @@ -40205,12 +41272,12 @@ public void stepHue(DefaultClusterCallback callback, Integer stepMode, Integer s BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void moveToSaturation(DefaultClusterCallback callback, Integer saturation, Integer transitionTime, Integer optionsMask, Integer optionsOverride) { @@ -40237,12 +41304,12 @@ public void moveToSaturation(DefaultClusterCallback callback, Integer saturation BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void moveSaturation(DefaultClusterCallback callback, Integer moveMode, Integer rate, Integer optionsMask, Integer optionsOverride) { @@ -40269,12 +41336,12 @@ public void moveSaturation(DefaultClusterCallback callback, Integer moveMode, In BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stepSaturation(DefaultClusterCallback callback, Integer stepMode, Integer stepSize, Integer transitionTime, Integer optionsMask, Integer optionsOverride) { @@ -40305,12 +41372,12 @@ public void stepSaturation(DefaultClusterCallback callback, Integer stepMode, In BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void moveToHueAndSaturation(DefaultClusterCallback callback, Integer hue, Integer saturation, Integer transitionTime, Integer optionsMask, Integer optionsOverride) { @@ -40341,12 +41408,12 @@ public void moveToHueAndSaturation(DefaultClusterCallback callback, Integer hue, BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void moveToColor(DefaultClusterCallback callback, Integer colorX, Integer colorY, Integer transitionTime, Integer optionsMask, Integer optionsOverride) { @@ -40377,12 +41444,12 @@ public void moveToColor(DefaultClusterCallback callback, Integer colorX, Integer BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void moveColor(DefaultClusterCallback callback, Integer rateX, Integer rateY, Integer optionsMask, Integer optionsOverride) { @@ -40409,12 +41476,12 @@ public void moveColor(DefaultClusterCallback callback, Integer rateX, Integer ra BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stepColor(DefaultClusterCallback callback, Integer stepX, Integer stepY, Integer transitionTime, Integer optionsMask, Integer optionsOverride) { @@ -40445,12 +41512,12 @@ public void stepColor(DefaultClusterCallback callback, Integer stepX, Integer st BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void moveToColorTemperature(DefaultClusterCallback callback, Integer colorTemperatureMireds, Integer transitionTime, Integer optionsMask, Integer optionsOverride) { @@ -40477,12 +41544,12 @@ public void moveToColorTemperature(DefaultClusterCallback callback, Integer colo BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void enhancedMoveToHue(DefaultClusterCallback callback, Integer enhancedHue, Integer direction, Integer transitionTime, Integer optionsMask, Integer optionsOverride) { @@ -40513,12 +41580,12 @@ public void enhancedMoveToHue(DefaultClusterCallback callback, Integer enhancedH BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void enhancedMoveHue(DefaultClusterCallback callback, Integer moveMode, Integer rate, Integer optionsMask, Integer optionsOverride) { @@ -40545,12 +41612,12 @@ public void enhancedMoveHue(DefaultClusterCallback callback, Integer moveMode, I BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void enhancedStepHue(DefaultClusterCallback callback, Integer stepMode, Integer stepSize, Integer transitionTime, Integer optionsMask, Integer optionsOverride) { @@ -40581,12 +41648,12 @@ public void enhancedStepHue(DefaultClusterCallback callback, Integer stepMode, I BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void enhancedMoveToHueAndSaturation(DefaultClusterCallback callback, Integer enhancedHue, Integer saturation, Integer transitionTime, Integer optionsMask, Integer optionsOverride) { @@ -40617,12 +41684,12 @@ public void enhancedMoveToHueAndSaturation(DefaultClusterCallback callback, Inte BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void colorLoopSet(DefaultClusterCallback callback, Integer updateFlags, Integer action, Integer direction, Integer time, Integer startHue, Integer optionsMask, Integer optionsOverride) { @@ -40661,12 +41728,12 @@ public void colorLoopSet(DefaultClusterCallback callback, Integer updateFlags, I BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stopMoveStep(DefaultClusterCallback callback, Integer optionsMask, Integer optionsOverride) { @@ -40685,12 +41752,12 @@ public void stopMoveStep(DefaultClusterCallback callback, Integer optionsMask, I BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void moveColorTemperature(DefaultClusterCallback callback, Integer moveMode, Integer rate, Integer colorTemperatureMinimumMireds, Integer colorTemperatureMaximumMireds, Integer optionsMask, Integer optionsOverride) { @@ -40725,12 +41792,12 @@ public void moveColorTemperature(DefaultClusterCallback callback, Integer moveMo BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stepColorTemperature(DefaultClusterCallback callback, Integer stepMode, Integer stepSize, Integer transitionTime, Integer colorTemperatureMinimumMireds, Integer colorTemperatureMaximumMireds, Integer optionsMask, Integer optionsOverride) { @@ -40769,12 +41836,12 @@ public void stepColorTemperature(DefaultClusterCallback callback, Integer stepMo BaseTLVType optionsOverridetlvValue = new UIntType(optionsOverride); elements.add(new StructElement(optionsOverrideFieldID, optionsOverridetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface NumberOfPrimariesAttributeCallback extends BaseAttributeCallback { @@ -50537,7 +51604,7 @@ public void changeChannel(ChangeChannelResponseCallback callback, String match, BaseTLVType matchtlvValue = new StringType(match); elements.add(new StructElement(matchFieldID, matchtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -50559,7 +51626,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void changeChannelByNumber(DefaultClusterCallback callback, Integer majorNumber, Integer minorNumber) { @@ -50578,12 +51645,12 @@ public void changeChannelByNumber(DefaultClusterCallback callback, Integer major BaseTLVType minorNumbertlvValue = new UIntType(minorNumber); elements.add(new StructElement(minorNumberFieldID, minorNumbertlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void skipChannel(DefaultClusterCallback callback, Integer count) { @@ -50598,12 +51665,12 @@ public void skipChannel(DefaultClusterCallback callback, Integer count, int time BaseTLVType counttlvValue = new IntType(count); elements.add(new StructElement(countFieldID, counttlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void getProgramGuide(ProgramGuideResponseCallback callback, Optional startTime, Optional endTime, Optional> channelList, Optional pageToken, Optional recordingFlag, Optional> externalIDList, Optional data) { @@ -50642,7 +51709,7 @@ public void getProgramGuide(ProgramGuideResponseCallback callback, Optionalmap((nonOptionaldata) -> new ByteArrayType(nonOptionaldata)).orElse(new EmptyType()); elements.add(new StructElement(dataFieldID, datatlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -50664,7 +51731,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(paging, programList); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void recordProgram(DefaultClusterCallback callback, String programIdentifier, Boolean shouldRecordSeries, ArrayList externalIDList, byte[] data) { @@ -50691,12 +51758,12 @@ public void recordProgram(DefaultClusterCallback callback, String programIdentif BaseTLVType datatlvValue = new ByteArrayType(data); elements.add(new StructElement(dataFieldID, datatlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void cancelRecordProgram(DefaultClusterCallback callback, String programIdentifier, Boolean shouldRecordSeries, ArrayList externalIDList, byte[] data) { @@ -50723,12 +51790,12 @@ public void cancelRecordProgram(DefaultClusterCallback callback, String programI BaseTLVType datatlvValue = new ByteArrayType(data); elements.add(new StructElement(dataFieldID, datatlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ChangeChannelResponseCallback extends BaseClusterCallback { @@ -51031,7 +52098,7 @@ public void navigateTarget(NavigateTargetResponseCallback callback, Integer targ BaseTLVType datatlvValue = data.map((nonOptionaldata) -> new StringType(nonOptionaldata)).orElse(new EmptyType()); elements.add(new StructElement(dataFieldID, datatlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -51053,7 +52120,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface NavigateTargetResponseCallback extends BaseClusterCallback { @@ -51320,7 +52387,7 @@ public void play(PlaybackResponseCallback callback, int timedInvokeTimeoutMs) { final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -51342,7 +52409,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void pause(PlaybackResponseCallback callback) { @@ -51353,7 +52420,7 @@ public void pause(PlaybackResponseCallback callback, int timedInvokeTimeoutMs) { final long commandId = 1L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -51375,7 +52442,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stop(PlaybackResponseCallback callback) { @@ -51386,7 +52453,7 @@ public void stop(PlaybackResponseCallback callback, int timedInvokeTimeoutMs) { final long commandId = 2L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -51408,7 +52475,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void startOver(PlaybackResponseCallback callback) { @@ -51419,7 +52486,7 @@ public void startOver(PlaybackResponseCallback callback, int timedInvokeTimeoutM final long commandId = 3L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -51441,7 +52508,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void previous(PlaybackResponseCallback callback) { @@ -51452,7 +52519,7 @@ public void previous(PlaybackResponseCallback callback, int timedInvokeTimeoutMs final long commandId = 4L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -51474,7 +52541,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void next(PlaybackResponseCallback callback) { @@ -51485,7 +52552,7 @@ public void next(PlaybackResponseCallback callback, int timedInvokeTimeoutMs) { final long commandId = 5L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -51507,7 +52574,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void rewind(PlaybackResponseCallback callback, Optional audioAdvanceUnmuted) { @@ -51522,7 +52589,7 @@ public void rewind(PlaybackResponseCallback callback, Optional audioAdv BaseTLVType audioAdvanceUnmutedtlvValue = audioAdvanceUnmuted.map((nonOptionalaudioAdvanceUnmuted) -> new BooleanType(nonOptionalaudioAdvanceUnmuted)).orElse(new EmptyType()); elements.add(new StructElement(audioAdvanceUnmutedFieldID, audioAdvanceUnmutedtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -51544,7 +52611,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void fastForward(PlaybackResponseCallback callback, Optional audioAdvanceUnmuted) { @@ -51559,7 +52626,7 @@ public void fastForward(PlaybackResponseCallback callback, Optional aud BaseTLVType audioAdvanceUnmutedtlvValue = audioAdvanceUnmuted.map((nonOptionalaudioAdvanceUnmuted) -> new BooleanType(nonOptionalaudioAdvanceUnmuted)).orElse(new EmptyType()); elements.add(new StructElement(audioAdvanceUnmutedFieldID, audioAdvanceUnmutedtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -51581,7 +52648,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void skipForward(PlaybackResponseCallback callback, Long deltaPositionMilliseconds) { @@ -51596,7 +52663,7 @@ public void skipForward(PlaybackResponseCallback callback, Long deltaPositionMil BaseTLVType deltaPositionMillisecondstlvValue = new UIntType(deltaPositionMilliseconds); elements.add(new StructElement(deltaPositionMillisecondsFieldID, deltaPositionMillisecondstlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -51618,7 +52685,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void skipBackward(PlaybackResponseCallback callback, Long deltaPositionMilliseconds) { @@ -51633,7 +52700,7 @@ public void skipBackward(PlaybackResponseCallback callback, Long deltaPositionMi BaseTLVType deltaPositionMillisecondstlvValue = new UIntType(deltaPositionMilliseconds); elements.add(new StructElement(deltaPositionMillisecondsFieldID, deltaPositionMillisecondstlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -51655,7 +52722,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void seek(PlaybackResponseCallback callback, Long position) { @@ -51670,7 +52737,7 @@ public void seek(PlaybackResponseCallback callback, Long position, int timedInvo BaseTLVType positiontlvValue = new UIntType(position); elements.add(new StructElement(positionFieldID, positiontlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -51692,7 +52759,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void activateAudioTrack(DefaultClusterCallback callback, String trackID, Integer audioOutputIndex) { @@ -51711,12 +52778,12 @@ public void activateAudioTrack(DefaultClusterCallback callback, String trackID, BaseTLVType audioOutputIndextlvValue = new UIntType(audioOutputIndex); elements.add(new StructElement(audioOutputIndexFieldID, audioOutputIndextlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void activateTextTrack(DefaultClusterCallback callback, String trackID) { @@ -51731,12 +52798,12 @@ public void activateTextTrack(DefaultClusterCallback callback, String trackID, i BaseTLVType trackIDtlvValue = new StringType(trackID); elements.add(new StructElement(trackIDFieldID, trackIDtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void deactivateTextTrack(DefaultClusterCallback callback) { @@ -51747,12 +52814,12 @@ public void deactivateTextTrack(DefaultClusterCallback callback, int timedInvoke final long commandId = 14L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface PlaybackResponseCallback extends BaseClusterCallback { @@ -52271,12 +53338,12 @@ public void selectInput(DefaultClusterCallback callback, Integer index, int time BaseTLVType indextlvValue = new UIntType(index); elements.add(new StructElement(indexFieldID, indextlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void showInputStatus(DefaultClusterCallback callback) { @@ -52287,12 +53354,12 @@ public void showInputStatus(DefaultClusterCallback callback, int timedInvokeTime final long commandId = 1L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void hideInputStatus(DefaultClusterCallback callback) { @@ -52303,12 +53370,12 @@ public void hideInputStatus(DefaultClusterCallback callback, int timedInvokeTime final long commandId = 2L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void renameInput(DefaultClusterCallback callback, Integer index, String name) { @@ -52327,12 +53394,12 @@ public void renameInput(DefaultClusterCallback callback, Integer index, String n BaseTLVType nametlvValue = new StringType(name); elements.add(new StructElement(nameFieldID, nametlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface InputListAttributeCallback extends BaseAttributeCallback { @@ -52584,12 +53651,12 @@ public void sleep(DefaultClusterCallback callback, int timedInvokeTimeoutMs) { final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { @@ -52791,7 +53858,7 @@ public void sendKey(SendKeyResponseCallback callback, Integer keyCode, int timed BaseTLVType keyCodetlvValue = new UIntType(keyCode); elements.add(new StructElement(keyCodeFieldID, keyCodetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -52806,7 +53873,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface SendKeyResponseCallback extends BaseClusterCallback { @@ -53030,7 +54097,7 @@ public void launchContent(LauncherResponseCallback callback, ChipStructs.Content BaseTLVType useCurrentContexttlvValue = useCurrentContext.map((nonOptionaluseCurrentContext) -> new BooleanType(nonOptionaluseCurrentContext)).orElse(new EmptyType()); elements.add(new StructElement(useCurrentContextFieldID, useCurrentContexttlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -53052,7 +54119,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void launchURL(LauncherResponseCallback callback, String contentURL, Optional displayString, Optional brandingInformation) { @@ -53075,7 +54142,7 @@ public void launchURL(LauncherResponseCallback callback, String contentURL, Opti BaseTLVType brandingInformationtlvValue = brandingInformation.map((nonOptionalbrandingInformation) -> nonOptionalbrandingInformation.encodeTlv()).orElse(new EmptyType()); elements.add(new StructElement(brandingInformationFieldID, brandingInformationtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -53097,7 +54164,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface LauncherResponseCallback extends BaseClusterCallback { @@ -53359,12 +54426,12 @@ public void selectOutput(DefaultClusterCallback callback, Integer index, int tim BaseTLVType indextlvValue = new UIntType(index); elements.add(new StructElement(indexFieldID, indextlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void renameOutput(DefaultClusterCallback callback, Integer index, String name) { @@ -53383,12 +54450,12 @@ public void renameOutput(DefaultClusterCallback callback, Integer index, String BaseTLVType nametlvValue = new StringType(name); elements.add(new StructElement(nameFieldID, nametlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface OutputListAttributeCallback extends BaseAttributeCallback { @@ -53650,7 +54717,7 @@ public void launchApp(LauncherResponseCallback callback, Optionalmap((nonOptionaldata) -> new ByteArrayType(nonOptionaldata)).orElse(new EmptyType()); elements.add(new StructElement(dataFieldID, datatlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -53672,7 +54739,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void stopApp(LauncherResponseCallback callback, Optional application) { @@ -53687,7 +54754,7 @@ public void stopApp(LauncherResponseCallback callback, Optionalmap((nonOptionalapplication) -> nonOptionalapplication.encodeTlv()).orElse(new EmptyType()); elements.add(new StructElement(applicationFieldID, applicationtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -53709,7 +54776,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void hideApp(LauncherResponseCallback callback, Optional application) { @@ -53724,7 +54791,7 @@ public void hideApp(LauncherResponseCallback callback, Optionalmap((nonOptionalapplication) -> nonOptionalapplication.encodeTlv()).orElse(new EmptyType()); elements.add(new StructElement(applicationFieldID, applicationtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -53746,7 +54813,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface LauncherResponseCallback extends BaseClusterCallback { @@ -54410,7 +55477,7 @@ public void getSetupPIN(GetSetupPINResponseCallback callback, String tempAccount BaseTLVType tempAccountIdentifiertlvValue = new StringType(tempAccountIdentifier); elements.add(new StructElement(tempAccountIdentifierFieldID, tempAccountIdentifiertlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -54425,7 +55492,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(setupPIN); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -54445,12 +55512,12 @@ public void login(DefaultClusterCallback callback, String tempAccountIdentifier, BaseTLVType nodetlvValue = node.map((nonOptionalnode) -> new UIntType(nonOptionalnode)).orElse(new EmptyType()); elements.add(new StructElement(nodeFieldID, nodetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -54462,12 +55529,12 @@ public void logout(DefaultClusterCallback callback, Optional node, int tim BaseTLVType nodetlvValue = node.map((nonOptionalnode) -> new UIntType(nonOptionalnode)).orElse(new EmptyType()); elements.add(new StructElement(nodeFieldID, nodetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface GetSetupPINResponseCallback extends BaseClusterCallback { @@ -54685,12 +55752,12 @@ public void updatePIN(DefaultClusterCallback callback, Optional oldPIN, BaseTLVType newPINtlvValue = new StringType(newPIN); elements.add(new StructElement(newPINFieldID, newPINtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void resetPIN(ResetPINResponseCallback callback) { @@ -54701,7 +55768,7 @@ public void resetPIN(ResetPINResponseCallback callback, int timedInvokeTimeoutMs final long commandId = 1L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -54716,7 +55783,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(PINCode); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void enable(DefaultClusterCallback callback) { @@ -54727,12 +55794,12 @@ public void enable(DefaultClusterCallback callback, int timedInvokeTimeoutMs) { final long commandId = 3L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void disable(DefaultClusterCallback callback) { @@ -54743,12 +55810,12 @@ public void disable(DefaultClusterCallback callback, int timedInvokeTimeoutMs) { final long commandId = 4L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void addBonusTime(DefaultClusterCallback callback, Optional PINCode, Optional bonusTime) { @@ -54767,12 +55834,12 @@ public void addBonusTime(DefaultClusterCallback callback, Optional PINCo BaseTLVType bonusTimetlvValue = bonusTime.map((nonOptionalbonusTime) -> new UIntType(nonOptionalbonusTime)).orElse(new EmptyType()); elements.add(new StructElement(bonusTimeFieldID, bonusTimetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setScreenDailyTime(DefaultClusterCallback callback, Long screenTime) { @@ -54787,12 +55854,12 @@ public void setScreenDailyTime(DefaultClusterCallback callback, Long screenTime, BaseTLVType screenTimetlvValue = new UIntType(screenTime); elements.add(new StructElement(screenTimeFieldID, screenTimetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void blockUnratedContent(DefaultClusterCallback callback) { @@ -54803,12 +55870,12 @@ public void blockUnratedContent(DefaultClusterCallback callback, int timedInvoke final long commandId = 7L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void unblockUnratedContent(DefaultClusterCallback callback) { @@ -54819,12 +55886,12 @@ public void unblockUnratedContent(DefaultClusterCallback callback, int timedInvo final long commandId = 8L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setOnDemandRatingThreshold(DefaultClusterCallback callback, String rating) { @@ -54839,12 +55906,12 @@ public void setOnDemandRatingThreshold(DefaultClusterCallback callback, String r BaseTLVType ratingtlvValue = new StringType(rating); elements.add(new StructElement(ratingFieldID, ratingtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void setScheduledContentRatingThreshold(DefaultClusterCallback callback, String rating) { @@ -54859,12 +55926,12 @@ public void setScheduledContentRatingThreshold(DefaultClusterCallback callback, BaseTLVType ratingtlvValue = new StringType(rating); elements.add(new StructElement(ratingFieldID, ratingtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ResetPINResponseCallback extends BaseClusterCallback { @@ -55282,7 +56349,7 @@ public void contentAppMessage(ContentAppMessageResponseCallback callback, Option BaseTLVType encodingHinttlvValue = new StringType(encodingHint); elements.add(new StructElement(encodingHintFieldID, encodingHinttlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -55311,7 +56378,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(status, data, encodingHint); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface ContentAppMessageResponseCallback extends BaseClusterCallback { @@ -55641,12 +56708,12 @@ public void getProfileInfoCommand(DefaultClusterCallback callback, int timedInvo final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void getMeasurementProfileCommand(DefaultClusterCallback callback, Integer attributeId, Long startTime, Integer numberOfIntervals) { @@ -55669,12 +56736,12 @@ public void getMeasurementProfileCommand(DefaultClusterCallback callback, Intege BaseTLVType numberOfIntervalstlvValue = new UIntType(numberOfIntervals); elements.add(new StructElement(numberOfIntervalsFieldID, numberOfIntervalstlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { @@ -59227,12 +60294,12 @@ public void test(DefaultClusterCallback callback, int timedInvokeTimeoutMs) { final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testNotHandled(DefaultClusterCallback callback) { @@ -59243,12 +60310,12 @@ public void testNotHandled(DefaultClusterCallback callback, int timedInvokeTimeo final long commandId = 1L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testSpecific(TestSpecificResponseCallback callback) { @@ -59259,7 +60326,7 @@ public void testSpecific(TestSpecificResponseCallback callback, int timedInvokeT final long commandId = 2L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -59274,7 +60341,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(returnValue); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testUnknownCommand(DefaultClusterCallback callback) { @@ -59285,12 +60352,12 @@ public void testUnknownCommand(DefaultClusterCallback callback, int timedInvokeT final long commandId = 3L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testAddArguments(TestAddArgumentsResponseCallback callback, Integer arg1, Integer arg2) { @@ -59309,7 +60376,7 @@ public void testAddArguments(TestAddArgumentsResponseCallback callback, Integer BaseTLVType arg2tlvValue = new UIntType(arg2); elements.add(new StructElement(arg2FieldID, arg2tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -59324,7 +60391,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(returnValue); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testSimpleArgumentRequest(TestSimpleArgumentResponseCallback callback, Boolean arg1) { @@ -59339,7 +60406,7 @@ public void testSimpleArgumentRequest(TestSimpleArgumentResponseCallback callbac BaseTLVType arg1tlvValue = new BooleanType(arg1); elements.add(new StructElement(arg1FieldID, arg1tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -59354,7 +60421,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(returnValue); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testStructArrayArgumentRequest(TestStructArrayArgumentResponseCallback callback, ArrayList arg1, ArrayList arg2, ArrayList arg3, ArrayList arg4, Integer arg5, Boolean arg6) { @@ -59389,7 +60456,7 @@ public void testStructArrayArgumentRequest(TestStructArrayArgumentResponseCallba BaseTLVType arg6tlvValue = new BooleanType(arg6); elements.add(new StructElement(arg6FieldID, arg6tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -59439,7 +60506,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(arg1, arg2, arg3, arg4, arg5, arg6); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testStructArgumentRequest(BooleanResponseCallback callback, ChipStructs.UnitTestingClusterSimpleStruct arg1) { @@ -59454,7 +60521,7 @@ public void testStructArgumentRequest(BooleanResponseCallback callback, ChipStru BaseTLVType arg1tlvValue = arg1.encodeTlv(); elements.add(new StructElement(arg1FieldID, arg1tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -59469,7 +60536,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(value); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testNestedStructArgumentRequest(BooleanResponseCallback callback, ChipStructs.UnitTestingClusterNestedStruct arg1) { @@ -59484,7 +60551,7 @@ public void testNestedStructArgumentRequest(BooleanResponseCallback callback, Ch BaseTLVType arg1tlvValue = arg1.encodeTlv(); elements.add(new StructElement(arg1FieldID, arg1tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -59499,7 +60566,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(value); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testListStructArgumentRequest(BooleanResponseCallback callback, ArrayList arg1) { @@ -59514,7 +60581,7 @@ public void testListStructArgumentRequest(BooleanResponseCallback callback, Arra BaseTLVType arg1tlvValue = ArrayType.generateArrayType(arg1, (elementarg1) -> elementarg1.encodeTlv()); elements.add(new StructElement(arg1FieldID, arg1tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -59529,7 +60596,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(value); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testListInt8UArgumentRequest(BooleanResponseCallback callback, ArrayList arg1) { @@ -59544,7 +60611,7 @@ public void testListInt8UArgumentRequest(BooleanResponseCallback callback, Array BaseTLVType arg1tlvValue = ArrayType.generateArrayType(arg1, (elementarg1) -> new UIntType(elementarg1)); elements.add(new StructElement(arg1FieldID, arg1tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -59559,7 +60626,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(value); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testNestedStructListArgumentRequest(BooleanResponseCallback callback, ChipStructs.UnitTestingClusterNestedStructList arg1) { @@ -59574,7 +60641,7 @@ public void testNestedStructListArgumentRequest(BooleanResponseCallback callback BaseTLVType arg1tlvValue = arg1.encodeTlv(); elements.add(new StructElement(arg1FieldID, arg1tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -59589,7 +60656,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(value); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testListNestedStructListArgumentRequest(BooleanResponseCallback callback, ArrayList arg1) { @@ -59604,7 +60671,7 @@ public void testListNestedStructListArgumentRequest(BooleanResponseCallback call BaseTLVType arg1tlvValue = ArrayType.generateArrayType(arg1, (elementarg1) -> elementarg1.encodeTlv()); elements.add(new StructElement(arg1FieldID, arg1tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -59619,7 +60686,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(value); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testListInt8UReverseRequest(TestListInt8UReverseResponseCallback callback, ArrayList arg1) { @@ -59634,7 +60701,7 @@ public void testListInt8UReverseRequest(TestListInt8UReverseResponseCallback cal BaseTLVType arg1tlvValue = ArrayType.generateArrayType(arg1, (elementarg1) -> new UIntType(elementarg1)); elements.add(new StructElement(arg1FieldID, arg1tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -59649,7 +60716,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(arg1); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testEnumsRequest(TestEnumsResponseCallback callback, Integer arg1, Integer arg2) { @@ -59668,7 +60735,7 @@ public void testEnumsRequest(TestEnumsResponseCallback callback, Integer arg1, I BaseTLVType arg2tlvValue = new UIntType(arg2); elements.add(new StructElement(arg2FieldID, arg2tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -59690,7 +60757,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(arg1, arg2); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testNullableOptionalRequest(TestNullableOptionalResponseCallback callback, @Nullable Optional arg1) { @@ -59705,7 +60772,7 @@ public void testNullableOptionalRequest(TestNullableOptionalResponseCallback cal BaseTLVType arg1tlvValue = arg1 != null ? arg1.map((nonOptionalarg1) -> new UIntType(nonOptionalarg1)).orElse(new EmptyType()) : new NullType(); elements.add(new StructElement(arg1FieldID, arg1tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -59741,7 +60808,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(wasPresent, wasNull, value, originalValue); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testComplexNullableOptionalRequest(TestComplexNullableOptionalResponseCallback callback, @Nullable Integer nullableInt, Optional optionalInt, @Nullable Optional nullableOptionalInt, @Nullable String nullableString, Optional optionalString, @Nullable Optional nullableOptionalString, @Nullable ChipStructs.UnitTestingClusterSimpleStruct nullableStruct, Optional optionalStruct, @Nullable Optional nullableOptionalStruct, @Nullable ArrayList nullableList, Optional> optionalList, @Nullable Optional> nullableOptionalList) { @@ -59800,7 +60867,7 @@ public void testComplexNullableOptionalRequest(TestComplexNullableOptionalRespon BaseTLVType nullableOptionalListtlvValue = nullableOptionalList != null ? nullableOptionalList.map((nonOptionalnullableOptionalList) -> ArrayType.generateArrayType(nonOptionalnullableOptionalList, (elementnonOptionalnullableOptionalList) -> new UIntType(elementnonOptionalnullableOptionalList))).orElse(new EmptyType()) : new NullType(); elements.add(new StructElement(nullableOptionalListFieldID, nullableOptionalListtlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -60004,7 +61071,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(nullableIntWasNull, nullableIntValue, optionalIntWasPresent, optionalIntValue, nullableOptionalIntWasPresent, nullableOptionalIntWasNull, nullableOptionalIntValue, nullableStringWasNull, nullableStringValue, optionalStringWasPresent, optionalStringValue, nullableOptionalStringWasPresent, nullableOptionalStringWasNull, nullableOptionalStringValue, nullableStructWasNull, nullableStructValue, optionalStructWasPresent, optionalStructValue, nullableOptionalStructWasPresent, nullableOptionalStructWasNull, nullableOptionalStructValue, nullableListWasNull, nullableListValue, optionalListWasPresent, optionalListValue, nullableOptionalListWasPresent, nullableOptionalListWasNull, nullableOptionalListValue); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void simpleStructEchoRequest(SimpleStructResponseCallback callback, ChipStructs.UnitTestingClusterSimpleStruct arg1) { @@ -60019,7 +61086,7 @@ public void simpleStructEchoRequest(SimpleStructResponseCallback callback, ChipS BaseTLVType arg1tlvValue = arg1.encodeTlv(); elements.add(new StructElement(arg1FieldID, arg1tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -60034,7 +61101,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(arg1); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } @@ -60042,12 +61109,12 @@ public void timedInvokeRequest(DefaultClusterCallback callback, int timedInvokeT final long commandId = 18L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testSimpleOptionalArgumentRequest(DefaultClusterCallback callback, Optional arg1) { @@ -60062,12 +61129,12 @@ public void testSimpleOptionalArgumentRequest(DefaultClusterCallback callback, O BaseTLVType arg1tlvValue = arg1.map((nonOptionalarg1) -> new BooleanType(nonOptionalarg1)).orElse(new EmptyType()); elements.add(new StructElement(arg1FieldID, arg1tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testEmitTestEventRequest(TestEmitTestEventResponseCallback callback, Integer arg1, Integer arg2, Boolean arg3) { @@ -60090,7 +61157,7 @@ public void testEmitTestEventRequest(TestEmitTestEventResponseCallback callback, BaseTLVType arg3tlvValue = new BooleanType(arg3); elements.add(new StructElement(arg3FieldID, arg3tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -60105,7 +61172,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(value); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testEmitTestFabricScopedEventRequest(TestEmitTestFabricScopedEventResponseCallback callback, Integer arg1) { @@ -60120,7 +61187,7 @@ public void testEmitTestFabricScopedEventRequest(TestEmitTestFabricScopedEventRe BaseTLVType arg1tlvValue = new UIntType(arg1); elements.add(new StructElement(arg1FieldID, arg1tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -60135,7 +61202,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(value); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testBatchHelperRequest(TestBatchHelperResponseCallback callback, Integer sleepBeforeResponseTimeMs, Integer sizeOfResponseBuffer, Integer fillCharacter) { @@ -60158,7 +61225,7 @@ public void testBatchHelperRequest(TestBatchHelperResponseCallback callback, Int BaseTLVType fillCharactertlvValue = new UIntType(fillCharacter); elements.add(new StructElement(fillCharacterFieldID, fillCharactertlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -60173,7 +61240,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(buffer); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testSecondBatchHelperRequest(TestBatchHelperResponseCallback callback, Integer sleepBeforeResponseTimeMs, Integer sizeOfResponseBuffer, Integer fillCharacter) { @@ -60196,7 +61263,7 @@ public void testSecondBatchHelperRequest(TestBatchHelperResponseCallback callbac BaseTLVType fillCharactertlvValue = new UIntType(fillCharacter); elements.add(new StructElement(fillCharacterFieldID, fillCharactertlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -60211,7 +61278,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(buffer); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void testDifferentVendorMeiRequest(TestDifferentVendorMeiResponseCallback callback, Integer arg1) { @@ -60226,7 +61293,7 @@ public void testDifferentVendorMeiRequest(TestDifferentVendorMeiResponseCallback BaseTLVType arg1tlvValue = new UIntType(arg1); elements.add(new StructElement(arg1FieldID, arg1tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -60248,7 +61315,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(arg1, eventNumber); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface TestSpecificResponseCallback extends BaseClusterCallback { @@ -63505,12 +64572,12 @@ public void failAtFault(DefaultClusterCallback callback, Integer type, Long id, BaseTLVType takeMutextlvValue = new BooleanType(takeMutex); elements.add(new StructElement(takeMutexFieldID, takeMutextlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void failRandomlyAtFault(DefaultClusterCallback callback, Integer type, Long id, Integer percentage) { @@ -63533,12 +64600,12 @@ public void failRandomlyAtFault(DefaultClusterCallback callback, Integer type, L BaseTLVType percentagetlvValue = new UIntType(percentage); elements.add(new StructElement(percentageFieldID, percentagetlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { @@ -63737,12 +64804,12 @@ public void ping(DefaultClusterCallback callback, int timedInvokeTimeoutMs) { final long commandId = 0L; ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { callback.onSuccess(); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public void addArguments(AddArgumentsResponseCallback callback, Integer arg1, Integer arg2) { @@ -63761,7 +64828,7 @@ public void addArguments(AddArgumentsResponseCallback callback, Integer arg1, In BaseTLVType arg2tlvValue = new UIntType(arg2); elements.add(new StructElement(arg2FieldID, arg2tlvValue)); - StructType value = new StructType(elements); + StructType commandArgs = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override public void onResponse(StructType invokeStructValue) { @@ -63776,7 +64843,7 @@ public void onResponse(StructType invokeStructValue) { } } callback.onSuccess(returnValue); - }}, commandId, value, timedInvokeTimeoutMs); + }}, commandId, commandArgs, timedInvokeTimeoutMs); } public interface AddArgumentsResponseCallback extends BaseClusterCallback { diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java b/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java index b759822df155b5..ce1a79c5a4a710 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java @@ -3457,6 +3457,52 @@ public String toString() { return output.toString(); } } +public static class ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent { + public ArrayList ranges; + private static final long RANGES_ID = 0L; + + public ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent( + ArrayList ranges + ) { + this.ranges = ranges; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(RANGES_ID, ArrayType.generateArrayType(ranges, (elementranges) -> elementranges.encodeTlv()))); + + return new StructType(values); + } + + public static ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + ArrayList ranges = null; + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == RANGES_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Array) { + ArrayType castingValue = element.value(ArrayType.class); + ranges = castingValue.map((elementcastingValue) -> ChipStructs.ElectricalPowerMeasurementClusterMeasurementRangeStruct.decodeTlv(elementcastingValue)); + } + } + } + return new ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent( + ranges + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent {\n"); + output.append("\tranges: "); + output.append(ranges); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} public static class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { public Optional energyImported; public Optional energyExported; diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java b/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java index cfc67037e90260..6fb0469aded45c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java @@ -5428,6 +5428,520 @@ public String toString() { return output.toString(); } } +public static class ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct { + public Long rangeMin; + public Long rangeMax; + public Optional percentMax; + public Optional percentMin; + public Optional percentTypical; + public Optional fixedMax; + public Optional fixedMin; + public Optional fixedTypical; + private static final long RANGE_MIN_ID = 0L; + private static final long RANGE_MAX_ID = 1L; + private static final long PERCENT_MAX_ID = 2L; + private static final long PERCENT_MIN_ID = 3L; + private static final long PERCENT_TYPICAL_ID = 4L; + private static final long FIXED_MAX_ID = 5L; + private static final long FIXED_MIN_ID = 6L; + private static final long FIXED_TYPICAL_ID = 7L; + + public ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct( + Long rangeMin, + Long rangeMax, + Optional percentMax, + Optional percentMin, + Optional percentTypical, + Optional fixedMax, + Optional fixedMin, + Optional fixedTypical + ) { + this.rangeMin = rangeMin; + this.rangeMax = rangeMax; + this.percentMax = percentMax; + this.percentMin = percentMin; + this.percentTypical = percentTypical; + this.fixedMax = fixedMax; + this.fixedMin = fixedMin; + this.fixedTypical = fixedTypical; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(RANGE_MIN_ID, new IntType(rangeMin))); + values.add(new StructElement(RANGE_MAX_ID, new IntType(rangeMax))); + values.add(new StructElement(PERCENT_MAX_ID, percentMax.map((nonOptionalpercentMax) -> new UIntType(nonOptionalpercentMax)).orElse(new EmptyType()))); + values.add(new StructElement(PERCENT_MIN_ID, percentMin.map((nonOptionalpercentMin) -> new UIntType(nonOptionalpercentMin)).orElse(new EmptyType()))); + values.add(new StructElement(PERCENT_TYPICAL_ID, percentTypical.map((nonOptionalpercentTypical) -> new UIntType(nonOptionalpercentTypical)).orElse(new EmptyType()))); + values.add(new StructElement(FIXED_MAX_ID, fixedMax.map((nonOptionalfixedMax) -> new UIntType(nonOptionalfixedMax)).orElse(new EmptyType()))); + values.add(new StructElement(FIXED_MIN_ID, fixedMin.map((nonOptionalfixedMin) -> new UIntType(nonOptionalfixedMin)).orElse(new EmptyType()))); + values.add(new StructElement(FIXED_TYPICAL_ID, fixedTypical.map((nonOptionalfixedTypical) -> new UIntType(nonOptionalfixedTypical)).orElse(new EmptyType()))); + + return new StructType(values); + } + + public static ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + Long rangeMin = null; + Long rangeMax = null; + Optional percentMax = Optional.empty(); + Optional percentMin = Optional.empty(); + Optional percentTypical = Optional.empty(); + Optional fixedMax = Optional.empty(); + Optional fixedMin = Optional.empty(); + Optional fixedTypical = Optional.empty(); + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == RANGE_MIN_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Int) { + IntType castingValue = element.value(IntType.class); + rangeMin = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == RANGE_MAX_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Int) { + IntType castingValue = element.value(IntType.class); + rangeMax = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == PERCENT_MAX_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + percentMax = Optional.of(castingValue.value(Integer.class)); + } + } else if (element.contextTagNum() == PERCENT_MIN_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + percentMin = Optional.of(castingValue.value(Integer.class)); + } + } else if (element.contextTagNum() == PERCENT_TYPICAL_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + percentTypical = Optional.of(castingValue.value(Integer.class)); + } + } else if (element.contextTagNum() == FIXED_MAX_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + fixedMax = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == FIXED_MIN_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + fixedMin = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == FIXED_TYPICAL_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + fixedTypical = Optional.of(castingValue.value(Long.class)); + } + } + } + return new ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct( + rangeMin, + rangeMax, + percentMax, + percentMin, + percentTypical, + fixedMax, + fixedMin, + fixedTypical + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct {\n"); + output.append("\trangeMin: "); + output.append(rangeMin); + output.append("\n"); + output.append("\trangeMax: "); + output.append(rangeMax); + output.append("\n"); + output.append("\tpercentMax: "); + output.append(percentMax); + output.append("\n"); + output.append("\tpercentMin: "); + output.append(percentMin); + output.append("\n"); + output.append("\tpercentTypical: "); + output.append(percentTypical); + output.append("\n"); + output.append("\tfixedMax: "); + output.append(fixedMax); + output.append("\n"); + output.append("\tfixedMin: "); + output.append(fixedMin); + output.append("\n"); + output.append("\tfixedTypical: "); + output.append(fixedTypical); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} +public static class ElectricalPowerMeasurementClusterMeasurementAccuracyStruct { + public Integer measurementType; + public Boolean measured; + public Long minMeasuredValue; + public Long maxMeasuredValue; + public ArrayList accuracyRanges; + private static final long MEASUREMENT_TYPE_ID = 0L; + private static final long MEASURED_ID = 1L; + private static final long MIN_MEASURED_VALUE_ID = 2L; + private static final long MAX_MEASURED_VALUE_ID = 3L; + private static final long ACCURACY_RANGES_ID = 4L; + + public ElectricalPowerMeasurementClusterMeasurementAccuracyStruct( + Integer measurementType, + Boolean measured, + Long minMeasuredValue, + Long maxMeasuredValue, + ArrayList accuracyRanges + ) { + this.measurementType = measurementType; + this.measured = measured; + this.minMeasuredValue = minMeasuredValue; + this.maxMeasuredValue = maxMeasuredValue; + this.accuracyRanges = accuracyRanges; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(MEASUREMENT_TYPE_ID, new UIntType(measurementType))); + values.add(new StructElement(MEASURED_ID, new BooleanType(measured))); + values.add(new StructElement(MIN_MEASURED_VALUE_ID, new IntType(minMeasuredValue))); + values.add(new StructElement(MAX_MEASURED_VALUE_ID, new IntType(maxMeasuredValue))); + values.add(new StructElement(ACCURACY_RANGES_ID, ArrayType.generateArrayType(accuracyRanges, (elementaccuracyRanges) -> elementaccuracyRanges.encodeTlv()))); + + return new StructType(values); + } + + public static ElectricalPowerMeasurementClusterMeasurementAccuracyStruct decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + Integer measurementType = null; + Boolean measured = null; + Long minMeasuredValue = null; + Long maxMeasuredValue = null; + ArrayList accuracyRanges = null; + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == MEASUREMENT_TYPE_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + measurementType = castingValue.value(Integer.class); + } + } else if (element.contextTagNum() == MEASURED_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Boolean) { + BooleanType castingValue = element.value(BooleanType.class); + measured = castingValue.value(Boolean.class); + } + } else if (element.contextTagNum() == MIN_MEASURED_VALUE_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Int) { + IntType castingValue = element.value(IntType.class); + minMeasuredValue = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == MAX_MEASURED_VALUE_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Int) { + IntType castingValue = element.value(IntType.class); + maxMeasuredValue = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == ACCURACY_RANGES_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Array) { + ArrayType castingValue = element.value(ArrayType.class); + accuracyRanges = castingValue.map((elementcastingValue) -> ChipStructs.ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.decodeTlv(elementcastingValue)); + } + } + } + return new ElectricalPowerMeasurementClusterMeasurementAccuracyStruct( + measurementType, + measured, + minMeasuredValue, + maxMeasuredValue, + accuracyRanges + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("ElectricalPowerMeasurementClusterMeasurementAccuracyStruct {\n"); + output.append("\tmeasurementType: "); + output.append(measurementType); + output.append("\n"); + output.append("\tmeasured: "); + output.append(measured); + output.append("\n"); + output.append("\tminMeasuredValue: "); + output.append(minMeasuredValue); + output.append("\n"); + output.append("\tmaxMeasuredValue: "); + output.append(maxMeasuredValue); + output.append("\n"); + output.append("\taccuracyRanges: "); + output.append(accuracyRanges); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} +public static class ElectricalPowerMeasurementClusterHarmonicMeasurementStruct { + public Integer order; + public @Nullable Long measurement; + private static final long ORDER_ID = 0L; + private static final long MEASUREMENT_ID = 1L; + + public ElectricalPowerMeasurementClusterHarmonicMeasurementStruct( + Integer order, + @Nullable Long measurement + ) { + this.order = order; + this.measurement = measurement; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(ORDER_ID, new UIntType(order))); + values.add(new StructElement(MEASUREMENT_ID, measurement != null ? new IntType(measurement) : new NullType())); + + return new StructType(values); + } + + public static ElectricalPowerMeasurementClusterHarmonicMeasurementStruct decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + Integer order = null; + @Nullable Long measurement = null; + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == ORDER_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + order = castingValue.value(Integer.class); + } + } else if (element.contextTagNum() == MEASUREMENT_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Int) { + IntType castingValue = element.value(IntType.class); + measurement = castingValue.value(Long.class); + } + } + } + return new ElectricalPowerMeasurementClusterHarmonicMeasurementStruct( + order, + measurement + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("ElectricalPowerMeasurementClusterHarmonicMeasurementStruct {\n"); + output.append("\torder: "); + output.append(order); + output.append("\n"); + output.append("\tmeasurement: "); + output.append(measurement); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} +public static class ElectricalPowerMeasurementClusterMeasurementRangeStruct { + public Integer measurementType; + public Long min; + public Long max; + public Optional startTimestamp; + public Optional endTimestamp; + public Optional minTimestamp; + public Optional maxTimestamp; + public Optional startSystime; + public Optional endSystime; + public Optional minSystime; + public Optional maxSystime; + private static final long MEASUREMENT_TYPE_ID = 0L; + private static final long MIN_ID = 1L; + private static final long MAX_ID = 2L; + private static final long START_TIMESTAMP_ID = 3L; + private static final long END_TIMESTAMP_ID = 4L; + private static final long MIN_TIMESTAMP_ID = 5L; + private static final long MAX_TIMESTAMP_ID = 6L; + private static final long START_SYSTIME_ID = 7L; + private static final long END_SYSTIME_ID = 8L; + private static final long MIN_SYSTIME_ID = 9L; + private static final long MAX_SYSTIME_ID = 10L; + + public ElectricalPowerMeasurementClusterMeasurementRangeStruct( + Integer measurementType, + Long min, + Long max, + Optional startTimestamp, + Optional endTimestamp, + Optional minTimestamp, + Optional maxTimestamp, + Optional startSystime, + Optional endSystime, + Optional minSystime, + Optional maxSystime + ) { + this.measurementType = measurementType; + this.min = min; + this.max = max; + this.startTimestamp = startTimestamp; + this.endTimestamp = endTimestamp; + this.minTimestamp = minTimestamp; + this.maxTimestamp = maxTimestamp; + this.startSystime = startSystime; + this.endSystime = endSystime; + this.minSystime = minSystime; + this.maxSystime = maxSystime; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(MEASUREMENT_TYPE_ID, new UIntType(measurementType))); + values.add(new StructElement(MIN_ID, new IntType(min))); + values.add(new StructElement(MAX_ID, new IntType(max))); + values.add(new StructElement(START_TIMESTAMP_ID, startTimestamp.map((nonOptionalstartTimestamp) -> new UIntType(nonOptionalstartTimestamp)).orElse(new EmptyType()))); + values.add(new StructElement(END_TIMESTAMP_ID, endTimestamp.map((nonOptionalendTimestamp) -> new UIntType(nonOptionalendTimestamp)).orElse(new EmptyType()))); + values.add(new StructElement(MIN_TIMESTAMP_ID, minTimestamp.map((nonOptionalminTimestamp) -> new UIntType(nonOptionalminTimestamp)).orElse(new EmptyType()))); + values.add(new StructElement(MAX_TIMESTAMP_ID, maxTimestamp.map((nonOptionalmaxTimestamp) -> new UIntType(nonOptionalmaxTimestamp)).orElse(new EmptyType()))); + values.add(new StructElement(START_SYSTIME_ID, startSystime.map((nonOptionalstartSystime) -> new UIntType(nonOptionalstartSystime)).orElse(new EmptyType()))); + values.add(new StructElement(END_SYSTIME_ID, endSystime.map((nonOptionalendSystime) -> new UIntType(nonOptionalendSystime)).orElse(new EmptyType()))); + values.add(new StructElement(MIN_SYSTIME_ID, minSystime.map((nonOptionalminSystime) -> new UIntType(nonOptionalminSystime)).orElse(new EmptyType()))); + values.add(new StructElement(MAX_SYSTIME_ID, maxSystime.map((nonOptionalmaxSystime) -> new UIntType(nonOptionalmaxSystime)).orElse(new EmptyType()))); + + return new StructType(values); + } + + public static ElectricalPowerMeasurementClusterMeasurementRangeStruct decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + Integer measurementType = null; + Long min = null; + Long max = null; + Optional startTimestamp = Optional.empty(); + Optional endTimestamp = Optional.empty(); + Optional minTimestamp = Optional.empty(); + Optional maxTimestamp = Optional.empty(); + Optional startSystime = Optional.empty(); + Optional endSystime = Optional.empty(); + Optional minSystime = Optional.empty(); + Optional maxSystime = Optional.empty(); + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == MEASUREMENT_TYPE_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + measurementType = castingValue.value(Integer.class); + } + } else if (element.contextTagNum() == MIN_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Int) { + IntType castingValue = element.value(IntType.class); + min = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == MAX_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Int) { + IntType castingValue = element.value(IntType.class); + max = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == START_TIMESTAMP_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + startTimestamp = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == END_TIMESTAMP_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + endTimestamp = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == MIN_TIMESTAMP_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + minTimestamp = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == MAX_TIMESTAMP_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + maxTimestamp = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == START_SYSTIME_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + startSystime = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == END_SYSTIME_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + endSystime = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == MIN_SYSTIME_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + minSystime = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == MAX_SYSTIME_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + maxSystime = Optional.of(castingValue.value(Long.class)); + } + } + } + return new ElectricalPowerMeasurementClusterMeasurementRangeStruct( + measurementType, + min, + max, + startTimestamp, + endTimestamp, + minTimestamp, + maxTimestamp, + startSystime, + endSystime, + minSystime, + maxSystime + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("ElectricalPowerMeasurementClusterMeasurementRangeStruct {\n"); + output.append("\tmeasurementType: "); + output.append(measurementType); + output.append("\n"); + output.append("\tmin: "); + output.append(min); + output.append("\n"); + output.append("\tmax: "); + output.append(max); + output.append("\n"); + output.append("\tstartTimestamp: "); + output.append(startTimestamp); + output.append("\n"); + output.append("\tendTimestamp: "); + output.append(endTimestamp); + output.append("\n"); + output.append("\tminTimestamp: "); + output.append(minTimestamp); + output.append("\n"); + output.append("\tmaxTimestamp: "); + output.append(maxTimestamp); + output.append("\n"); + output.append("\tstartSystime: "); + output.append(startSystime); + output.append("\n"); + output.append("\tendSystime: "); + output.append(endSystime); + output.append("\n"); + output.append("\tminSystime: "); + output.append(minSystime); + output.append("\n"); + output.append("\tmaxSystime: "); + output.append(maxSystime); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} public static class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { public Long rangeMin; public Long rangeMax; @@ -5685,6 +6199,97 @@ public String toString() { return output.toString(); } } +public static class ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct { + public @Nullable Optional importedResetTimestamp; + public @Nullable Optional exportedResetTimestamp; + public @Nullable Optional importedResetSystime; + public @Nullable Optional exportedResetSystime; + private static final long IMPORTED_RESET_TIMESTAMP_ID = 0L; + private static final long EXPORTED_RESET_TIMESTAMP_ID = 1L; + private static final long IMPORTED_RESET_SYSTIME_ID = 2L; + private static final long EXPORTED_RESET_SYSTIME_ID = 3L; + + public ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct( + @Nullable Optional importedResetTimestamp, + @Nullable Optional exportedResetTimestamp, + @Nullable Optional importedResetSystime, + @Nullable Optional exportedResetSystime + ) { + this.importedResetTimestamp = importedResetTimestamp; + this.exportedResetTimestamp = exportedResetTimestamp; + this.importedResetSystime = importedResetSystime; + this.exportedResetSystime = exportedResetSystime; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(IMPORTED_RESET_TIMESTAMP_ID, importedResetTimestamp != null ? importedResetTimestamp.map((nonOptionalimportedResetTimestamp) -> new UIntType(nonOptionalimportedResetTimestamp)).orElse(new EmptyType()) : new NullType())); + values.add(new StructElement(EXPORTED_RESET_TIMESTAMP_ID, exportedResetTimestamp != null ? exportedResetTimestamp.map((nonOptionalexportedResetTimestamp) -> new UIntType(nonOptionalexportedResetTimestamp)).orElse(new EmptyType()) : new NullType())); + values.add(new StructElement(IMPORTED_RESET_SYSTIME_ID, importedResetSystime != null ? importedResetSystime.map((nonOptionalimportedResetSystime) -> new UIntType(nonOptionalimportedResetSystime)).orElse(new EmptyType()) : new NullType())); + values.add(new StructElement(EXPORTED_RESET_SYSTIME_ID, exportedResetSystime != null ? exportedResetSystime.map((nonOptionalexportedResetSystime) -> new UIntType(nonOptionalexportedResetSystime)).orElse(new EmptyType()) : new NullType())); + + return new StructType(values); + } + + public static ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + @Nullable Optional importedResetTimestamp = null; + @Nullable Optional exportedResetTimestamp = null; + @Nullable Optional importedResetSystime = null; + @Nullable Optional exportedResetSystime = null; + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == IMPORTED_RESET_TIMESTAMP_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + importedResetTimestamp = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == EXPORTED_RESET_TIMESTAMP_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + exportedResetTimestamp = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == IMPORTED_RESET_SYSTIME_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + importedResetSystime = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == EXPORTED_RESET_SYSTIME_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + exportedResetSystime = Optional.of(castingValue.value(Long.class)); + } + } + } + return new ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct( + importedResetTimestamp, + exportedResetTimestamp, + importedResetSystime, + exportedResetSystime + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct {\n"); + output.append("\timportedResetTimestamp: "); + output.append(importedResetTimestamp); + output.append("\n"); + output.append("\texportedResetTimestamp: "); + output.append(exportedResetTimestamp); + output.append("\n"); + output.append("\timportedResetSystime: "); + output.append(importedResetSystime); + output.append("\n"); + output.append("\texportedResetSystime: "); + output.append(exportedResetSystime); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} public static class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { public Long energy; public Optional startTimestamp; diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java index 43e246a70b6d81..a1d43e3a7933a5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java @@ -223,6 +223,9 @@ public static BaseCluster getCluster(long clusterId) { if (clusterId == ValveConfigurationAndControl.ID) { return new ValveConfigurationAndControl(); } + if (clusterId == ElectricalPowerMeasurement.ID) { + return new ElectricalPowerMeasurement(); + } if (clusterId == ElectricalEnergyMeasurement.ID) { return new ElectricalEnergyMeasurement(); } @@ -241,6 +244,9 @@ public static BaseCluster getCluster(long clusterId) { if (clusterId == EnergyPreference.ID) { return new EnergyPreference(); } + if (clusterId == PowerTopology.ID) { + return new PowerTopology(); + } if (clusterId == EnergyEvseMode.ID) { return new EnergyEvseMode(); } @@ -3586,7 +3592,8 @@ public static Event value(long id) throws NoSuchFieldError { public enum Command { TestEventTrigger(0L), - TimeSnapshot(1L),; + TimeSnapshot(1L), + PayloadTestRequest(3L),; private final long id; Command(long id) { this.id = id; @@ -3621,6 +3628,23 @@ public static TestEventTriggerCommandField value(int id) throws NoSuchFieldError } throw new NoSuchFieldError(); } + }public enum PayloadTestRequestCommandField {EnableKey(0),Value(1),Count(2),; + private final int id; + PayloadTestRequestCommandField(int id) { + this.id = id; + } + + public int getID() { + return id; + } + public static PayloadTestRequestCommandField value(int id) throws NoSuchFieldError { + for (PayloadTestRequestCommandField field : PayloadTestRequestCommandField.values()) { + if (field.getID() == id) { + return field; + } + } + throw new NoSuchFieldError(); + } }@Override public String getAttributeName(long id) throws NoSuchFieldError { return Attribute.value(id).toString(); @@ -9019,6 +9043,126 @@ public long getCommandID(String name) throws IllegalArgumentException { return Command.valueOf(name).getID(); } } + public static class ElectricalPowerMeasurement implements BaseCluster { + public static final long ID = 144L; + public long getID() { + return ID; + } + + public enum Attribute { + PowerMode(0L), + NumberOfMeasurementTypes(1L), + Accuracy(2L), + Ranges(3L), + Voltage(4L), + ActiveCurrent(5L), + ReactiveCurrent(6L), + ApparentCurrent(7L), + ActivePower(8L), + ReactivePower(9L), + ApparentPower(10L), + RMSVoltage(11L), + RMSCurrent(12L), + RMSPower(13L), + Frequency(14L), + HarmonicCurrents(15L), + HarmonicPhases(16L), + PowerFactor(17L), + NeutralCurrent(18L), + GeneratedCommandList(65528L), + AcceptedCommandList(65529L), + EventList(65530L), + AttributeList(65531L), + FeatureMap(65532L), + ClusterRevision(65533L),; + private final long id; + Attribute(long id) { + this.id = id; + } + + public long getID() { + return id; + } + + public static Attribute value(long id) throws NoSuchFieldError { + for (Attribute attribute : Attribute.values()) { + if (attribute.getID() == id) { + return attribute; + } + } + throw new NoSuchFieldError(); + } + } + + public enum Event { + MeasurementPeriodRanges(0L),; + private final long id; + Event(long id) { + this.id = id; + } + + public long getID() { + return id; + } + + public static Event value(long id) throws NoSuchFieldError { + for (Event event : Event.values()) { + if (event.getID() == id) { + return event; + } + } + throw new NoSuchFieldError(); + } + } + + public enum Command {; + private final long id; + Command(long id) { + this.id = id; + } + + public long getID() { + return id; + } + + public static Command value(long id) throws NoSuchFieldError { + for (Command command : Command.values()) { + if (command.getID() == id) { + return command; + } + } + throw new NoSuchFieldError(); + } + }@Override + public String getAttributeName(long id) throws NoSuchFieldError { + return Attribute.value(id).toString(); + } + + @Override + public String getEventName(long id) throws NoSuchFieldError { + return Event.value(id).toString(); + } + + @Override + public String getCommandName(long id) throws NoSuchFieldError { + return Command.value(id).toString(); + } + + @Override + public long getAttributeID(String name) throws IllegalArgumentException { + return Attribute.valueOf(name).getID(); + } + + @Override + public long getEventID(String name) throws IllegalArgumentException { + return Event.valueOf(name).getID(); + } + + @Override + public long getCommandID(String name) throws IllegalArgumentException { + return Command.valueOf(name).getID(); + } + } public static class ElectricalEnergyMeasurement implements BaseCluster { public static final long ID = 145L; public long getID() { @@ -9031,6 +9175,7 @@ public enum Attribute { CumulativeEnergyExported(2L), PeriodicEnergyImported(3L), PeriodicEnergyExported(4L), + CumulativeEnergyReset(5L), GeneratedCommandList(65528L), AcceptedCommandList(65529L), EventList(65530L), @@ -9946,6 +10091,108 @@ public long getCommandID(String name) throws IllegalArgumentException { return Command.valueOf(name).getID(); } } + public static class PowerTopology implements BaseCluster { + public static final long ID = 156L; + public long getID() { + return ID; + } + + public enum Attribute { + AvailableEndpoints(0L), + ActiveEndpoints(1L), + GeneratedCommandList(65528L), + AcceptedCommandList(65529L), + EventList(65530L), + AttributeList(65531L), + FeatureMap(65532L), + ClusterRevision(65533L),; + private final long id; + Attribute(long id) { + this.id = id; + } + + public long getID() { + return id; + } + + public static Attribute value(long id) throws NoSuchFieldError { + for (Attribute attribute : Attribute.values()) { + if (attribute.getID() == id) { + return attribute; + } + } + throw new NoSuchFieldError(); + } + } + + public enum Event {; + private final long id; + Event(long id) { + this.id = id; + } + + public long getID() { + return id; + } + + public static Event value(long id) throws NoSuchFieldError { + for (Event event : Event.values()) { + if (event.getID() == id) { + return event; + } + } + throw new NoSuchFieldError(); + } + } + + public enum Command {; + private final long id; + Command(long id) { + this.id = id; + } + + public long getID() { + return id; + } + + public static Command value(long id) throws NoSuchFieldError { + for (Command command : Command.values()) { + if (command.getID() == id) { + return command; + } + } + throw new NoSuchFieldError(); + } + }@Override + public String getAttributeName(long id) throws NoSuchFieldError { + return Attribute.value(id).toString(); + } + + @Override + public String getEventName(long id) throws NoSuchFieldError { + return Event.value(id).toString(); + } + + @Override + public String getCommandName(long id) throws NoSuchFieldError { + return Command.value(id).toString(); + } + + @Override + public long getAttributeID(String name) throws IllegalArgumentException { + return Attribute.valueOf(name).getID(); + } + + @Override + public long getEventID(String name) throws IllegalArgumentException { + return Event.valueOf(name).getID(); + } + + @Override + public long getCommandID(String name) throws IllegalArgumentException { + return Command.valueOf(name).getID(); + } + } public static class EnergyEvseMode implements BaseCluster { public static final long ID = 157L; public long getID() { diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java index 837e6e72bd193c..14b4a97284f173 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java @@ -3336,6 +3336,28 @@ public void onError(Exception error) { callback.onFailure(error); } } + + public static class DelegatedGeneralDiagnosticsClusterPayloadTestResponseCallback implements ChipClusters.GeneralDiagnosticsCluster.PayloadTestResponseCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(byte[] payload) { + Map responseValues = new LinkedHashMap<>(); + + CommandResponseInfo payloadResponseValue = new CommandResponseInfo("payload", "byte[]"); + responseValues.put(payloadResponseValue, payload); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception error) { + callback.onFailure(error); + } + } public static class DelegatedGeneralDiagnosticsClusterNetworkInterfacesAttributeCallback implements ChipClusters.GeneralDiagnosticsCluster.NetworkInterfacesAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override @@ -9403,7 +9425,448 @@ public void onError(Exception ex) { } } - public static class DelegatedHepaFilterMonitoringClusterAcceptedCommandListAttributeCallback implements ChipClusters.HepaFilterMonitoringCluster.AcceptedCommandListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedHepaFilterMonitoringClusterAcceptedCommandListAttributeCallback implements ChipClusters.HepaFilterMonitoringCluster.AcceptedCommandListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedHepaFilterMonitoringClusterEventListAttributeCallback implements ChipClusters.HepaFilterMonitoringCluster.EventListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedHepaFilterMonitoringClusterAttributeListAttributeCallback implements ChipClusters.HepaFilterMonitoringCluster.AttributeListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedActivatedCarbonFilterMonitoringClusterLastChangedTimeAttributeCallback implements ChipClusters.ActivatedCarbonFilterMonitoringCluster.LastChangedTimeAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Long value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedActivatedCarbonFilterMonitoringClusterReplacementProductListAttributeCallback implements ChipClusters.ActivatedCarbonFilterMonitoringCluster.ReplacementProductListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedActivatedCarbonFilterMonitoringClusterGeneratedCommandListAttributeCallback implements ChipClusters.ActivatedCarbonFilterMonitoringCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedActivatedCarbonFilterMonitoringClusterAcceptedCommandListAttributeCallback implements ChipClusters.ActivatedCarbonFilterMonitoringCluster.AcceptedCommandListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedActivatedCarbonFilterMonitoringClusterEventListAttributeCallback implements ChipClusters.ActivatedCarbonFilterMonitoringCluster.EventListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedActivatedCarbonFilterMonitoringClusterAttributeListAttributeCallback implements ChipClusters.ActivatedCarbonFilterMonitoringCluster.AttributeListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedBooleanStateConfigurationClusterGeneratedCommandListAttributeCallback implements ChipClusters.BooleanStateConfigurationCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedBooleanStateConfigurationClusterAcceptedCommandListAttributeCallback implements ChipClusters.BooleanStateConfigurationCluster.AcceptedCommandListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedBooleanStateConfigurationClusterEventListAttributeCallback implements ChipClusters.BooleanStateConfigurationCluster.EventListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedBooleanStateConfigurationClusterAttributeListAttributeCallback implements ChipClusters.BooleanStateConfigurationCluster.AttributeListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedValveConfigurationAndControlClusterOpenDurationAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.OpenDurationAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Long value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedValveConfigurationAndControlClusterDefaultOpenDurationAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.DefaultOpenDurationAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Long value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedValveConfigurationAndControlClusterAutoCloseTimeAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.AutoCloseTimeAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Long value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedValveConfigurationAndControlClusterRemainingDurationAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.RemainingDurationAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Long value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedValveConfigurationAndControlClusterCurrentStateAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.CurrentStateAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Integer value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Integer"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedValveConfigurationAndControlClusterTargetStateAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.TargetStateAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Integer value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Integer"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedValveConfigurationAndControlClusterCurrentLevelAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.CurrentLevelAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Integer value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Integer"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedValveConfigurationAndControlClusterTargetLevelAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.TargetLevelAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Integer value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Integer"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedValveConfigurationAndControlClusterGeneratedCommandListAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9424,7 +9887,7 @@ public void onError(Exception ex) { } } - public static class DelegatedHepaFilterMonitoringClusterEventListAttributeCallback implements ChipClusters.HepaFilterMonitoringCluster.EventListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedValveConfigurationAndControlClusterAcceptedCommandListAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.AcceptedCommandListAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9445,7 +9908,7 @@ public void onError(Exception ex) { } } - public static class DelegatedHepaFilterMonitoringClusterAttributeListAttributeCallback implements ChipClusters.HepaFilterMonitoringCluster.AttributeListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedValveConfigurationAndControlClusterEventListAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.EventListAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9466,7 +9929,7 @@ public void onError(Exception ex) { } } - public static class DelegatedActivatedCarbonFilterMonitoringClusterLastChangedTimeAttributeCallback implements ChipClusters.ActivatedCarbonFilterMonitoringCluster.LastChangedTimeAttributeCallback, DelegatedClusterCallback { + public static class DelegatedValveConfigurationAndControlClusterAttributeListAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.AttributeListAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9474,10 +9937,10 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(@Nullable Long value) { + public void onSuccess(List valueList) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); - responseValues.put(commandResponseInfo, value); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); callback.onSuccess(responseValues); } @@ -9487,7 +9950,7 @@ public void onError(Exception ex) { } } - public static class DelegatedActivatedCarbonFilterMonitoringClusterReplacementProductListAttributeCallback implements ChipClusters.ActivatedCarbonFilterMonitoringCluster.ReplacementProductListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterAccuracyAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.AccuracyAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9495,9 +9958,9 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(List valueList) { + public void onSuccess(List valueList) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); responseValues.put(commandResponseInfo, valueList); callback.onSuccess(responseValues); } @@ -9508,7 +9971,7 @@ public void onError(Exception ex) { } } - public static class DelegatedActivatedCarbonFilterMonitoringClusterGeneratedCommandListAttributeCallback implements ChipClusters.ActivatedCarbonFilterMonitoringCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterRangesAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.RangesAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9516,9 +9979,9 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(List valueList) { + public void onSuccess(List valueList) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); responseValues.put(commandResponseInfo, valueList); callback.onSuccess(responseValues); } @@ -9529,7 +9992,7 @@ public void onError(Exception ex) { } } - public static class DelegatedActivatedCarbonFilterMonitoringClusterAcceptedCommandListAttributeCallback implements ChipClusters.ActivatedCarbonFilterMonitoringCluster.AcceptedCommandListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterVoltageAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.VoltageAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9537,10 +10000,10 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(List valueList) { + public void onSuccess(@Nullable Long value) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); - responseValues.put(commandResponseInfo, valueList); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); callback.onSuccess(responseValues); } @@ -9550,7 +10013,7 @@ public void onError(Exception ex) { } } - public static class DelegatedActivatedCarbonFilterMonitoringClusterEventListAttributeCallback implements ChipClusters.ActivatedCarbonFilterMonitoringCluster.EventListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterActiveCurrentAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.ActiveCurrentAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9558,10 +10021,10 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(List valueList) { + public void onSuccess(@Nullable Long value) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); - responseValues.put(commandResponseInfo, valueList); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); callback.onSuccess(responseValues); } @@ -9571,7 +10034,7 @@ public void onError(Exception ex) { } } - public static class DelegatedActivatedCarbonFilterMonitoringClusterAttributeListAttributeCallback implements ChipClusters.ActivatedCarbonFilterMonitoringCluster.AttributeListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterReactiveCurrentAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.ReactiveCurrentAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9579,10 +10042,10 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(List valueList) { + public void onSuccess(@Nullable Long value) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); - responseValues.put(commandResponseInfo, valueList); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); callback.onSuccess(responseValues); } @@ -9592,7 +10055,7 @@ public void onError(Exception ex) { } } - public static class DelegatedBooleanStateConfigurationClusterGeneratedCommandListAttributeCallback implements ChipClusters.BooleanStateConfigurationCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterApparentCurrentAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.ApparentCurrentAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9600,10 +10063,10 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(List valueList) { + public void onSuccess(@Nullable Long value) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); - responseValues.put(commandResponseInfo, valueList); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); callback.onSuccess(responseValues); } @@ -9613,7 +10076,7 @@ public void onError(Exception ex) { } } - public static class DelegatedBooleanStateConfigurationClusterAcceptedCommandListAttributeCallback implements ChipClusters.BooleanStateConfigurationCluster.AcceptedCommandListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterActivePowerAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.ActivePowerAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9621,10 +10084,10 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(List valueList) { + public void onSuccess(@Nullable Long value) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); - responseValues.put(commandResponseInfo, valueList); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); callback.onSuccess(responseValues); } @@ -9634,7 +10097,7 @@ public void onError(Exception ex) { } } - public static class DelegatedBooleanStateConfigurationClusterEventListAttributeCallback implements ChipClusters.BooleanStateConfigurationCluster.EventListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterReactivePowerAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.ReactivePowerAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9642,10 +10105,10 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(List valueList) { + public void onSuccess(@Nullable Long value) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); - responseValues.put(commandResponseInfo, valueList); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); callback.onSuccess(responseValues); } @@ -9655,7 +10118,7 @@ public void onError(Exception ex) { } } - public static class DelegatedBooleanStateConfigurationClusterAttributeListAttributeCallback implements ChipClusters.BooleanStateConfigurationCluster.AttributeListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterApparentPowerAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.ApparentPowerAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9663,10 +10126,10 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(List valueList) { + public void onSuccess(@Nullable Long value) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); - responseValues.put(commandResponseInfo, valueList); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); callback.onSuccess(responseValues); } @@ -9676,7 +10139,7 @@ public void onError(Exception ex) { } } - public static class DelegatedValveConfigurationAndControlClusterOpenDurationAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.OpenDurationAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterRMSVoltageAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.RMSVoltageAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9697,7 +10160,7 @@ public void onError(Exception ex) { } } - public static class DelegatedValveConfigurationAndControlClusterDefaultOpenDurationAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.DefaultOpenDurationAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterRMSCurrentAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.RMSCurrentAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9718,7 +10181,7 @@ public void onError(Exception ex) { } } - public static class DelegatedValveConfigurationAndControlClusterAutoCloseTimeAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.AutoCloseTimeAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterRMSPowerAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.RMSPowerAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9739,7 +10202,7 @@ public void onError(Exception ex) { } } - public static class DelegatedValveConfigurationAndControlClusterRemainingDurationAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.RemainingDurationAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterFrequencyAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.FrequencyAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9760,7 +10223,7 @@ public void onError(Exception ex) { } } - public static class DelegatedValveConfigurationAndControlClusterCurrentStateAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.CurrentStateAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterHarmonicCurrentsAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.HarmonicCurrentsAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9768,10 +10231,10 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(@Nullable Integer value) { + public void onSuccess(@Nullable List valueList) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Integer"); - responseValues.put(commandResponseInfo, value); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); callback.onSuccess(responseValues); } @@ -9781,7 +10244,7 @@ public void onError(Exception ex) { } } - public static class DelegatedValveConfigurationAndControlClusterTargetStateAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.TargetStateAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterHarmonicPhasesAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.HarmonicPhasesAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9789,10 +10252,10 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(@Nullable Integer value) { + public void onSuccess(@Nullable List valueList) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Integer"); - responseValues.put(commandResponseInfo, value); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); callback.onSuccess(responseValues); } @@ -9802,7 +10265,7 @@ public void onError(Exception ex) { } } - public static class DelegatedValveConfigurationAndControlClusterCurrentLevelAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.CurrentLevelAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterPowerFactorAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.PowerFactorAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9810,9 +10273,9 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(@Nullable Integer value) { + public void onSuccess(@Nullable Long value) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Integer"); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); responseValues.put(commandResponseInfo, value); callback.onSuccess(responseValues); } @@ -9823,7 +10286,7 @@ public void onError(Exception ex) { } } - public static class DelegatedValveConfigurationAndControlClusterTargetLevelAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.TargetLevelAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterNeutralCurrentAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.NeutralCurrentAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9831,9 +10294,9 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(@Nullable Integer value) { + public void onSuccess(@Nullable Long value) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Integer"); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); responseValues.put(commandResponseInfo, value); callback.onSuccess(responseValues); } @@ -9844,7 +10307,7 @@ public void onError(Exception ex) { } } - public static class DelegatedValveConfigurationAndControlClusterGeneratedCommandListAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterGeneratedCommandListAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9865,7 +10328,7 @@ public void onError(Exception ex) { } } - public static class DelegatedValveConfigurationAndControlClusterAcceptedCommandListAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.AcceptedCommandListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterAcceptedCommandListAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.AcceptedCommandListAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9886,7 +10349,7 @@ public void onError(Exception ex) { } } - public static class DelegatedValveConfigurationAndControlClusterEventListAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.EventListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterEventListAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.EventListAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -9907,7 +10370,7 @@ public void onError(Exception ex) { } } - public static class DelegatedValveConfigurationAndControlClusterAttributeListAttributeCallback implements ChipClusters.ValveConfigurationAndControlCluster.AttributeListAttributeCallback, DelegatedClusterCallback { + public static class DelegatedElectricalPowerMeasurementClusterAttributeListAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.AttributeListAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override public void setCallbackDelegate(ClusterCommandCallback callback) { @@ -10033,6 +10496,27 @@ public void onError(Exception ex) { } } + public static class DelegatedElectricalEnergyMeasurementClusterCumulativeEnergyResetAttributeCallback implements ChipClusters.ElectricalEnergyMeasurementCluster.CumulativeEnergyResetAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "ChipStructs.ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + public static class DelegatedElectricalEnergyMeasurementClusterGeneratedCommandListAttributeCallback implements ChipClusters.ElectricalEnergyMeasurementCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override @@ -11085,6 +11569,132 @@ public void onError(Exception ex) { } } + public static class DelegatedPowerTopologyClusterAvailableEndpointsAttributeCallback implements ChipClusters.PowerTopologyCluster.AvailableEndpointsAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedPowerTopologyClusterActiveEndpointsAttributeCallback implements ChipClusters.PowerTopologyCluster.ActiveEndpointsAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedPowerTopologyClusterGeneratedCommandListAttributeCallback implements ChipClusters.PowerTopologyCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedPowerTopologyClusterAcceptedCommandListAttributeCallback implements ChipClusters.PowerTopologyCluster.AcceptedCommandListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedPowerTopologyClusterEventListAttributeCallback implements ChipClusters.PowerTopologyCluster.EventListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedPowerTopologyClusterAttributeListAttributeCallback implements ChipClusters.PowerTopologyCluster.AttributeListAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + public static class DelegatedEnergyEvseModeClusterChangeToModeResponseCallback implements ChipClusters.EnergyEvseModeCluster.ChangeToModeResponseCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @@ -20427,6 +21037,10 @@ public Map initializeClusterMap() { (ptr, endpointId) -> new ChipClusters.ValveConfigurationAndControlCluster(ptr, endpointId), new HashMap<>()); clusterMap.put("valveConfigurationAndControl", valveConfigurationAndControlClusterInfo); + ClusterInfo electricalPowerMeasurementClusterInfo = new ClusterInfo( + (ptr, endpointId) -> new ChipClusters.ElectricalPowerMeasurementCluster(ptr, endpointId), new HashMap<>()); + clusterMap.put("electricalPowerMeasurement", electricalPowerMeasurementClusterInfo); + ClusterInfo electricalEnergyMeasurementClusterInfo = new ClusterInfo( (ptr, endpointId) -> new ChipClusters.ElectricalEnergyMeasurementCluster(ptr, endpointId), new HashMap<>()); clusterMap.put("electricalEnergyMeasurement", electricalEnergyMeasurementClusterInfo); @@ -20451,6 +21065,10 @@ public Map initializeClusterMap() { (ptr, endpointId) -> new ChipClusters.EnergyPreferenceCluster(ptr, endpointId), new HashMap<>()); clusterMap.put("energyPreference", energyPreferenceClusterInfo); + ClusterInfo powerTopologyClusterInfo = new ClusterInfo( + (ptr, endpointId) -> new ChipClusters.PowerTopologyCluster(ptr, endpointId), new HashMap<>()); + clusterMap.put("powerTopology", powerTopologyClusterInfo); + ClusterInfo energyEvseModeClusterInfo = new ClusterInfo( (ptr, endpointId) -> new ChipClusters.EnergyEvseModeCluster(ptr, endpointId), new HashMap<>()); clusterMap.put("energyEvseMode", energyEvseModeClusterInfo); @@ -20700,12 +21318,14 @@ public void combineCommand(Map destination, Map> getCommandMap() { ); generalDiagnosticsClusterInteractionInfoMap.put("timeSnapshot", generalDiagnosticstimeSnapshotInteractionInfo); + Map generalDiagnosticspayloadTestRequestCommandParams = new LinkedHashMap(); + + CommandParameterInfo generalDiagnosticspayloadTestRequestenableKeyCommandParameterInfo = new CommandParameterInfo("enableKey", byte[].class, byte[].class); + generalDiagnosticspayloadTestRequestCommandParams.put("enableKey",generalDiagnosticspayloadTestRequestenableKeyCommandParameterInfo); + + CommandParameterInfo generalDiagnosticspayloadTestRequestvalueCommandParameterInfo = new CommandParameterInfo("value", Integer.class, Integer.class); + generalDiagnosticspayloadTestRequestCommandParams.put("value",generalDiagnosticspayloadTestRequestvalueCommandParameterInfo); + + CommandParameterInfo generalDiagnosticspayloadTestRequestcountCommandParameterInfo = new CommandParameterInfo("count", Integer.class, Integer.class); + generalDiagnosticspayloadTestRequestCommandParams.put("count",generalDiagnosticspayloadTestRequestcountCommandParameterInfo); + InteractionInfo generalDiagnosticspayloadTestRequestInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.GeneralDiagnosticsCluster) cluster) + .payloadTestRequest((ChipClusters.GeneralDiagnosticsCluster.PayloadTestResponseCallback) callback + , (byte[]) + commandArguments.get("enableKey") + + , (Integer) + commandArguments.get("value") + + , (Integer) + commandArguments.get("count") + + ); + }, + () -> new DelegatedGeneralDiagnosticsClusterPayloadTestResponseCallback(), + generalDiagnosticspayloadTestRequestCommandParams + ); + generalDiagnosticsClusterInteractionInfoMap.put("payloadTestRequest", generalDiagnosticspayloadTestRequestInteractionInfo); + commandMap.put("generalDiagnostics", generalDiagnosticsClusterInteractionInfoMap); Map softwareDiagnosticsClusterInteractionInfoMap = new LinkedHashMap<>(); @@ -23566,6 +24216,10 @@ public Map> getCommandMap() { commandMap.put("valveConfigurationAndControl", valveConfigurationAndControlClusterInteractionInfoMap); + Map electricalPowerMeasurementClusterInteractionInfoMap = new LinkedHashMap<>(); + + commandMap.put("electricalPowerMeasurement", electricalPowerMeasurementClusterInteractionInfoMap); + Map electricalEnergyMeasurementClusterInteractionInfoMap = new LinkedHashMap<>(); commandMap.put("electricalEnergyMeasurement", electricalEnergyMeasurementClusterInteractionInfoMap); @@ -23997,6 +24651,10 @@ public Map> getCommandMap() { commandMap.put("energyPreference", energyPreferenceClusterInteractionInfoMap); + Map powerTopologyClusterInteractionInfoMap = new LinkedHashMap<>(); + + commandMap.put("powerTopology", powerTopologyClusterInteractionInfoMap); + Map energyEvseModeClusterInteractionInfoMap = new LinkedHashMap<>(); Map energyEvseModechangeToModeCommandParams = new LinkedHashMap(); diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java index 85f913818cf9f8..cc18af0810cc10 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java @@ -8964,6 +8964,285 @@ private static Map readValveConfigurationAndControlInte return result; } + private static Map readElectricalPowerMeasurementInteractionInfo() { + Map result = new LinkedHashMap<>();Map readElectricalPowerMeasurementPowerModeCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementPowerModeAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readPowerModeAttribute( + (ChipClusters.IntegerAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readElectricalPowerMeasurementPowerModeCommandParams + ); + result.put("readPowerModeAttribute", readElectricalPowerMeasurementPowerModeAttributeInteractionInfo); + Map readElectricalPowerMeasurementNumberOfMeasurementTypesCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementNumberOfMeasurementTypesAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readNumberOfMeasurementTypesAttribute( + (ChipClusters.IntegerAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readElectricalPowerMeasurementNumberOfMeasurementTypesCommandParams + ); + result.put("readNumberOfMeasurementTypesAttribute", readElectricalPowerMeasurementNumberOfMeasurementTypesAttributeInteractionInfo); + Map readElectricalPowerMeasurementAccuracyCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementAccuracyAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readAccuracyAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.AccuracyAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterAccuracyAttributeCallback(), + readElectricalPowerMeasurementAccuracyCommandParams + ); + result.put("readAccuracyAttribute", readElectricalPowerMeasurementAccuracyAttributeInteractionInfo); + Map readElectricalPowerMeasurementRangesCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementRangesAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readRangesAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.RangesAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterRangesAttributeCallback(), + readElectricalPowerMeasurementRangesCommandParams + ); + result.put("readRangesAttribute", readElectricalPowerMeasurementRangesAttributeInteractionInfo); + Map readElectricalPowerMeasurementVoltageCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementVoltageAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readVoltageAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.VoltageAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterVoltageAttributeCallback(), + readElectricalPowerMeasurementVoltageCommandParams + ); + result.put("readVoltageAttribute", readElectricalPowerMeasurementVoltageAttributeInteractionInfo); + Map readElectricalPowerMeasurementActiveCurrentCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementActiveCurrentAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readActiveCurrentAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.ActiveCurrentAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterActiveCurrentAttributeCallback(), + readElectricalPowerMeasurementActiveCurrentCommandParams + ); + result.put("readActiveCurrentAttribute", readElectricalPowerMeasurementActiveCurrentAttributeInteractionInfo); + Map readElectricalPowerMeasurementReactiveCurrentCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementReactiveCurrentAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readReactiveCurrentAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.ReactiveCurrentAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterReactiveCurrentAttributeCallback(), + readElectricalPowerMeasurementReactiveCurrentCommandParams + ); + result.put("readReactiveCurrentAttribute", readElectricalPowerMeasurementReactiveCurrentAttributeInteractionInfo); + Map readElectricalPowerMeasurementApparentCurrentCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementApparentCurrentAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readApparentCurrentAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.ApparentCurrentAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterApparentCurrentAttributeCallback(), + readElectricalPowerMeasurementApparentCurrentCommandParams + ); + result.put("readApparentCurrentAttribute", readElectricalPowerMeasurementApparentCurrentAttributeInteractionInfo); + Map readElectricalPowerMeasurementActivePowerCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementActivePowerAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readActivePowerAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.ActivePowerAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterActivePowerAttributeCallback(), + readElectricalPowerMeasurementActivePowerCommandParams + ); + result.put("readActivePowerAttribute", readElectricalPowerMeasurementActivePowerAttributeInteractionInfo); + Map readElectricalPowerMeasurementReactivePowerCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementReactivePowerAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readReactivePowerAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.ReactivePowerAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterReactivePowerAttributeCallback(), + readElectricalPowerMeasurementReactivePowerCommandParams + ); + result.put("readReactivePowerAttribute", readElectricalPowerMeasurementReactivePowerAttributeInteractionInfo); + Map readElectricalPowerMeasurementApparentPowerCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementApparentPowerAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readApparentPowerAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.ApparentPowerAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterApparentPowerAttributeCallback(), + readElectricalPowerMeasurementApparentPowerCommandParams + ); + result.put("readApparentPowerAttribute", readElectricalPowerMeasurementApparentPowerAttributeInteractionInfo); + Map readElectricalPowerMeasurementRMSVoltageCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementRMSVoltageAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readRMSVoltageAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.RMSVoltageAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterRMSVoltageAttributeCallback(), + readElectricalPowerMeasurementRMSVoltageCommandParams + ); + result.put("readRMSVoltageAttribute", readElectricalPowerMeasurementRMSVoltageAttributeInteractionInfo); + Map readElectricalPowerMeasurementRMSCurrentCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementRMSCurrentAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readRMSCurrentAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.RMSCurrentAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterRMSCurrentAttributeCallback(), + readElectricalPowerMeasurementRMSCurrentCommandParams + ); + result.put("readRMSCurrentAttribute", readElectricalPowerMeasurementRMSCurrentAttributeInteractionInfo); + Map readElectricalPowerMeasurementRMSPowerCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementRMSPowerAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readRMSPowerAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.RMSPowerAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterRMSPowerAttributeCallback(), + readElectricalPowerMeasurementRMSPowerCommandParams + ); + result.put("readRMSPowerAttribute", readElectricalPowerMeasurementRMSPowerAttributeInteractionInfo); + Map readElectricalPowerMeasurementFrequencyCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementFrequencyAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readFrequencyAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.FrequencyAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterFrequencyAttributeCallback(), + readElectricalPowerMeasurementFrequencyCommandParams + ); + result.put("readFrequencyAttribute", readElectricalPowerMeasurementFrequencyAttributeInteractionInfo); + Map readElectricalPowerMeasurementHarmonicCurrentsCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementHarmonicCurrentsAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readHarmonicCurrentsAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.HarmonicCurrentsAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterHarmonicCurrentsAttributeCallback(), + readElectricalPowerMeasurementHarmonicCurrentsCommandParams + ); + result.put("readHarmonicCurrentsAttribute", readElectricalPowerMeasurementHarmonicCurrentsAttributeInteractionInfo); + Map readElectricalPowerMeasurementHarmonicPhasesCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementHarmonicPhasesAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readHarmonicPhasesAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.HarmonicPhasesAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterHarmonicPhasesAttributeCallback(), + readElectricalPowerMeasurementHarmonicPhasesCommandParams + ); + result.put("readHarmonicPhasesAttribute", readElectricalPowerMeasurementHarmonicPhasesAttributeInteractionInfo); + Map readElectricalPowerMeasurementPowerFactorCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementPowerFactorAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readPowerFactorAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.PowerFactorAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterPowerFactorAttributeCallback(), + readElectricalPowerMeasurementPowerFactorCommandParams + ); + result.put("readPowerFactorAttribute", readElectricalPowerMeasurementPowerFactorAttributeInteractionInfo); + Map readElectricalPowerMeasurementNeutralCurrentCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementNeutralCurrentAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readNeutralCurrentAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.NeutralCurrentAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterNeutralCurrentAttributeCallback(), + readElectricalPowerMeasurementNeutralCurrentCommandParams + ); + result.put("readNeutralCurrentAttribute", readElectricalPowerMeasurementNeutralCurrentAttributeInteractionInfo); + Map readElectricalPowerMeasurementGeneratedCommandListCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementGeneratedCommandListAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readGeneratedCommandListAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.GeneratedCommandListAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterGeneratedCommandListAttributeCallback(), + readElectricalPowerMeasurementGeneratedCommandListCommandParams + ); + result.put("readGeneratedCommandListAttribute", readElectricalPowerMeasurementGeneratedCommandListAttributeInteractionInfo); + Map readElectricalPowerMeasurementAcceptedCommandListCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementAcceptedCommandListAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readAcceptedCommandListAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.AcceptedCommandListAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterAcceptedCommandListAttributeCallback(), + readElectricalPowerMeasurementAcceptedCommandListCommandParams + ); + result.put("readAcceptedCommandListAttribute", readElectricalPowerMeasurementAcceptedCommandListAttributeInteractionInfo); + Map readElectricalPowerMeasurementEventListCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementEventListAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readEventListAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.EventListAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterEventListAttributeCallback(), + readElectricalPowerMeasurementEventListCommandParams + ); + result.put("readEventListAttribute", readElectricalPowerMeasurementEventListAttributeInteractionInfo); + Map readElectricalPowerMeasurementAttributeListCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementAttributeListAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readAttributeListAttribute( + (ChipClusters.ElectricalPowerMeasurementCluster.AttributeListAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalPowerMeasurementClusterAttributeListAttributeCallback(), + readElectricalPowerMeasurementAttributeListCommandParams + ); + result.put("readAttributeListAttribute", readElectricalPowerMeasurementAttributeListAttributeInteractionInfo); + Map readElectricalPowerMeasurementFeatureMapCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementFeatureMapAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readFeatureMapAttribute( + (ChipClusters.LongAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedLongAttributeCallback(), + readElectricalPowerMeasurementFeatureMapCommandParams + ); + result.put("readFeatureMapAttribute", readElectricalPowerMeasurementFeatureMapAttributeInteractionInfo); + Map readElectricalPowerMeasurementClusterRevisionCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalPowerMeasurementClusterRevisionAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalPowerMeasurementCluster) cluster).readClusterRevisionAttribute( + (ChipClusters.IntegerAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readElectricalPowerMeasurementClusterRevisionCommandParams + ); + result.put("readClusterRevisionAttribute", readElectricalPowerMeasurementClusterRevisionAttributeInteractionInfo); + + return result; + } private static Map readElectricalEnergyMeasurementInteractionInfo() { Map result = new LinkedHashMap<>();Map readElectricalEnergyMeasurementGeneratedCommandListCommandParams = new LinkedHashMap(); InteractionInfo readElectricalEnergyMeasurementGeneratedCommandListAttributeInteractionInfo = new InteractionInfo( @@ -9879,6 +10158,98 @@ private static Map readEnergyPreferenceInteractionInfo( return result; } + private static Map readPowerTopologyInteractionInfo() { + Map result = new LinkedHashMap<>();Map readPowerTopologyAvailableEndpointsCommandParams = new LinkedHashMap(); + InteractionInfo readPowerTopologyAvailableEndpointsAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.PowerTopologyCluster) cluster).readAvailableEndpointsAttribute( + (ChipClusters.PowerTopologyCluster.AvailableEndpointsAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedPowerTopologyClusterAvailableEndpointsAttributeCallback(), + readPowerTopologyAvailableEndpointsCommandParams + ); + result.put("readAvailableEndpointsAttribute", readPowerTopologyAvailableEndpointsAttributeInteractionInfo); + Map readPowerTopologyActiveEndpointsCommandParams = new LinkedHashMap(); + InteractionInfo readPowerTopologyActiveEndpointsAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.PowerTopologyCluster) cluster).readActiveEndpointsAttribute( + (ChipClusters.PowerTopologyCluster.ActiveEndpointsAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedPowerTopologyClusterActiveEndpointsAttributeCallback(), + readPowerTopologyActiveEndpointsCommandParams + ); + result.put("readActiveEndpointsAttribute", readPowerTopologyActiveEndpointsAttributeInteractionInfo); + Map readPowerTopologyGeneratedCommandListCommandParams = new LinkedHashMap(); + InteractionInfo readPowerTopologyGeneratedCommandListAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.PowerTopologyCluster) cluster).readGeneratedCommandListAttribute( + (ChipClusters.PowerTopologyCluster.GeneratedCommandListAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedPowerTopologyClusterGeneratedCommandListAttributeCallback(), + readPowerTopologyGeneratedCommandListCommandParams + ); + result.put("readGeneratedCommandListAttribute", readPowerTopologyGeneratedCommandListAttributeInteractionInfo); + Map readPowerTopologyAcceptedCommandListCommandParams = new LinkedHashMap(); + InteractionInfo readPowerTopologyAcceptedCommandListAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.PowerTopologyCluster) cluster).readAcceptedCommandListAttribute( + (ChipClusters.PowerTopologyCluster.AcceptedCommandListAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedPowerTopologyClusterAcceptedCommandListAttributeCallback(), + readPowerTopologyAcceptedCommandListCommandParams + ); + result.put("readAcceptedCommandListAttribute", readPowerTopologyAcceptedCommandListAttributeInteractionInfo); + Map readPowerTopologyEventListCommandParams = new LinkedHashMap(); + InteractionInfo readPowerTopologyEventListAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.PowerTopologyCluster) cluster).readEventListAttribute( + (ChipClusters.PowerTopologyCluster.EventListAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedPowerTopologyClusterEventListAttributeCallback(), + readPowerTopologyEventListCommandParams + ); + result.put("readEventListAttribute", readPowerTopologyEventListAttributeInteractionInfo); + Map readPowerTopologyAttributeListCommandParams = new LinkedHashMap(); + InteractionInfo readPowerTopologyAttributeListAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.PowerTopologyCluster) cluster).readAttributeListAttribute( + (ChipClusters.PowerTopologyCluster.AttributeListAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedPowerTopologyClusterAttributeListAttributeCallback(), + readPowerTopologyAttributeListCommandParams + ); + result.put("readAttributeListAttribute", readPowerTopologyAttributeListAttributeInteractionInfo); + Map readPowerTopologyFeatureMapCommandParams = new LinkedHashMap(); + InteractionInfo readPowerTopologyFeatureMapAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.PowerTopologyCluster) cluster).readFeatureMapAttribute( + (ChipClusters.LongAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedLongAttributeCallback(), + readPowerTopologyFeatureMapCommandParams + ); + result.put("readFeatureMapAttribute", readPowerTopologyFeatureMapAttributeInteractionInfo); + Map readPowerTopologyClusterRevisionCommandParams = new LinkedHashMap(); + InteractionInfo readPowerTopologyClusterRevisionAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.PowerTopologyCluster) cluster).readClusterRevisionAttribute( + (ChipClusters.IntegerAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readPowerTopologyClusterRevisionCommandParams + ); + result.put("readClusterRevisionAttribute", readPowerTopologyClusterRevisionAttributeInteractionInfo); + + return result; + } private static Map readEnergyEvseModeInteractionInfo() { Map result = new LinkedHashMap<>();Map readEnergyEvseModeSupportedModesCommandParams = new LinkedHashMap(); InteractionInfo readEnergyEvseModeSupportedModesAttributeInteractionInfo = new InteractionInfo( @@ -20182,12 +20553,14 @@ public Map> getReadAttributeMap() { put("activatedCarbonFilterMonitoring", readActivatedCarbonFilterMonitoringInteractionInfo()); put("booleanStateConfiguration", readBooleanStateConfigurationInteractionInfo()); put("valveConfigurationAndControl", readValveConfigurationAndControlInteractionInfo()); + put("electricalPowerMeasurement", readElectricalPowerMeasurementInteractionInfo()); put("electricalEnergyMeasurement", readElectricalEnergyMeasurementInteractionInfo()); put("demandResponseLoadControl", readDemandResponseLoadControlInteractionInfo()); put("messages", readMessagesInteractionInfo()); put("deviceEnergyManagement", readDeviceEnergyManagementInteractionInfo()); put("energyEvse", readEnergyEvseInteractionInfo()); put("energyPreference", readEnergyPreferenceInteractionInfo()); + put("powerTopology", readPowerTopologyInteractionInfo()); put("energyEvseMode", readEnergyEvseModeInteractionInfo()); put("deviceEnergyManagementMode", readDeviceEnergyManagementModeInteractionInfo()); put("doorLock", readDoorLockInteractionInfo()); diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java index dc674be7a4a7ec..0e5a32b23f04c4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java @@ -1190,6 +1190,8 @@ public Map> getWriteAttributeMap() { ); writeValveConfigurationAndControlInteractionInfo.put("writeDefaultOpenLevelAttribute", writeValveConfigurationAndControlDefaultOpenLevelAttributeInteractionInfo); writeAttributeMap.put("valveConfigurationAndControl", writeValveConfigurationAndControlInteractionInfo); + Map writeElectricalPowerMeasurementInteractionInfo = new LinkedHashMap<>(); + writeAttributeMap.put("electricalPowerMeasurement", writeElectricalPowerMeasurementInteractionInfo); Map writeElectricalEnergyMeasurementInteractionInfo = new LinkedHashMap<>(); writeAttributeMap.put("electricalEnergyMeasurement", writeElectricalEnergyMeasurementInteractionInfo); Map writeDemandResponseLoadControlInteractionInfo = new LinkedHashMap<>(); @@ -1356,6 +1358,8 @@ public Map> getWriteAttributeMap() { ); writeEnergyPreferenceInteractionInfo.put("writeCurrentLowPowerModeSensitivityAttribute", writeEnergyPreferenceCurrentLowPowerModeSensitivityAttributeInteractionInfo); writeAttributeMap.put("energyPreference", writeEnergyPreferenceInteractionInfo); + Map writePowerTopologyInteractionInfo = new LinkedHashMap<>(); + writeAttributeMap.put("powerTopology", writePowerTopologyInteractionInfo); Map writeEnergyEvseModeInteractionInfo = new LinkedHashMap<>(); Map writeEnergyEvseModeStartUpModeCommandParams = new LinkedHashMap(); CommandParameterInfo energyEvseModestartUpModeCommandParameterInfo = diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt new file mode 100644 index 00000000000000..cc399a62cbc419 --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt @@ -0,0 +1,78 @@ +/* + * + * 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. + */ +package chip.devicecontroller.cluster.eventstructs + +import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent( + val ranges: + List< + chip.devicecontroller.cluster.structs.ElectricalPowerMeasurementClusterMeasurementRangeStruct + > +) { + override fun toString(): String = buildString { + append("ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent {\n") + append("\tranges : $ranges\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + startArray(ContextSpecificTag(TAG_RANGES)) + for (item in ranges.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + endStructure() + } + } + + companion object { + private const val TAG_RANGES = 0 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent { + tlvReader.enterStructure(tlvTag) + val ranges = + buildList< + chip.devicecontroller.cluster.structs.ElectricalPowerMeasurementClusterMeasurementRangeStruct + > { + tlvReader.enterArray(ContextSpecificTag(TAG_RANGES)) + while (!tlvReader.isEndOfContainer()) { + this.add( + chip.devicecontroller.cluster.structs + .ElectricalPowerMeasurementClusterMeasurementRangeStruct + .fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } + + tlvReader.exitContainer() + + return ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent(ranges) + } + } +} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni index d5fe7ad8fcc5ce..34fd21bb27d770 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni @@ -55,9 +55,14 @@ structs_sources = [ "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseModeClusterModeOptionStruct.kt", @@ -161,6 +166,7 @@ eventstructs_sources = [ "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt", diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt new file mode 100644 index 00000000000000..e16d78d8de18e1 --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt @@ -0,0 +1,146 @@ +/* + * + * 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. + */ +package chip.devicecontroller.cluster.structs + +import chip.devicecontroller.cluster.* +import java.util.Optional +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct( + val importedResetTimestamp: Optional?, + val exportedResetTimestamp: Optional?, + val importedResetSystime: Optional?, + val exportedResetSystime: Optional? +) { + override fun toString(): String = buildString { + append("ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct {\n") + append("\timportedResetTimestamp : $importedResetTimestamp\n") + append("\texportedResetTimestamp : $exportedResetTimestamp\n") + append("\timportedResetSystime : $importedResetSystime\n") + append("\texportedResetSystime : $exportedResetSystime\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + if (importedResetTimestamp != null) { + if (importedResetTimestamp.isPresent) { + val optimportedResetTimestamp = importedResetTimestamp.get() + put(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP), optimportedResetTimestamp) + } + } else { + putNull(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP)) + } + if (exportedResetTimestamp != null) { + if (exportedResetTimestamp.isPresent) { + val optexportedResetTimestamp = exportedResetTimestamp.get() + put(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP), optexportedResetTimestamp) + } + } else { + putNull(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP)) + } + if (importedResetSystime != null) { + if (importedResetSystime.isPresent) { + val optimportedResetSystime = importedResetSystime.get() + put(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME), optimportedResetSystime) + } + } else { + putNull(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME)) + } + if (exportedResetSystime != null) { + if (exportedResetSystime.isPresent) { + val optexportedResetSystime = exportedResetSystime.get() + put(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME), optexportedResetSystime) + } + } else { + putNull(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME)) + } + endStructure() + } + } + + companion object { + private const val TAG_IMPORTED_RESET_TIMESTAMP = 0 + private const val TAG_EXPORTED_RESET_TIMESTAMP = 1 + private const val TAG_IMPORTED_RESET_SYSTIME = 2 + private const val TAG_EXPORTED_RESET_SYSTIME = 3 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct { + tlvReader.enterStructure(tlvTag) + val importedResetTimestamp = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP)) + null + } + val exportedResetTimestamp = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP)) + null + } + val importedResetSystime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME)) + null + } + val exportedResetSystime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME)) + null + } + + tlvReader.exitContainer() + + return ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct( + importedResetTimestamp, + exportedResetTimestamp, + importedResetSystime, + exportedResetSystime + ) + } + } +} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt new file mode 100644 index 00000000000000..dd4286af08c7f2 --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt @@ -0,0 +1,72 @@ +/* + * + * 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. + */ +package chip.devicecontroller.cluster.structs + +import chip.devicecontroller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalPowerMeasurementClusterHarmonicMeasurementStruct( + val order: UInt, + val measurement: Long? +) { + override fun toString(): String = buildString { + append("ElectricalPowerMeasurementClusterHarmonicMeasurementStruct {\n") + append("\torder : $order\n") + append("\tmeasurement : $measurement\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_ORDER), order) + if (measurement != null) { + put(ContextSpecificTag(TAG_MEASUREMENT), measurement) + } else { + putNull(ContextSpecificTag(TAG_MEASUREMENT)) + } + endStructure() + } + } + + companion object { + private const val TAG_ORDER = 0 + private const val TAG_MEASUREMENT = 1 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterHarmonicMeasurementStruct { + tlvReader.enterStructure(tlvTag) + val order = tlvReader.getUInt(ContextSpecificTag(TAG_ORDER)) + val measurement = + if (!tlvReader.isNull()) { + tlvReader.getLong(ContextSpecificTag(TAG_MEASUREMENT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MEASUREMENT)) + null + } + + tlvReader.exitContainer() + + return ElectricalPowerMeasurementClusterHarmonicMeasurementStruct(order, measurement) + } + } +} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt new file mode 100644 index 00000000000000..b937601980e488 --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt @@ -0,0 +1,150 @@ +/* + * + * 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. + */ +package chip.devicecontroller.cluster.structs + +import chip.devicecontroller.cluster.* +import java.util.Optional +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct( + val rangeMin: Long, + val rangeMax: Long, + val percentMax: Optional, + val percentMin: Optional, + val percentTypical: Optional, + val fixedMax: Optional, + val fixedMin: Optional, + val fixedTypical: Optional +) { + override fun toString(): String = buildString { + append("ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct {\n") + append("\trangeMin : $rangeMin\n") + append("\trangeMax : $rangeMax\n") + append("\tpercentMax : $percentMax\n") + append("\tpercentMin : $percentMin\n") + append("\tpercentTypical : $percentTypical\n") + append("\tfixedMax : $fixedMax\n") + append("\tfixedMin : $fixedMin\n") + append("\tfixedTypical : $fixedTypical\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_RANGE_MIN), rangeMin) + put(ContextSpecificTag(TAG_RANGE_MAX), rangeMax) + if (percentMax.isPresent) { + val optpercentMax = percentMax.get() + put(ContextSpecificTag(TAG_PERCENT_MAX), optpercentMax) + } + if (percentMin.isPresent) { + val optpercentMin = percentMin.get() + put(ContextSpecificTag(TAG_PERCENT_MIN), optpercentMin) + } + if (percentTypical.isPresent) { + val optpercentTypical = percentTypical.get() + put(ContextSpecificTag(TAG_PERCENT_TYPICAL), optpercentTypical) + } + if (fixedMax.isPresent) { + val optfixedMax = fixedMax.get() + put(ContextSpecificTag(TAG_FIXED_MAX), optfixedMax) + } + if (fixedMin.isPresent) { + val optfixedMin = fixedMin.get() + put(ContextSpecificTag(TAG_FIXED_MIN), optfixedMin) + } + if (fixedTypical.isPresent) { + val optfixedTypical = fixedTypical.get() + put(ContextSpecificTag(TAG_FIXED_TYPICAL), optfixedTypical) + } + endStructure() + } + } + + companion object { + private const val TAG_RANGE_MIN = 0 + private const val TAG_RANGE_MAX = 1 + private const val TAG_PERCENT_MAX = 2 + private const val TAG_PERCENT_MIN = 3 + private const val TAG_PERCENT_TYPICAL = 4 + private const val TAG_FIXED_MAX = 5 + private const val TAG_FIXED_MIN = 6 + private const val TAG_FIXED_TYPICAL = 7 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct { + tlvReader.enterStructure(tlvTag) + val rangeMin = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MIN)) + val rangeMax = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MAX)) + val percentMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MAX))) + } else { + Optional.empty() + } + val percentMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MIN))) + } else { + Optional.empty() + } + val percentTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_TYPICAL))) + } else { + Optional.empty() + } + val fixedMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) + } else { + Optional.empty() + } + val fixedMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) + } else { + Optional.empty() + } + val fixedTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) + } else { + Optional.empty() + } + + tlvReader.exitContainer() + + return ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct( + rangeMin, + rangeMax, + percentMax, + percentMin, + percentTypical, + fixedMax, + fixedMin, + fixedTypical + ) + } + } +} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt new file mode 100644 index 00000000000000..8197ccc39696ae --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt @@ -0,0 +1,100 @@ +/* + * + * 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. + */ +package chip.devicecontroller.cluster.structs + +import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalPowerMeasurementClusterMeasurementAccuracyStruct( + val measurementType: UInt, + val measured: Boolean, + val minMeasuredValue: Long, + val maxMeasuredValue: Long, + val accuracyRanges: List +) { + override fun toString(): String = buildString { + append("ElectricalPowerMeasurementClusterMeasurementAccuracyStruct {\n") + append("\tmeasurementType : $measurementType\n") + append("\tmeasured : $measured\n") + append("\tminMeasuredValue : $minMeasuredValue\n") + append("\tmaxMeasuredValue : $maxMeasuredValue\n") + append("\taccuracyRanges : $accuracyRanges\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_MEASUREMENT_TYPE), measurementType) + put(ContextSpecificTag(TAG_MEASURED), measured) + put(ContextSpecificTag(TAG_MIN_MEASURED_VALUE), minMeasuredValue) + put(ContextSpecificTag(TAG_MAX_MEASURED_VALUE), maxMeasuredValue) + startArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + for (item in accuracyRanges.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + endStructure() + } + } + + companion object { + private const val TAG_MEASUREMENT_TYPE = 0 + private const val TAG_MEASURED = 1 + private const val TAG_MIN_MEASURED_VALUE = 2 + private const val TAG_MAX_MEASURED_VALUE = 3 + private const val TAG_ACCURACY_RANGES = 4 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementAccuracyStruct { + tlvReader.enterStructure(tlvTag) + val measurementType = tlvReader.getUInt(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) + val measured = tlvReader.getBoolean(ContextSpecificTag(TAG_MEASURED)) + val minMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MIN_MEASURED_VALUE)) + val maxMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MAX_MEASURED_VALUE)) + val accuracyRanges = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + + tlvReader.exitContainer() + + return ElectricalPowerMeasurementClusterMeasurementAccuracyStruct( + measurementType, + measured, + minMeasuredValue, + maxMeasuredValue, + accuracyRanges + ) + } + } +} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt new file mode 100644 index 00000000000000..8ddb817032d7f3 --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt @@ -0,0 +1,184 @@ +/* + * + * 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. + */ +package chip.devicecontroller.cluster.structs + +import chip.devicecontroller.cluster.* +import java.util.Optional +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalPowerMeasurementClusterMeasurementRangeStruct( + val measurementType: UInt, + val min: Long, + val max: Long, + val startTimestamp: Optional, + val endTimestamp: Optional, + val minTimestamp: Optional, + val maxTimestamp: Optional, + val startSystime: Optional, + val endSystime: Optional, + val minSystime: Optional, + val maxSystime: Optional +) { + override fun toString(): String = buildString { + append("ElectricalPowerMeasurementClusterMeasurementRangeStruct {\n") + append("\tmeasurementType : $measurementType\n") + append("\tmin : $min\n") + append("\tmax : $max\n") + append("\tstartTimestamp : $startTimestamp\n") + append("\tendTimestamp : $endTimestamp\n") + append("\tminTimestamp : $minTimestamp\n") + append("\tmaxTimestamp : $maxTimestamp\n") + append("\tstartSystime : $startSystime\n") + append("\tendSystime : $endSystime\n") + append("\tminSystime : $minSystime\n") + append("\tmaxSystime : $maxSystime\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_MEASUREMENT_TYPE), measurementType) + put(ContextSpecificTag(TAG_MIN), min) + put(ContextSpecificTag(TAG_MAX), max) + if (startTimestamp.isPresent) { + val optstartTimestamp = startTimestamp.get() + put(ContextSpecificTag(TAG_START_TIMESTAMP), optstartTimestamp) + } + if (endTimestamp.isPresent) { + val optendTimestamp = endTimestamp.get() + put(ContextSpecificTag(TAG_END_TIMESTAMP), optendTimestamp) + } + if (minTimestamp.isPresent) { + val optminTimestamp = minTimestamp.get() + put(ContextSpecificTag(TAG_MIN_TIMESTAMP), optminTimestamp) + } + if (maxTimestamp.isPresent) { + val optmaxTimestamp = maxTimestamp.get() + put(ContextSpecificTag(TAG_MAX_TIMESTAMP), optmaxTimestamp) + } + if (startSystime.isPresent) { + val optstartSystime = startSystime.get() + put(ContextSpecificTag(TAG_START_SYSTIME), optstartSystime) + } + if (endSystime.isPresent) { + val optendSystime = endSystime.get() + put(ContextSpecificTag(TAG_END_SYSTIME), optendSystime) + } + if (minSystime.isPresent) { + val optminSystime = minSystime.get() + put(ContextSpecificTag(TAG_MIN_SYSTIME), optminSystime) + } + if (maxSystime.isPresent) { + val optmaxSystime = maxSystime.get() + put(ContextSpecificTag(TAG_MAX_SYSTIME), optmaxSystime) + } + endStructure() + } + } + + companion object { + private const val TAG_MEASUREMENT_TYPE = 0 + private const val TAG_MIN = 1 + private const val TAG_MAX = 2 + private const val TAG_START_TIMESTAMP = 3 + private const val TAG_END_TIMESTAMP = 4 + private const val TAG_MIN_TIMESTAMP = 5 + private const val TAG_MAX_TIMESTAMP = 6 + private const val TAG_START_SYSTIME = 7 + private const val TAG_END_SYSTIME = 8 + private const val TAG_MIN_SYSTIME = 9 + private const val TAG_MAX_SYSTIME = 10 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementRangeStruct { + tlvReader.enterStructure(tlvTag) + val measurementType = tlvReader.getUInt(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) + val min = tlvReader.getLong(ContextSpecificTag(TAG_MIN)) + val max = tlvReader.getLong(ContextSpecificTag(TAG_MAX)) + val startTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_TIMESTAMP))) + } else { + Optional.empty() + } + val endTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_TIMESTAMP))) + } else { + Optional.empty() + } + val minTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_TIMESTAMP))) + } else { + Optional.empty() + } + val maxTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_TIMESTAMP))) + } else { + Optional.empty() + } + val startSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) + } else { + Optional.empty() + } + val endSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) + } else { + Optional.empty() + } + val minSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_SYSTIME))) + } else { + Optional.empty() + } + val maxSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_SYSTIME))) + } else { + Optional.empty() + } + + tlvReader.exitContainer() + + return ElectricalPowerMeasurementClusterMeasurementRangeStruct( + measurementType, + min, + max, + startTimestamp, + endTimestamp, + minTimestamp, + maxTimestamp, + startSystime, + endSystime, + minSystime, + maxSystime + ) + } + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt index 8be25c67fbcda4..64ade41965a6e9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt @@ -103,6 +103,19 @@ class ElectricalEnergyMeasurementCluster( object SubscriptionEstablished : PeriodicEnergyExportedAttributeSubscriptionState() } + class CumulativeEnergyResetAttribute( + val value: ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct? + ) + + sealed class CumulativeEnergyResetAttributeSubscriptionState { + data class Success(val value: ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct?) : + CumulativeEnergyResetAttributeSubscriptionState() + + data class Error(val exception: Exception) : CumulativeEnergyResetAttributeSubscriptionState() + + object SubscriptionEstablished : CumulativeEnergyResetAttributeSubscriptionState() + } + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { @@ -653,6 +666,115 @@ class ElectricalEnergyMeasurementCluster( } } + suspend fun readCumulativeEnergyResetAttribute(): CumulativeEnergyResetAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Cumulativeenergyreset attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CumulativeEnergyResetAttribute(decodedValue) + } + + suspend fun subscribeCumulativeEnergyResetAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 5u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + CumulativeEnergyResetAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Cumulativeenergyreset attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CumulativeEnergyResetAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(CumulativeEnergyResetAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { val ATTRIBUTE_ID: UInt = 65528u diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalPowerMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalPowerMeasurementCluster.kt new file mode 100644 index 00000000000000..6932934b50f103 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalPowerMeasurementCluster.kt @@ -0,0 +1,2760 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.transform +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.SubscribeRequest +import matter.controller.SubscriptionState +import matter.controller.UByteSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class ElectricalPowerMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AccuracyAttribute( + val value: List + ) + + sealed class AccuracyAttributeSubscriptionState { + data class Success( + val value: List + ) : AccuracyAttributeSubscriptionState() + + data class Error(val exception: Exception) : AccuracyAttributeSubscriptionState() + + object SubscriptionEstablished : AccuracyAttributeSubscriptionState() + } + + class RangesAttribute(val value: List?) + + sealed class RangesAttributeSubscriptionState { + data class Success(val value: List?) : + RangesAttributeSubscriptionState() + + data class Error(val exception: Exception) : RangesAttributeSubscriptionState() + + object SubscriptionEstablished : RangesAttributeSubscriptionState() + } + + class VoltageAttribute(val value: Long?) + + sealed class VoltageAttributeSubscriptionState { + data class Success(val value: Long?) : VoltageAttributeSubscriptionState() + + data class Error(val exception: Exception) : VoltageAttributeSubscriptionState() + + object SubscriptionEstablished : VoltageAttributeSubscriptionState() + } + + class ActiveCurrentAttribute(val value: Long?) + + sealed class ActiveCurrentAttributeSubscriptionState { + data class Success(val value: Long?) : ActiveCurrentAttributeSubscriptionState() + + data class Error(val exception: Exception) : ActiveCurrentAttributeSubscriptionState() + + object SubscriptionEstablished : ActiveCurrentAttributeSubscriptionState() + } + + class ReactiveCurrentAttribute(val value: Long?) + + sealed class ReactiveCurrentAttributeSubscriptionState { + data class Success(val value: Long?) : ReactiveCurrentAttributeSubscriptionState() + + data class Error(val exception: Exception) : ReactiveCurrentAttributeSubscriptionState() + + object SubscriptionEstablished : ReactiveCurrentAttributeSubscriptionState() + } + + class ApparentCurrentAttribute(val value: Long?) + + sealed class ApparentCurrentAttributeSubscriptionState { + data class Success(val value: Long?) : ApparentCurrentAttributeSubscriptionState() + + data class Error(val exception: Exception) : ApparentCurrentAttributeSubscriptionState() + + object SubscriptionEstablished : ApparentCurrentAttributeSubscriptionState() + } + + class ActivePowerAttribute(val value: Long?) + + sealed class ActivePowerAttributeSubscriptionState { + data class Success(val value: Long?) : ActivePowerAttributeSubscriptionState() + + data class Error(val exception: Exception) : ActivePowerAttributeSubscriptionState() + + object SubscriptionEstablished : ActivePowerAttributeSubscriptionState() + } + + class ReactivePowerAttribute(val value: Long?) + + sealed class ReactivePowerAttributeSubscriptionState { + data class Success(val value: Long?) : ReactivePowerAttributeSubscriptionState() + + data class Error(val exception: Exception) : ReactivePowerAttributeSubscriptionState() + + object SubscriptionEstablished : ReactivePowerAttributeSubscriptionState() + } + + class ApparentPowerAttribute(val value: Long?) + + sealed class ApparentPowerAttributeSubscriptionState { + data class Success(val value: Long?) : ApparentPowerAttributeSubscriptionState() + + data class Error(val exception: Exception) : ApparentPowerAttributeSubscriptionState() + + object SubscriptionEstablished : ApparentPowerAttributeSubscriptionState() + } + + class RMSVoltageAttribute(val value: Long?) + + sealed class RMSVoltageAttributeSubscriptionState { + data class Success(val value: Long?) : RMSVoltageAttributeSubscriptionState() + + data class Error(val exception: Exception) : RMSVoltageAttributeSubscriptionState() + + object SubscriptionEstablished : RMSVoltageAttributeSubscriptionState() + } + + class RMSCurrentAttribute(val value: Long?) + + sealed class RMSCurrentAttributeSubscriptionState { + data class Success(val value: Long?) : RMSCurrentAttributeSubscriptionState() + + data class Error(val exception: Exception) : RMSCurrentAttributeSubscriptionState() + + object SubscriptionEstablished : RMSCurrentAttributeSubscriptionState() + } + + class RMSPowerAttribute(val value: Long?) + + sealed class RMSPowerAttributeSubscriptionState { + data class Success(val value: Long?) : RMSPowerAttributeSubscriptionState() + + data class Error(val exception: Exception) : RMSPowerAttributeSubscriptionState() + + object SubscriptionEstablished : RMSPowerAttributeSubscriptionState() + } + + class FrequencyAttribute(val value: Long?) + + sealed class FrequencyAttributeSubscriptionState { + data class Success(val value: Long?) : FrequencyAttributeSubscriptionState() + + data class Error(val exception: Exception) : FrequencyAttributeSubscriptionState() + + object SubscriptionEstablished : FrequencyAttributeSubscriptionState() + } + + class HarmonicCurrentsAttribute( + val value: List? + ) + + sealed class HarmonicCurrentsAttributeSubscriptionState { + data class Success( + val value: List? + ) : HarmonicCurrentsAttributeSubscriptionState() + + data class Error(val exception: Exception) : HarmonicCurrentsAttributeSubscriptionState() + + object SubscriptionEstablished : HarmonicCurrentsAttributeSubscriptionState() + } + + class HarmonicPhasesAttribute( + val value: List? + ) + + sealed class HarmonicPhasesAttributeSubscriptionState { + data class Success( + val value: List? + ) : HarmonicPhasesAttributeSubscriptionState() + + data class Error(val exception: Exception) : HarmonicPhasesAttributeSubscriptionState() + + object SubscriptionEstablished : HarmonicPhasesAttributeSubscriptionState() + } + + class PowerFactorAttribute(val value: Long?) + + sealed class PowerFactorAttributeSubscriptionState { + data class Success(val value: Long?) : PowerFactorAttributeSubscriptionState() + + data class Error(val exception: Exception) : PowerFactorAttributeSubscriptionState() + + object SubscriptionEstablished : PowerFactorAttributeSubscriptionState() + } + + class NeutralCurrentAttribute(val value: Long?) + + sealed class NeutralCurrentAttributeSubscriptionState { + data class Success(val value: Long?) : NeutralCurrentAttributeSubscriptionState() + + data class Error(val exception: Exception) : NeutralCurrentAttributeSubscriptionState() + + object SubscriptionEstablished : NeutralCurrentAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) + + sealed class GeneratedCommandListAttributeSubscriptionState { + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() + + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) + + sealed class AcceptedCommandListAttributeSubscriptionState { + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() + + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) + + sealed class EventListAttributeSubscriptionState { + data class Success(val value: List) : EventListAttributeSubscriptionState() + + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() + + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) + + sealed class AttributeListAttributeSubscriptionState { + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() + + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readPowerModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Powermode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun subscribePowerModeAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 0u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Powermode attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + emit(UByteSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(UByteSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readNumberOfMeasurementTypesAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberofmeasurementtypes attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun subscribeNumberOfMeasurementTypesAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 1u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofmeasurementtypes attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + emit(UByteSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(UByteSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readAccuracyAttribute(): AccuracyAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Accuracy attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + + return AccuracyAttribute(decodedValue) + } + + suspend fun subscribeAccuracyAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 2u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + AccuracyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Accuracy attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + + emit(AccuracyAttributeSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(AccuracyAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readRangesAttribute(): RangesAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Ranges attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterMeasurementRangeStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + return RangesAttribute(decodedValue) + } + + suspend fun subscribeRangesAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 3u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + RangesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Ranges attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterMeasurementRangeStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(RangesAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(RangesAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readVoltageAttribute(): VoltageAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Voltage attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return VoltageAttribute(decodedValue) + } + + suspend fun subscribeVoltageAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 4u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + VoltageAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Voltage attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(VoltageAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(VoltageAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readActiveCurrentAttribute(): ActiveCurrentAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activecurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ActiveCurrentAttribute(decodedValue) + } + + suspend fun subscribeActiveCurrentAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 5u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + ActiveCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Activecurrent attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ActiveCurrentAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(ActiveCurrentAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readReactiveCurrentAttribute(): ReactiveCurrentAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Reactivecurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ReactiveCurrentAttribute(decodedValue) + } + + suspend fun subscribeReactiveCurrentAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 6u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + ReactiveCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Reactivecurrent attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ReactiveCurrentAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(ReactiveCurrentAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readApparentCurrentAttribute(): ApparentCurrentAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Apparentcurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ApparentCurrentAttribute(decodedValue) + } + + suspend fun subscribeApparentCurrentAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 7u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + ApparentCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Apparentcurrent attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ApparentCurrentAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(ApparentCurrentAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readActivePowerAttribute(): ActivePowerAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activepower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ActivePowerAttribute(decodedValue) + } + + suspend fun subscribeActivePowerAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 8u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + ActivePowerAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Activepower attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ActivePowerAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(ActivePowerAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readReactivePowerAttribute(): ReactivePowerAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Reactivepower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ReactivePowerAttribute(decodedValue) + } + + suspend fun subscribeReactivePowerAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 9u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + ReactivePowerAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Reactivepower attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ReactivePowerAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(ReactivePowerAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readApparentPowerAttribute(): ApparentPowerAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Apparentpower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ApparentPowerAttribute(decodedValue) + } + + suspend fun subscribeApparentPowerAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 10u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + ApparentPowerAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Apparentpower attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ApparentPowerAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(ApparentPowerAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readRMSVoltageAttribute(): RMSVoltageAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltage attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return RMSVoltageAttribute(decodedValue) + } + + suspend fun subscribeRMSVoltageAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 11u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + RMSVoltageAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmsvoltage attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(RMSVoltageAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(RMSVoltageAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readRMSCurrentAttribute(): RMSCurrentAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmscurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return RMSCurrentAttribute(decodedValue) + } + + suspend fun subscribeRMSCurrentAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 12u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + RMSCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmscurrent attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(RMSCurrentAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(RMSCurrentAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readRMSPowerAttribute(): RMSPowerAttribute { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmspower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return RMSPowerAttribute(decodedValue) + } + + suspend fun subscribeRMSPowerAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 13u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + RMSPowerAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmspower attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(RMSPowerAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(RMSPowerAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readFrequencyAttribute(): FrequencyAttribute { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Frequency attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return FrequencyAttribute(decodedValue) + } + + suspend fun subscribeFrequencyAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 14u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + FrequencyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Frequency attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(FrequencyAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(FrequencyAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readHarmonicCurrentsAttribute(): HarmonicCurrentsAttribute { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Harmoniccurrents attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return HarmonicCurrentsAttribute(decodedValue) + } + + suspend fun subscribeHarmonicCurrentsAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 15u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + HarmonicCurrentsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Harmoniccurrents attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(HarmonicCurrentsAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(HarmonicCurrentsAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readHarmonicPhasesAttribute(): HarmonicPhasesAttribute { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Harmonicphases attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return HarmonicPhasesAttribute(decodedValue) + } + + suspend fun subscribeHarmonicPhasesAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 16u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + HarmonicPhasesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Harmonicphases attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(HarmonicPhasesAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(HarmonicPhasesAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readPowerFactorAttribute(): PowerFactorAttribute { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Powerfactor attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PowerFactorAttribute(decodedValue) + } + + suspend fun subscribePowerFactorAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 17u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + PowerFactorAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Powerfactor attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PowerFactorAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(PowerFactorAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readNeutralCurrentAttribute(): NeutralCurrentAttribute { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Neutralcurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NeutralCurrentAttribute(decodedValue) + } + + suspend fun subscribeNeutralCurrentAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 18u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + NeutralCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Neutralcurrent attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(NeutralCurrentAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(NeutralCurrentAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun subscribeGeneratedCommandListAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 65528u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun subscribeAcceptedCommandListAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 65529u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun subscribeEventListAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 65530u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + emit(EventListAttributeSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(EventListAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun subscribeAttributeListAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 65531u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun subscribeFeatureMapAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 65532u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + emit(UIntSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(UIntSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun subscribeClusterRevisionAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 65533u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + emit(UShortSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(UShortSubscriptionState.SubscriptionEstablished) + } + } + } + } + + companion object { + private val logger = Logger.getLogger(ElectricalPowerMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 144u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt index cdc7a18ad10d15..192e15ba65e2d7 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt @@ -48,6 +48,8 @@ class GeneralDiagnosticsCluster( ) { class TimeSnapshotResponse(val systemTimeMs: ULong, val posixTimeMs: ULong?) + class PayloadTestResponse(val payload: ByteArray) + class NetworkInterfacesAttribute(val value: List) sealed class NetworkInterfacesAttributeSubscriptionState { @@ -216,6 +218,61 @@ class GeneralDiagnosticsCluster( return TimeSnapshotResponse(systemTimeMs_decoded, posixTimeMs_decoded) } + suspend fun payloadTestRequest( + enableKey: ByteArray, + value: UByte, + count: UShort, + timedInvokeTimeout: Duration? = null + ): PayloadTestResponse { + val commandId: UInt = 3u + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ENABLE_KEY_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ENABLE_KEY_REQ), enableKey) + + val TAG_VALUE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_VALUE_REQ), value) + + val TAG_COUNT_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_COUNT_REQ), count) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timedInvokeTimeout + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_PAYLOAD: Int = 0 + var payload_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_PAYLOAD)) { + payload_decoded = tlvReader.getByteArray(tag) + } else { + tlvReader.skipElement() + } + } + + if (payload_decoded == null) { + throw IllegalStateException("payload not found in TLV") + } + + tlvReader.exitContainer() + + return PayloadTestResponse(payload_decoded) + } + suspend fun readNetworkInterfacesAttribute(): NetworkInterfacesAttribute { val ATTRIBUTE_ID: UInt = 0u diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerTopologyCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerTopologyCluster.kt new file mode 100644 index 00000000000000..763677bae3dee5 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerTopologyCluster.kt @@ -0,0 +1,863 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.transform +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.SubscribeRequest +import matter.controller.SubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class PowerTopologyCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AvailableEndpointsAttribute(val value: List?) + + sealed class AvailableEndpointsAttributeSubscriptionState { + data class Success(val value: List?) : AvailableEndpointsAttributeSubscriptionState() + + data class Error(val exception: Exception) : AvailableEndpointsAttributeSubscriptionState() + + object SubscriptionEstablished : AvailableEndpointsAttributeSubscriptionState() + } + + class ActiveEndpointsAttribute(val value: List?) + + sealed class ActiveEndpointsAttributeSubscriptionState { + data class Success(val value: List?) : ActiveEndpointsAttributeSubscriptionState() + + data class Error(val exception: Exception) : ActiveEndpointsAttributeSubscriptionState() + + object SubscriptionEstablished : ActiveEndpointsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) + + sealed class GeneratedCommandListAttributeSubscriptionState { + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() + + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) + + sealed class AcceptedCommandListAttributeSubscriptionState { + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() + + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) + + sealed class EventListAttributeSubscriptionState { + data class Success(val value: List) : EventListAttributeSubscriptionState() + + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() + + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) + + sealed class AttributeListAttributeSubscriptionState { + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() + + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readAvailableEndpointsAttribute(): AvailableEndpointsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Availableendpoints attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return AvailableEndpointsAttribute(decodedValue) + } + + suspend fun subscribeAvailableEndpointsAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 0u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + AvailableEndpointsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Availableendpoints attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(AvailableEndpointsAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(AvailableEndpointsAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readActiveEndpointsAttribute(): ActiveEndpointsAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activeendpoints attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return ActiveEndpointsAttribute(decodedValue) + } + + suspend fun subscribeActiveEndpointsAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 1u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + ActiveEndpointsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activeendpoints attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ActiveEndpointsAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(ActiveEndpointsAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun subscribeGeneratedCommandListAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 65528u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun subscribeAcceptedCommandListAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 65529u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun subscribeEventListAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 65530u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + emit(EventListAttributeSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(EventListAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun subscribeAttributeListAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 65531u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun subscribeFeatureMapAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 65532u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + emit(UIntSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(UIntSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun subscribeClusterRevisionAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 65533u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + emit(UShortSubscriptionState.Success(decodedValue)) + } + SubscriptionState.SubscriptionEstablished -> { + emit(UShortSubscriptionState.SubscriptionEstablished) + } + } + } + } + + companion object { + private val logger = Logger.getLogger(PowerTopologyCluster::class.java.name) + const val CLUSTER_ID: UInt = 156u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt new file mode 100644 index 00000000000000..1618b5cc9ac5a9 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt @@ -0,0 +1,76 @@ +/* + * + * 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. + */ +package matter.controller.cluster.eventstructs + +import matter.controller.cluster.* +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent( + val ranges: + List +) { + override fun toString(): String = buildString { + append("ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent {\n") + append("\tranges : $ranges\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + startArray(ContextSpecificTag(TAG_RANGES)) + for (item in ranges.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + endStructure() + } + } + + companion object { + private const val TAG_RANGES = 0 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent { + tlvReader.enterStructure(tlvTag) + val ranges = + buildList< + matter.controller.cluster.structs.ElectricalPowerMeasurementClusterMeasurementRangeStruct + > { + tlvReader.enterArray(ContextSpecificTag(TAG_RANGES)) + while (!tlvReader.isEndOfContainer()) { + this.add( + matter.controller.cluster.structs + .ElectricalPowerMeasurementClusterMeasurementRangeStruct + .fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } + + tlvReader.exitContainer() + + return ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent(ranges) + } + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/files.gni b/src/controller/java/generated/java/matter/controller/cluster/files.gni index 83a43a79ffe791..f62cee23bdd5b3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/files.gni +++ b/src/controller/java/generated/java/matter/controller/cluster/files.gni @@ -55,9 +55,14 @@ matter_structs_sources = [ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseModeClusterModeOptionStruct.kt", @@ -161,6 +166,7 @@ matter_eventstructs_sources = [ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt", @@ -252,6 +258,7 @@ matter_clusters_sources = [ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalPowerMeasurementCluster.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseModeCluster.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyPreferenceCluster.kt", @@ -299,6 +306,7 @@ matter_clusters_sources = [ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerTopologyCluster.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt", diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt new file mode 100644 index 00000000000000..9ae505db1e48b3 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt @@ -0,0 +1,146 @@ +/* + * + * 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. + */ +package matter.controller.cluster.structs + +import java.util.Optional +import matter.controller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct( + val importedResetTimestamp: Optional?, + val exportedResetTimestamp: Optional?, + val importedResetSystime: Optional?, + val exportedResetSystime: Optional? +) { + override fun toString(): String = buildString { + append("ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct {\n") + append("\timportedResetTimestamp : $importedResetTimestamp\n") + append("\texportedResetTimestamp : $exportedResetTimestamp\n") + append("\timportedResetSystime : $importedResetSystime\n") + append("\texportedResetSystime : $exportedResetSystime\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + if (importedResetTimestamp != null) { + if (importedResetTimestamp.isPresent) { + val optimportedResetTimestamp = importedResetTimestamp.get() + put(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP), optimportedResetTimestamp) + } + } else { + putNull(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP)) + } + if (exportedResetTimestamp != null) { + if (exportedResetTimestamp.isPresent) { + val optexportedResetTimestamp = exportedResetTimestamp.get() + put(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP), optexportedResetTimestamp) + } + } else { + putNull(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP)) + } + if (importedResetSystime != null) { + if (importedResetSystime.isPresent) { + val optimportedResetSystime = importedResetSystime.get() + put(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME), optimportedResetSystime) + } + } else { + putNull(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME)) + } + if (exportedResetSystime != null) { + if (exportedResetSystime.isPresent) { + val optexportedResetSystime = exportedResetSystime.get() + put(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME), optexportedResetSystime) + } + } else { + putNull(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME)) + } + endStructure() + } + } + + companion object { + private const val TAG_IMPORTED_RESET_TIMESTAMP = 0 + private const val TAG_EXPORTED_RESET_TIMESTAMP = 1 + private const val TAG_IMPORTED_RESET_SYSTIME = 2 + private const val TAG_EXPORTED_RESET_SYSTIME = 3 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct { + tlvReader.enterStructure(tlvTag) + val importedResetTimestamp = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP)) + null + } + val exportedResetTimestamp = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP)) + null + } + val importedResetSystime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME)) + null + } + val exportedResetSystime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME)) + null + } + + tlvReader.exitContainer() + + return ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct( + importedResetTimestamp, + exportedResetTimestamp, + importedResetSystime, + exportedResetSystime + ) + } + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt new file mode 100644 index 00000000000000..54c2868f6dd8f0 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt @@ -0,0 +1,72 @@ +/* + * + * 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. + */ +package matter.controller.cluster.structs + +import matter.controller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalPowerMeasurementClusterHarmonicMeasurementStruct( + val order: UByte, + val measurement: Long? +) { + override fun toString(): String = buildString { + append("ElectricalPowerMeasurementClusterHarmonicMeasurementStruct {\n") + append("\torder : $order\n") + append("\tmeasurement : $measurement\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_ORDER), order) + if (measurement != null) { + put(ContextSpecificTag(TAG_MEASUREMENT), measurement) + } else { + putNull(ContextSpecificTag(TAG_MEASUREMENT)) + } + endStructure() + } + } + + companion object { + private const val TAG_ORDER = 0 + private const val TAG_MEASUREMENT = 1 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterHarmonicMeasurementStruct { + tlvReader.enterStructure(tlvTag) + val order = tlvReader.getUByte(ContextSpecificTag(TAG_ORDER)) + val measurement = + if (!tlvReader.isNull()) { + tlvReader.getLong(ContextSpecificTag(TAG_MEASUREMENT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MEASUREMENT)) + null + } + + tlvReader.exitContainer() + + return ElectricalPowerMeasurementClusterHarmonicMeasurementStruct(order, measurement) + } + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt new file mode 100644 index 00000000000000..18e5534ff45480 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt @@ -0,0 +1,150 @@ +/* + * + * 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. + */ +package matter.controller.cluster.structs + +import java.util.Optional +import matter.controller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct( + val rangeMin: Long, + val rangeMax: Long, + val percentMax: Optional, + val percentMin: Optional, + val percentTypical: Optional, + val fixedMax: Optional, + val fixedMin: Optional, + val fixedTypical: Optional +) { + override fun toString(): String = buildString { + append("ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct {\n") + append("\trangeMin : $rangeMin\n") + append("\trangeMax : $rangeMax\n") + append("\tpercentMax : $percentMax\n") + append("\tpercentMin : $percentMin\n") + append("\tpercentTypical : $percentTypical\n") + append("\tfixedMax : $fixedMax\n") + append("\tfixedMin : $fixedMin\n") + append("\tfixedTypical : $fixedTypical\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_RANGE_MIN), rangeMin) + put(ContextSpecificTag(TAG_RANGE_MAX), rangeMax) + if (percentMax.isPresent) { + val optpercentMax = percentMax.get() + put(ContextSpecificTag(TAG_PERCENT_MAX), optpercentMax) + } + if (percentMin.isPresent) { + val optpercentMin = percentMin.get() + put(ContextSpecificTag(TAG_PERCENT_MIN), optpercentMin) + } + if (percentTypical.isPresent) { + val optpercentTypical = percentTypical.get() + put(ContextSpecificTag(TAG_PERCENT_TYPICAL), optpercentTypical) + } + if (fixedMax.isPresent) { + val optfixedMax = fixedMax.get() + put(ContextSpecificTag(TAG_FIXED_MAX), optfixedMax) + } + if (fixedMin.isPresent) { + val optfixedMin = fixedMin.get() + put(ContextSpecificTag(TAG_FIXED_MIN), optfixedMin) + } + if (fixedTypical.isPresent) { + val optfixedTypical = fixedTypical.get() + put(ContextSpecificTag(TAG_FIXED_TYPICAL), optfixedTypical) + } + endStructure() + } + } + + companion object { + private const val TAG_RANGE_MIN = 0 + private const val TAG_RANGE_MAX = 1 + private const val TAG_PERCENT_MAX = 2 + private const val TAG_PERCENT_MIN = 3 + private const val TAG_PERCENT_TYPICAL = 4 + private const val TAG_FIXED_MAX = 5 + private const val TAG_FIXED_MIN = 6 + private const val TAG_FIXED_TYPICAL = 7 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct { + tlvReader.enterStructure(tlvTag) + val rangeMin = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MIN)) + val rangeMax = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MAX)) + val percentMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MAX))) + } else { + Optional.empty() + } + val percentMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MIN))) + } else { + Optional.empty() + } + val percentTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_TYPICAL))) + } else { + Optional.empty() + } + val fixedMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) + } else { + Optional.empty() + } + val fixedMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) + } else { + Optional.empty() + } + val fixedTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) + } else { + Optional.empty() + } + + tlvReader.exitContainer() + + return ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct( + rangeMin, + rangeMax, + percentMax, + percentMin, + percentTypical, + fixedMax, + fixedMin, + fixedTypical + ) + } + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt new file mode 100644 index 00000000000000..895b52e30fca5f --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt @@ -0,0 +1,100 @@ +/* + * + * 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. + */ +package matter.controller.cluster.structs + +import matter.controller.cluster.* +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalPowerMeasurementClusterMeasurementAccuracyStruct( + val measurementType: UShort, + val measured: Boolean, + val minMeasuredValue: Long, + val maxMeasuredValue: Long, + val accuracyRanges: List +) { + override fun toString(): String = buildString { + append("ElectricalPowerMeasurementClusterMeasurementAccuracyStruct {\n") + append("\tmeasurementType : $measurementType\n") + append("\tmeasured : $measured\n") + append("\tminMeasuredValue : $minMeasuredValue\n") + append("\tmaxMeasuredValue : $maxMeasuredValue\n") + append("\taccuracyRanges : $accuracyRanges\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_MEASUREMENT_TYPE), measurementType) + put(ContextSpecificTag(TAG_MEASURED), measured) + put(ContextSpecificTag(TAG_MIN_MEASURED_VALUE), minMeasuredValue) + put(ContextSpecificTag(TAG_MAX_MEASURED_VALUE), maxMeasuredValue) + startArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + for (item in accuracyRanges.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + endStructure() + } + } + + companion object { + private const val TAG_MEASUREMENT_TYPE = 0 + private const val TAG_MEASURED = 1 + private const val TAG_MIN_MEASURED_VALUE = 2 + private const val TAG_MAX_MEASURED_VALUE = 3 + private const val TAG_ACCURACY_RANGES = 4 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementAccuracyStruct { + tlvReader.enterStructure(tlvTag) + val measurementType = tlvReader.getUShort(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) + val measured = tlvReader.getBoolean(ContextSpecificTag(TAG_MEASURED)) + val minMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MIN_MEASURED_VALUE)) + val maxMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MAX_MEASURED_VALUE)) + val accuracyRanges = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + + tlvReader.exitContainer() + + return ElectricalPowerMeasurementClusterMeasurementAccuracyStruct( + measurementType, + measured, + minMeasuredValue, + maxMeasuredValue, + accuracyRanges + ) + } + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt new file mode 100644 index 00000000000000..4550a6a514b22e --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt @@ -0,0 +1,184 @@ +/* + * + * 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. + */ +package matter.controller.cluster.structs + +import java.util.Optional +import matter.controller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalPowerMeasurementClusterMeasurementRangeStruct( + val measurementType: UShort, + val min: Long, + val max: Long, + val startTimestamp: Optional, + val endTimestamp: Optional, + val minTimestamp: Optional, + val maxTimestamp: Optional, + val startSystime: Optional, + val endSystime: Optional, + val minSystime: Optional, + val maxSystime: Optional +) { + override fun toString(): String = buildString { + append("ElectricalPowerMeasurementClusterMeasurementRangeStruct {\n") + append("\tmeasurementType : $measurementType\n") + append("\tmin : $min\n") + append("\tmax : $max\n") + append("\tstartTimestamp : $startTimestamp\n") + append("\tendTimestamp : $endTimestamp\n") + append("\tminTimestamp : $minTimestamp\n") + append("\tmaxTimestamp : $maxTimestamp\n") + append("\tstartSystime : $startSystime\n") + append("\tendSystime : $endSystime\n") + append("\tminSystime : $minSystime\n") + append("\tmaxSystime : $maxSystime\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_MEASUREMENT_TYPE), measurementType) + put(ContextSpecificTag(TAG_MIN), min) + put(ContextSpecificTag(TAG_MAX), max) + if (startTimestamp.isPresent) { + val optstartTimestamp = startTimestamp.get() + put(ContextSpecificTag(TAG_START_TIMESTAMP), optstartTimestamp) + } + if (endTimestamp.isPresent) { + val optendTimestamp = endTimestamp.get() + put(ContextSpecificTag(TAG_END_TIMESTAMP), optendTimestamp) + } + if (minTimestamp.isPresent) { + val optminTimestamp = minTimestamp.get() + put(ContextSpecificTag(TAG_MIN_TIMESTAMP), optminTimestamp) + } + if (maxTimestamp.isPresent) { + val optmaxTimestamp = maxTimestamp.get() + put(ContextSpecificTag(TAG_MAX_TIMESTAMP), optmaxTimestamp) + } + if (startSystime.isPresent) { + val optstartSystime = startSystime.get() + put(ContextSpecificTag(TAG_START_SYSTIME), optstartSystime) + } + if (endSystime.isPresent) { + val optendSystime = endSystime.get() + put(ContextSpecificTag(TAG_END_SYSTIME), optendSystime) + } + if (minSystime.isPresent) { + val optminSystime = minSystime.get() + put(ContextSpecificTag(TAG_MIN_SYSTIME), optminSystime) + } + if (maxSystime.isPresent) { + val optmaxSystime = maxSystime.get() + put(ContextSpecificTag(TAG_MAX_SYSTIME), optmaxSystime) + } + endStructure() + } + } + + companion object { + private const val TAG_MEASUREMENT_TYPE = 0 + private const val TAG_MIN = 1 + private const val TAG_MAX = 2 + private const val TAG_START_TIMESTAMP = 3 + private const val TAG_END_TIMESTAMP = 4 + private const val TAG_MIN_TIMESTAMP = 5 + private const val TAG_MAX_TIMESTAMP = 6 + private const val TAG_START_SYSTIME = 7 + private const val TAG_END_SYSTIME = 8 + private const val TAG_MIN_SYSTIME = 9 + private const val TAG_MAX_SYSTIME = 10 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementRangeStruct { + tlvReader.enterStructure(tlvTag) + val measurementType = tlvReader.getUShort(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) + val min = tlvReader.getLong(ContextSpecificTag(TAG_MIN)) + val max = tlvReader.getLong(ContextSpecificTag(TAG_MAX)) + val startTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_START_TIMESTAMP))) + } else { + Optional.empty() + } + val endTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_END_TIMESTAMP))) + } else { + Optional.empty() + } + val minTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_TIMESTAMP))) + } else { + Optional.empty() + } + val maxTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_TIMESTAMP))) + } else { + Optional.empty() + } + val startSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) + } else { + Optional.empty() + } + val endSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) + } else { + Optional.empty() + } + val minSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_SYSTIME))) + } else { + Optional.empty() + } + val maxSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_SYSTIME))) + } else { + Optional.empty() + } + + tlvReader.exitContainer() + + return ElectricalPowerMeasurementClusterMeasurementRangeStruct( + measurementType, + min, + max, + startTimestamp, + endTimestamp, + minTimestamp, + maxTimestamp, + startSystime, + endSystime, + minSystime, + maxSystime + ) + } + } +} diff --git a/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java b/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java index 6f70ad885ec9b7..bbf247b09e5a9d 100644 --- a/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java +++ b/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java @@ -1326,6 +1326,8 @@ public void shutdownCommissioning() { shutdownCommissioning(deviceControllerPtr); } + public static native byte[] validateAndExtractCSR(byte[] csrElements, byte[] csrNonce); + private native PaseVerifierParams computePaseVerifier( long deviceControllerPtr, long devicePtr, long setupPincode, long iterations, byte[] salt); diff --git a/src/controller/java/src/chip/devicecontroller/ControllerParams.java b/src/controller/java/src/chip/devicecontroller/ControllerParams.java index c52147f73b83b1..ca41cf900902af 100644 --- a/src/controller/java/src/chip/devicecontroller/ControllerParams.java +++ b/src/controller/java/src/chip/devicecontroller/ControllerParams.java @@ -14,6 +14,7 @@ public final class ControllerParams { private final boolean attemptNetworkScanWiFi; private final boolean attemptNetworkScanThread; private final boolean skipCommissioningComplete; + private final boolean skipAttestationCertificateValidation; private final Optional countryCode; private final Optional regulatoryLocationType; @Nullable private final KeypairDelegate keypairDelegate; @@ -33,6 +34,7 @@ private ControllerParams(Builder builder) { this.attemptNetworkScanWiFi = builder.attemptNetworkScanWiFi; this.attemptNetworkScanThread = builder.attemptNetworkScanThread; this.skipCommissioningComplete = builder.skipCommissioningComplete; + this.skipAttestationCertificateValidation = builder.skipAttestationCertificateValidation; this.countryCode = builder.countryCode; this.regulatoryLocationType = builder.regulatoryLocationType; this.keypairDelegate = builder.keypairDelegate; @@ -76,6 +78,10 @@ public boolean getSkipCommissioningComplete() { return skipCommissioningComplete; } + public boolean getSkipAttestationCertificateValidation() { + return skipAttestationCertificateValidation; + } + public Optional getCountryCode() { return countryCode; } @@ -137,6 +143,7 @@ public static class Builder { private boolean attemptNetworkScanWiFi = false; private boolean attemptNetworkScanThread = false; private boolean skipCommissioningComplete = false; + private boolean skipAttestationCertificateValidation = false; private Optional countryCode = Optional.empty(); private Optional regulatoryLocationType = Optional.empty(); @Nullable private KeypairDelegate keypairDelegate = null; @@ -257,6 +264,21 @@ public Builder setSkipCommissioningComplete(boolean skipCommissioningComplete) { return this; } + /** + * Used when the Commissioner disables Attestation Certificate Validation. + * + *

Specifically, this sets SkipAttestationCertificateValidation in the + * CommissioningParameters passed to the CommissioningDelegate. + * + * @param skipAttestationCertificateValidation + * @return + */ + public Builder setSkipAttestationCertificateValidation( + boolean skipAttestationCertificateValidation) { + this.skipAttestationCertificateValidation = skipAttestationCertificateValidation; + return this; + } + /** * Sets the Regulatory Location country code passed to ChipDeviceCommissioner's * CommissioningParameters. diff --git a/src/controller/java/src/chip/devicecontroller/DiscoveredDevice.java b/src/controller/java/src/chip/devicecontroller/DiscoveredDevice.java index 3be9631512af42..01d6ecc28cce42 100644 --- a/src/controller/java/src/chip/devicecontroller/DiscoveredDevice.java +++ b/src/controller/java/src/chip/devicecontroller/DiscoveredDevice.java @@ -20,4 +20,5 @@ public class DiscoveredDevice { public long discriminator; public String ipAddress; + public int port; } diff --git a/src/controller/java/templates/partials/encode_value.zapt b/src/controller/java/templates/partials/encode_value.zapt deleted file mode 100644 index 3f6d573662ba9f..00000000000000 --- a/src/controller/java/templates/partials/encode_value.zapt +++ /dev/null @@ -1,61 +0,0 @@ -{{#if isOptional}} - if ({{source}} != nullptr) { - jobject optionalValue_{{depth}}; - chip::JniReferences::GetInstance().GetOptionalValue({{source}}, optionalValue_{{depth}}); - if (optionalValue_{{depth}} != nullptr) { - auto & definedValue_{{depth}} = {{target}}.Emplace(); - {{>encode_value target=(concat "definedValue_" depth) source=(concat "optionalValue_" depth) cluster=cluster depth=(incrementDepth depth) isOptional=false}} - } - } -{{else if isNullable}} - if ({{source}} == nullptr) { - {{target}}.SetNull(); - } else { - auto & nonNullValue_{{depth}} = {{target}}.SetNonNull(); - {{>encode_value target=(concat "nonNullValue_" depth) source=source cluster=cluster depth=(incrementDepth depth) isNullable=false}} - } -{{else if isArray}} - { - using ListType_{{depth}} = std::remove_reference_t; - using ListMemberType_{{depth}} = ListMemberTypeGetter::Type; - jint {{source}}Size; - chip::JniReferences::GetInstance().GetListSize({{source}}, {{source}}Size); - if ({{source}}Size != 0) { - auto * listHolder_{{depth}} = new ListHolder({{source}}Size); - listFreer.add(listHolder_{{depth}}); - - for (jint i_{{depth}} = 0; i_{{depth}} < {{source}}Size; ++i_{{depth}}) { - jobject element_{{depth}}; - chip::JniReferences::GetInstance().GetListItem({{source}}, i_{{depth}}, element_{{depth}}); - {{>encode_value target=(concat "listHolder_" depth "->mList[i_" depth "]") source=(concat "element_" depth) cluster=cluster depth=(incrementDepth depth) isArray=false}} - } - {{target}} = ListType_{{depth}}(listHolder_{{depth}}->mList, {{source}}Size); - } else { - {{target}} = ListType_{{depth}}(); - } - } -{{else if (isOctetString type)}} - cleanupByteArrays.push_back(chip::Platform::MakeUnique(env, static_cast({{source}}))); - {{target}} = cleanupByteArrays.back()->byteSpan(); -{{else if (isCharString type)}} - cleanupStrings.push_back(chip::Platform::MakeUnique(env, static_cast({{source}}))); - {{target}} = cleanupStrings.back()->charSpan(); -{{else}} - {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} - jobject {{../source}}_{{asLowerCamelCase label}}Item_{{../depth}}; - chip::JniReferences::GetInstance().GetObjectField({{../source}}, "{{asLowerCamelCase label}}", "{{asJniSignature type null (asUpperCamelCase ../cluster) true}}", {{../source}}_{{asLowerCamelCase label}}Item_{{../depth}}); - {{>encode_value target=(concat ../target "." (asLowerCamelCase label)) source=(concat ../source "_" (asLowerCamelCase label) "Item_" ../depth) cluster=../cluster depth=(incrementDepth ../depth)}} - {{/zcl_struct_items_by_struct_and_cluster_name}} - {{else}} - {{#if_chip_enum type}} - {{target}} = static_cast>(chip::JniReferences::GetInstance().{{asJavaType type null parent.parent.name forceNotList=true}}ToPrimitive({{source}})); - {{else}} - {{#if_is_strongly_typed_bitmap type}} - {{target}}.SetRaw(static_cast::IntegerType>(chip::JniReferences::GetInstance().{{asJavaType type null parent.parent.name forceNotList=true}}ToPrimitive({{source}}))); - {{else}} - {{target}} = static_cast>(chip::JniReferences::GetInstance().{{asJavaType type null parent.parent.name forceNotList=true}}ToPrimitive({{source}})); - {{/if_is_strongly_typed_bitmap}} - {{/if_chip_enum}} - {{/if_is_struct}} -{{/if}} diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index 96243f8da40123..7a8aebe5b5c493 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -19550,6 +19550,1080 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } break; } + case app::Clusters::ElectricalPowerMeasurement::Id: { + using namespace app::Clusters::ElectricalPowerMeasurement; + switch (aPath.mAttributeId) + { + case Attributes::PowerMode::Id: { + using TypeInfo = Attributes::PowerMode::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + jint jnivalue = static_cast(cppValue); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, + value); + return value; + } + case Attributes::NumberOfMeasurementTypes::Id: { + using TypeInfo = Attributes::NumberOfMeasurementTypes::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + jint jnivalue = static_cast(cppValue); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, + value); + return value; + } + case Attributes::Accuracy::Id: { + using TypeInfo = Attributes::Accuracy::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + jobject newElement_0_measurementType; + std::string newElement_0_measurementTypeClassName = "java/lang/Integer"; + std::string newElement_0_measurementTypeCtorSignature = "(I)V"; + jint jninewElement_0_measurementType = static_cast(entry_0.measurementType); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_measurementTypeClassName.c_str(), newElement_0_measurementTypeCtorSignature.c_str(), + jninewElement_0_measurementType, newElement_0_measurementType); + jobject newElement_0_measured; + std::string newElement_0_measuredClassName = "java/lang/Boolean"; + std::string newElement_0_measuredCtorSignature = "(Z)V"; + jboolean jninewElement_0_measured = static_cast(entry_0.measured); + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_measuredClassName.c_str(), + newElement_0_measuredCtorSignature.c_str(), + jninewElement_0_measured, newElement_0_measured); + jobject newElement_0_minMeasuredValue; + std::string newElement_0_minMeasuredValueClassName = "java/lang/Long"; + std::string newElement_0_minMeasuredValueCtorSignature = "(J)V"; + jlong jninewElement_0_minMeasuredValue = static_cast(entry_0.minMeasuredValue); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_minMeasuredValueClassName.c_str(), newElement_0_minMeasuredValueCtorSignature.c_str(), + jninewElement_0_minMeasuredValue, newElement_0_minMeasuredValue); + jobject newElement_0_maxMeasuredValue; + std::string newElement_0_maxMeasuredValueClassName = "java/lang/Long"; + std::string newElement_0_maxMeasuredValueCtorSignature = "(J)V"; + jlong jninewElement_0_maxMeasuredValue = static_cast(entry_0.maxMeasuredValue); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_maxMeasuredValueClassName.c_str(), newElement_0_maxMeasuredValueCtorSignature.c_str(), + jninewElement_0_maxMeasuredValue, newElement_0_maxMeasuredValue); + jobject newElement_0_accuracyRanges; + chip::JniReferences::GetInstance().CreateArrayList(newElement_0_accuracyRanges); + + auto iter_newElement_0_accuracyRanges_2 = entry_0.accuracyRanges.begin(); + while (iter_newElement_0_accuracyRanges_2.Next()) + { + auto & entry_2 = iter_newElement_0_accuracyRanges_2.GetValue(); + jobject newElement_2; + jobject newElement_2_rangeMin; + std::string newElement_2_rangeMinClassName = "java/lang/Long"; + std::string newElement_2_rangeMinCtorSignature = "(J)V"; + jlong jninewElement_2_rangeMin = static_cast(entry_2.rangeMin); + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_2_rangeMinClassName.c_str(), + newElement_2_rangeMinCtorSignature.c_str(), + jninewElement_2_rangeMin, newElement_2_rangeMin); + jobject newElement_2_rangeMax; + std::string newElement_2_rangeMaxClassName = "java/lang/Long"; + std::string newElement_2_rangeMaxCtorSignature = "(J)V"; + jlong jninewElement_2_rangeMax = static_cast(entry_2.rangeMax); + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_2_rangeMaxClassName.c_str(), + newElement_2_rangeMaxCtorSignature.c_str(), + jninewElement_2_rangeMax, newElement_2_rangeMax); + jobject newElement_2_percentMax; + if (!entry_2.percentMax.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_percentMax); + } + else + { + jobject newElement_2_percentMaxInsideOptional; + std::string newElement_2_percentMaxInsideOptionalClassName = "java/lang/Integer"; + std::string newElement_2_percentMaxInsideOptionalCtorSignature = "(I)V"; + jint jninewElement_2_percentMaxInsideOptional = static_cast(entry_2.percentMax.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_2_percentMaxInsideOptionalClassName.c_str(), + newElement_2_percentMaxInsideOptionalCtorSignature.c_str(), jninewElement_2_percentMaxInsideOptional, + newElement_2_percentMaxInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_2_percentMaxInsideOptional, + newElement_2_percentMax); + } + jobject newElement_2_percentMin; + if (!entry_2.percentMin.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_percentMin); + } + else + { + jobject newElement_2_percentMinInsideOptional; + std::string newElement_2_percentMinInsideOptionalClassName = "java/lang/Integer"; + std::string newElement_2_percentMinInsideOptionalCtorSignature = "(I)V"; + jint jninewElement_2_percentMinInsideOptional = static_cast(entry_2.percentMin.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_2_percentMinInsideOptionalClassName.c_str(), + newElement_2_percentMinInsideOptionalCtorSignature.c_str(), jninewElement_2_percentMinInsideOptional, + newElement_2_percentMinInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_2_percentMinInsideOptional, + newElement_2_percentMin); + } + jobject newElement_2_percentTypical; + if (!entry_2.percentTypical.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_percentTypical); + } + else + { + jobject newElement_2_percentTypicalInsideOptional; + std::string newElement_2_percentTypicalInsideOptionalClassName = "java/lang/Integer"; + std::string newElement_2_percentTypicalInsideOptionalCtorSignature = "(I)V"; + jint jninewElement_2_percentTypicalInsideOptional = static_cast(entry_2.percentTypical.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_2_percentTypicalInsideOptionalClassName.c_str(), + newElement_2_percentTypicalInsideOptionalCtorSignature.c_str(), + jninewElement_2_percentTypicalInsideOptional, newElement_2_percentTypicalInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_2_percentTypicalInsideOptional, + newElement_2_percentTypical); + } + jobject newElement_2_fixedMax; + if (!entry_2.fixedMax.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_fixedMax); + } + else + { + jobject newElement_2_fixedMaxInsideOptional; + std::string newElement_2_fixedMaxInsideOptionalClassName = "java/lang/Long"; + std::string newElement_2_fixedMaxInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_2_fixedMaxInsideOptional = static_cast(entry_2.fixedMax.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_2_fixedMaxInsideOptionalClassName.c_str(), + newElement_2_fixedMaxInsideOptionalCtorSignature.c_str(), jninewElement_2_fixedMaxInsideOptional, + newElement_2_fixedMaxInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_2_fixedMaxInsideOptional, + newElement_2_fixedMax); + } + jobject newElement_2_fixedMin; + if (!entry_2.fixedMin.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_fixedMin); + } + else + { + jobject newElement_2_fixedMinInsideOptional; + std::string newElement_2_fixedMinInsideOptionalClassName = "java/lang/Long"; + std::string newElement_2_fixedMinInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_2_fixedMinInsideOptional = static_cast(entry_2.fixedMin.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_2_fixedMinInsideOptionalClassName.c_str(), + newElement_2_fixedMinInsideOptionalCtorSignature.c_str(), jninewElement_2_fixedMinInsideOptional, + newElement_2_fixedMinInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_2_fixedMinInsideOptional, + newElement_2_fixedMin); + } + jobject newElement_2_fixedTypical; + if (!entry_2.fixedTypical.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_fixedTypical); + } + else + { + jobject newElement_2_fixedTypicalInsideOptional; + std::string newElement_2_fixedTypicalInsideOptionalClassName = "java/lang/Long"; + std::string newElement_2_fixedTypicalInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_2_fixedTypicalInsideOptional = static_cast(entry_2.fixedTypical.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_2_fixedTypicalInsideOptionalClassName.c_str(), + newElement_2_fixedTypicalInsideOptionalCtorSignature.c_str(), + jninewElement_2_fixedTypicalInsideOptional, newElement_2_fixedTypicalInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_2_fixedTypicalInsideOptional, + newElement_2_fixedTypical); + } + + jclass measurementAccuracyRangeStructStructClass_3; + err = chip::JniReferences::GetInstance().GetLocalClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct", + measurementAccuracyRangeStructStructClass_3); + if (err != CHIP_NO_ERROR) + { + ChipLogError( + Zcl, + "Could not find class ChipStructs$ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct"); + return nullptr; + } + + jmethodID measurementAccuracyRangeStructStructCtor_3; + err = chip::JniReferences::GetInstance().FindMethod( + env, measurementAccuracyRangeStructStructClass_3, "", + "(Ljava/lang/Long;Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" + "Optional;Ljava/util/Optional;Ljava/util/Optional;)V", + &measurementAccuracyRangeStructStructCtor_3); + if (err != CHIP_NO_ERROR || measurementAccuracyRangeStructStructCtor_3 == nullptr) + { + ChipLogError(Zcl, + "Could not find ChipStructs$ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct " + "constructor"); + return nullptr; + } + + newElement_2 = env->NewObject( + measurementAccuracyRangeStructStructClass_3, measurementAccuracyRangeStructStructCtor_3, + newElement_2_rangeMin, newElement_2_rangeMax, newElement_2_percentMax, newElement_2_percentMin, + newElement_2_percentTypical, newElement_2_fixedMax, newElement_2_fixedMin, newElement_2_fixedTypical); + chip::JniReferences::GetInstance().AddToList(newElement_0_accuracyRanges, newElement_2); + } + + jclass measurementAccuracyStructStructClass_1; + err = chip::JniReferences::GetInstance().GetLocalClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalPowerMeasurementClusterMeasurementAccuracyStruct", + measurementAccuracyStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, + "Could not find class ChipStructs$ElectricalPowerMeasurementClusterMeasurementAccuracyStruct"); + return nullptr; + } + + jmethodID measurementAccuracyStructStructCtor_1; + err = chip::JniReferences::GetInstance().FindMethod( + env, measurementAccuracyStructStructClass_1, "", + "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Long;Ljava/lang/Long;Ljava/util/ArrayList;)V", + &measurementAccuracyStructStructCtor_1); + if (err != CHIP_NO_ERROR || measurementAccuracyStructStructCtor_1 == nullptr) + { + ChipLogError( + Zcl, "Could not find ChipStructs$ElectricalPowerMeasurementClusterMeasurementAccuracyStruct constructor"); + return nullptr; + } + + newElement_0 = env->NewObject(measurementAccuracyStructStructClass_1, measurementAccuracyStructStructCtor_1, + newElement_0_measurementType, newElement_0_measured, newElement_0_minMeasuredValue, + newElement_0_maxMeasuredValue, newElement_0_accuracyRanges); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::Ranges::Id: { + using TypeInfo = Attributes::Ranges::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + jobject newElement_0_measurementType; + std::string newElement_0_measurementTypeClassName = "java/lang/Integer"; + std::string newElement_0_measurementTypeCtorSignature = "(I)V"; + jint jninewElement_0_measurementType = static_cast(entry_0.measurementType); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_measurementTypeClassName.c_str(), newElement_0_measurementTypeCtorSignature.c_str(), + jninewElement_0_measurementType, newElement_0_measurementType); + jobject newElement_0_min; + std::string newElement_0_minClassName = "java/lang/Long"; + std::string newElement_0_minCtorSignature = "(J)V"; + jlong jninewElement_0_min = static_cast(entry_0.min); + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_minClassName.c_str(), + newElement_0_minCtorSignature.c_str(), + jninewElement_0_min, newElement_0_min); + jobject newElement_0_max; + std::string newElement_0_maxClassName = "java/lang/Long"; + std::string newElement_0_maxCtorSignature = "(J)V"; + jlong jninewElement_0_max = static_cast(entry_0.max); + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_maxClassName.c_str(), + newElement_0_maxCtorSignature.c_str(), + jninewElement_0_max, newElement_0_max); + jobject newElement_0_startTimestamp; + if (!entry_0.startTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_startTimestamp); + } + else + { + jobject newElement_0_startTimestampInsideOptional; + std::string newElement_0_startTimestampInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_startTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_startTimestampInsideOptional = static_cast(entry_0.startTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_startTimestampInsideOptionalClassName.c_str(), + newElement_0_startTimestampInsideOptionalCtorSignature.c_str(), + jninewElement_0_startTimestampInsideOptional, newElement_0_startTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_startTimestampInsideOptional, + newElement_0_startTimestamp); + } + jobject newElement_0_endTimestamp; + if (!entry_0.endTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_endTimestamp); + } + else + { + jobject newElement_0_endTimestampInsideOptional; + std::string newElement_0_endTimestampInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_endTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_endTimestampInsideOptional = static_cast(entry_0.endTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_endTimestampInsideOptionalClassName.c_str(), + newElement_0_endTimestampInsideOptionalCtorSignature.c_str(), jninewElement_0_endTimestampInsideOptional, + newElement_0_endTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_endTimestampInsideOptional, + newElement_0_endTimestamp); + } + jobject newElement_0_minTimestamp; + if (!entry_0.minTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_minTimestamp); + } + else + { + jobject newElement_0_minTimestampInsideOptional; + std::string newElement_0_minTimestampInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_minTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_minTimestampInsideOptional = static_cast(entry_0.minTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_minTimestampInsideOptionalClassName.c_str(), + newElement_0_minTimestampInsideOptionalCtorSignature.c_str(), jninewElement_0_minTimestampInsideOptional, + newElement_0_minTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_minTimestampInsideOptional, + newElement_0_minTimestamp); + } + jobject newElement_0_maxTimestamp; + if (!entry_0.maxTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_maxTimestamp); + } + else + { + jobject newElement_0_maxTimestampInsideOptional; + std::string newElement_0_maxTimestampInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_maxTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_maxTimestampInsideOptional = static_cast(entry_0.maxTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_maxTimestampInsideOptionalClassName.c_str(), + newElement_0_maxTimestampInsideOptionalCtorSignature.c_str(), jninewElement_0_maxTimestampInsideOptional, + newElement_0_maxTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_maxTimestampInsideOptional, + newElement_0_maxTimestamp); + } + jobject newElement_0_startSystime; + if (!entry_0.startSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_startSystime); + } + else + { + jobject newElement_0_startSystimeInsideOptional; + std::string newElement_0_startSystimeInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_startSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_startSystimeInsideOptional = static_cast(entry_0.startSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_startSystimeInsideOptionalClassName.c_str(), + newElement_0_startSystimeInsideOptionalCtorSignature.c_str(), jninewElement_0_startSystimeInsideOptional, + newElement_0_startSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_startSystimeInsideOptional, + newElement_0_startSystime); + } + jobject newElement_0_endSystime; + if (!entry_0.endSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_endSystime); + } + else + { + jobject newElement_0_endSystimeInsideOptional; + std::string newElement_0_endSystimeInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_endSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_endSystimeInsideOptional = static_cast(entry_0.endSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_endSystimeInsideOptionalClassName.c_str(), + newElement_0_endSystimeInsideOptionalCtorSignature.c_str(), jninewElement_0_endSystimeInsideOptional, + newElement_0_endSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_endSystimeInsideOptional, + newElement_0_endSystime); + } + jobject newElement_0_minSystime; + if (!entry_0.minSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_minSystime); + } + else + { + jobject newElement_0_minSystimeInsideOptional; + std::string newElement_0_minSystimeInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_minSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_minSystimeInsideOptional = static_cast(entry_0.minSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_minSystimeInsideOptionalClassName.c_str(), + newElement_0_minSystimeInsideOptionalCtorSignature.c_str(), jninewElement_0_minSystimeInsideOptional, + newElement_0_minSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_minSystimeInsideOptional, + newElement_0_minSystime); + } + jobject newElement_0_maxSystime; + if (!entry_0.maxSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_maxSystime); + } + else + { + jobject newElement_0_maxSystimeInsideOptional; + std::string newElement_0_maxSystimeInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_maxSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_maxSystimeInsideOptional = static_cast(entry_0.maxSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_maxSystimeInsideOptionalClassName.c_str(), + newElement_0_maxSystimeInsideOptionalCtorSignature.c_str(), jninewElement_0_maxSystimeInsideOptional, + newElement_0_maxSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_maxSystimeInsideOptional, + newElement_0_maxSystime); + } + + jclass measurementRangeStructStructClass_1; + err = chip::JniReferences::GetInstance().GetLocalClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalPowerMeasurementClusterMeasurementRangeStruct", + measurementRangeStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$ElectricalPowerMeasurementClusterMeasurementRangeStruct"); + return nullptr; + } + + jmethodID measurementRangeStructStructCtor_1; + err = chip::JniReferences::GetInstance().FindMethod( + env, measurementRangeStructStructClass_1, "", + "(Ljava/lang/Integer;Ljava/lang/Long;Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" + "Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" + "Optional;)V", + &measurementRangeStructStructCtor_1); + if (err != CHIP_NO_ERROR || measurementRangeStructStructCtor_1 == nullptr) + { + ChipLogError(Zcl, + "Could not find ChipStructs$ElectricalPowerMeasurementClusterMeasurementRangeStruct constructor"); + return nullptr; + } + + newElement_0 = env->NewObject(measurementRangeStructStructClass_1, measurementRangeStructStructCtor_1, + newElement_0_measurementType, newElement_0_min, newElement_0_max, + newElement_0_startTimestamp, newElement_0_endTimestamp, newElement_0_minTimestamp, + newElement_0_maxTimestamp, newElement_0_startSystime, newElement_0_endSystime, + newElement_0_minSystime, newElement_0_maxSystime); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::Voltage::Id: { + using TypeInfo = Attributes::Voltage::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::ActiveCurrent::Id: { + using TypeInfo = Attributes::ActiveCurrent::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::ReactiveCurrent::Id: { + using TypeInfo = Attributes::ReactiveCurrent::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::ApparentCurrent::Id: { + using TypeInfo = Attributes::ApparentCurrent::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::ActivePower::Id: { + using TypeInfo = Attributes::ActivePower::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::ReactivePower::Id: { + using TypeInfo = Attributes::ReactivePower::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::ApparentPower::Id: { + using TypeInfo = Attributes::ApparentPower::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::RMSVoltage::Id: { + using TypeInfo = Attributes::RMSVoltage::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::RMSCurrent::Id: { + using TypeInfo = Attributes::RMSCurrent::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::RMSPower::Id: { + using TypeInfo = Attributes::RMSPower::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::Frequency::Id: { + using TypeInfo = Attributes::Frequency::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::HarmonicCurrents::Id: { + using TypeInfo = Attributes::HarmonicCurrents::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_1 = cppValue.Value().begin(); + while (iter_value_1.Next()) + { + auto & entry_1 = iter_value_1.GetValue(); + jobject newElement_1; + jobject newElement_1_order; + std::string newElement_1_orderClassName = "java/lang/Integer"; + std::string newElement_1_orderCtorSignature = "(I)V"; + jint jninewElement_1_order = static_cast(entry_1.order); + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_orderClassName.c_str(), + newElement_1_orderCtorSignature.c_str(), + jninewElement_1_order, newElement_1_order); + jobject newElement_1_measurement; + if (entry_1.measurement.IsNull()) + { + newElement_1_measurement = nullptr; + } + else + { + std::string newElement_1_measurementClassName = "java/lang/Long"; + std::string newElement_1_measurementCtorSignature = "(J)V"; + jlong jninewElement_1_measurement = static_cast(entry_1.measurement.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_1_measurementClassName.c_str(), newElement_1_measurementCtorSignature.c_str(), + jninewElement_1_measurement, newElement_1_measurement); + } + + jclass harmonicMeasurementStructStructClass_2; + err = chip::JniReferences::GetInstance().GetLocalClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalPowerMeasurementClusterHarmonicMeasurementStruct", + harmonicMeasurementStructStructClass_2); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, + "Could not find class ChipStructs$ElectricalPowerMeasurementClusterHarmonicMeasurementStruct"); + return nullptr; + } + + jmethodID harmonicMeasurementStructStructCtor_2; + err = chip::JniReferences::GetInstance().FindMethod(env, harmonicMeasurementStructStructClass_2, "", + "(Ljava/lang/Integer;Ljava/lang/Long;)V", + &harmonicMeasurementStructStructCtor_2); + if (err != CHIP_NO_ERROR || harmonicMeasurementStructStructCtor_2 == nullptr) + { + ChipLogError( + Zcl, + "Could not find ChipStructs$ElectricalPowerMeasurementClusterHarmonicMeasurementStruct constructor"); + return nullptr; + } + + newElement_1 = env->NewObject(harmonicMeasurementStructStructClass_2, harmonicMeasurementStructStructCtor_2, + newElement_1_order, newElement_1_measurement); + chip::JniReferences::GetInstance().AddToList(value, newElement_1); + } + } + return value; + } + case Attributes::HarmonicPhases::Id: { + using TypeInfo = Attributes::HarmonicPhases::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_1 = cppValue.Value().begin(); + while (iter_value_1.Next()) + { + auto & entry_1 = iter_value_1.GetValue(); + jobject newElement_1; + jobject newElement_1_order; + std::string newElement_1_orderClassName = "java/lang/Integer"; + std::string newElement_1_orderCtorSignature = "(I)V"; + jint jninewElement_1_order = static_cast(entry_1.order); + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_orderClassName.c_str(), + newElement_1_orderCtorSignature.c_str(), + jninewElement_1_order, newElement_1_order); + jobject newElement_1_measurement; + if (entry_1.measurement.IsNull()) + { + newElement_1_measurement = nullptr; + } + else + { + std::string newElement_1_measurementClassName = "java/lang/Long"; + std::string newElement_1_measurementCtorSignature = "(J)V"; + jlong jninewElement_1_measurement = static_cast(entry_1.measurement.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_1_measurementClassName.c_str(), newElement_1_measurementCtorSignature.c_str(), + jninewElement_1_measurement, newElement_1_measurement); + } + + jclass harmonicMeasurementStructStructClass_2; + err = chip::JniReferences::GetInstance().GetLocalClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalPowerMeasurementClusterHarmonicMeasurementStruct", + harmonicMeasurementStructStructClass_2); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, + "Could not find class ChipStructs$ElectricalPowerMeasurementClusterHarmonicMeasurementStruct"); + return nullptr; + } + + jmethodID harmonicMeasurementStructStructCtor_2; + err = chip::JniReferences::GetInstance().FindMethod(env, harmonicMeasurementStructStructClass_2, "", + "(Ljava/lang/Integer;Ljava/lang/Long;)V", + &harmonicMeasurementStructStructCtor_2); + if (err != CHIP_NO_ERROR || harmonicMeasurementStructStructCtor_2 == nullptr) + { + ChipLogError( + Zcl, + "Could not find ChipStructs$ElectricalPowerMeasurementClusterHarmonicMeasurementStruct constructor"); + return nullptr; + } + + newElement_1 = env->NewObject(harmonicMeasurementStructStructClass_2, harmonicMeasurementStructStructCtor_2, + newElement_1_order, newElement_1_measurement); + chip::JniReferences::GetInstance().AddToList(value, newElement_1); + } + } + return value; + } + case Attributes::PowerFactor::Id: { + using TypeInfo = Attributes::PowerFactor::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::NeutralCurrent::Id: { + using TypeInfo = Attributes::NeutralCurrent::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::GeneratedCommandList::Id: { + using TypeInfo = Attributes::GeneratedCommandList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::AcceptedCommandList::Id: { + using TypeInfo = Attributes::AcceptedCommandList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::EventList::Id: { + using TypeInfo = Attributes::EventList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::AttributeList::Id: { + using TypeInfo = Attributes::AttributeList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::FeatureMap::Id: { + using TypeInfo = Attributes::FeatureMap::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + return value; + } + case Attributes::ClusterRevision::Id: { + using TypeInfo = Attributes::ClusterRevision::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + jint jnivalue = static_cast(cppValue); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, + value); + return value; + } + default: + *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB; + break; + } + break; + } case app::Clusters::ElectricalEnergyMeasurement::Id: { using namespace app::Clusters::ElectricalEnergyMeasurement; switch (aPath.mAttributeId) @@ -20158,79 +21232,229 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR value_startTimestampInsideOptional); chip::JniReferences::GetInstance().CreateOptional(value_startTimestampInsideOptional, value_startTimestamp); } - jobject value_endTimestamp; - if (!cppValue.Value().endTimestamp.HasValue()) + jobject value_endTimestamp; + if (!cppValue.Value().endTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_endTimestamp); + } + else + { + jobject value_endTimestampInsideOptional; + std::string value_endTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_endTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_endTimestampInsideOptional = static_cast(cppValue.Value().endTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_endTimestampInsideOptionalClassName.c_str(), value_endTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_endTimestampInsideOptional, value_endTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_endTimestampInsideOptional, value_endTimestamp); + } + jobject value_startSystime; + if (!cppValue.Value().startSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_startSystime); + } + else + { + jobject value_startSystimeInsideOptional; + std::string value_startSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_startSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_startSystimeInsideOptional = static_cast(cppValue.Value().startSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_startSystimeInsideOptionalClassName.c_str(), value_startSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_startSystimeInsideOptional, value_startSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_startSystimeInsideOptional, value_startSystime); + } + jobject value_endSystime; + if (!cppValue.Value().endSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_endSystime); + } + else + { + jobject value_endSystimeInsideOptional; + std::string value_endSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_endSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_endSystimeInsideOptional = static_cast(cppValue.Value().endSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_endSystimeInsideOptionalClassName.c_str(), value_endSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_endSystimeInsideOptional, value_endSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_endSystimeInsideOptional, value_endSystime); + } + + jclass energyMeasurementStructStructClass_1; + err = chip::JniReferences::GetInstance().GetLocalClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", + energyMeasurementStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct"); + return nullptr; + } + + jmethodID energyMeasurementStructStructCtor_1; + err = chip::JniReferences::GetInstance().FindMethod( + env, energyMeasurementStructStructClass_1, "", + "(Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", + &energyMeasurementStructStructCtor_1); + if (err != CHIP_NO_ERROR || energyMeasurementStructStructCtor_1 == nullptr) + { + ChipLogError( + Zcl, "Could not find ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct constructor"); + return nullptr; + } + + value = env->NewObject(energyMeasurementStructStructClass_1, energyMeasurementStructStructCtor_1, value_energy, + value_startTimestamp, value_endTimestamp, value_startSystime, value_endSystime); + } + return value; + } + case Attributes::CumulativeEnergyReset::Id: { + using TypeInfo = Attributes::CumulativeEnergyReset::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + jobject value_importedResetTimestamp; + if (!cppValue.Value().importedResetTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_importedResetTimestamp); + } + else + { + jobject value_importedResetTimestampInsideOptional; + if (cppValue.Value().importedResetTimestamp.Value().IsNull()) + { + value_importedResetTimestampInsideOptional = nullptr; + } + else + { + std::string value_importedResetTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_importedResetTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_importedResetTimestampInsideOptional = + static_cast(cppValue.Value().importedResetTimestamp.Value().Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_importedResetTimestampInsideOptionalClassName.c_str(), + value_importedResetTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_importedResetTimestampInsideOptional, value_importedResetTimestampInsideOptional); + } + chip::JniReferences::GetInstance().CreateOptional(value_importedResetTimestampInsideOptional, + value_importedResetTimestamp); + } + jobject value_exportedResetTimestamp; + if (!cppValue.Value().exportedResetTimestamp.HasValue()) { - chip::JniReferences::GetInstance().CreateOptional(nullptr, value_endTimestamp); + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_exportedResetTimestamp); } else { - jobject value_endTimestampInsideOptional; - std::string value_endTimestampInsideOptionalClassName = "java/lang/Long"; - std::string value_endTimestampInsideOptionalCtorSignature = "(J)V"; - jlong jnivalue_endTimestampInsideOptional = static_cast(cppValue.Value().endTimestamp.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - value_endTimestampInsideOptionalClassName.c_str(), value_endTimestampInsideOptionalCtorSignature.c_str(), - jnivalue_endTimestampInsideOptional, value_endTimestampInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(value_endTimestampInsideOptional, value_endTimestamp); + jobject value_exportedResetTimestampInsideOptional; + if (cppValue.Value().exportedResetTimestamp.Value().IsNull()) + { + value_exportedResetTimestampInsideOptional = nullptr; + } + else + { + std::string value_exportedResetTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_exportedResetTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_exportedResetTimestampInsideOptional = + static_cast(cppValue.Value().exportedResetTimestamp.Value().Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_exportedResetTimestampInsideOptionalClassName.c_str(), + value_exportedResetTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_exportedResetTimestampInsideOptional, value_exportedResetTimestampInsideOptional); + } + chip::JniReferences::GetInstance().CreateOptional(value_exportedResetTimestampInsideOptional, + value_exportedResetTimestamp); } - jobject value_startSystime; - if (!cppValue.Value().startSystime.HasValue()) + jobject value_importedResetSystime; + if (!cppValue.Value().importedResetSystime.HasValue()) { - chip::JniReferences::GetInstance().CreateOptional(nullptr, value_startSystime); + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_importedResetSystime); } else { - jobject value_startSystimeInsideOptional; - std::string value_startSystimeInsideOptionalClassName = "java/lang/Long"; - std::string value_startSystimeInsideOptionalCtorSignature = "(J)V"; - jlong jnivalue_startSystimeInsideOptional = static_cast(cppValue.Value().startSystime.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - value_startSystimeInsideOptionalClassName.c_str(), value_startSystimeInsideOptionalCtorSignature.c_str(), - jnivalue_startSystimeInsideOptional, value_startSystimeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(value_startSystimeInsideOptional, value_startSystime); + jobject value_importedResetSystimeInsideOptional; + if (cppValue.Value().importedResetSystime.Value().IsNull()) + { + value_importedResetSystimeInsideOptional = nullptr; + } + else + { + std::string value_importedResetSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_importedResetSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_importedResetSystimeInsideOptional = + static_cast(cppValue.Value().importedResetSystime.Value().Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_importedResetSystimeInsideOptionalClassName.c_str(), + value_importedResetSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_importedResetSystimeInsideOptional, value_importedResetSystimeInsideOptional); + } + chip::JniReferences::GetInstance().CreateOptional(value_importedResetSystimeInsideOptional, + value_importedResetSystime); } - jobject value_endSystime; - if (!cppValue.Value().endSystime.HasValue()) + jobject value_exportedResetSystime; + if (!cppValue.Value().exportedResetSystime.HasValue()) { - chip::JniReferences::GetInstance().CreateOptional(nullptr, value_endSystime); + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_exportedResetSystime); } else { - jobject value_endSystimeInsideOptional; - std::string value_endSystimeInsideOptionalClassName = "java/lang/Long"; - std::string value_endSystimeInsideOptionalCtorSignature = "(J)V"; - jlong jnivalue_endSystimeInsideOptional = static_cast(cppValue.Value().endSystime.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - value_endSystimeInsideOptionalClassName.c_str(), value_endSystimeInsideOptionalCtorSignature.c_str(), - jnivalue_endSystimeInsideOptional, value_endSystimeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(value_endSystimeInsideOptional, value_endSystime); + jobject value_exportedResetSystimeInsideOptional; + if (cppValue.Value().exportedResetSystime.Value().IsNull()) + { + value_exportedResetSystimeInsideOptional = nullptr; + } + else + { + std::string value_exportedResetSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_exportedResetSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_exportedResetSystimeInsideOptional = + static_cast(cppValue.Value().exportedResetSystime.Value().Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_exportedResetSystimeInsideOptionalClassName.c_str(), + value_exportedResetSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_exportedResetSystimeInsideOptional, value_exportedResetSystimeInsideOptional); + } + chip::JniReferences::GetInstance().CreateOptional(value_exportedResetSystimeInsideOptional, + value_exportedResetSystime); } - jclass energyMeasurementStructStructClass_1; + jclass cumulativeEnergyResetStructStructClass_1; err = chip::JniReferences::GetInstance().GetLocalClassRef( - env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", - energyMeasurementStructStructClass_1); + env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct", + cumulativeEnergyResetStructStructClass_1); if (err != CHIP_NO_ERROR) { - ChipLogError(Zcl, "Could not find class ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct"); + ChipLogError(Zcl, + "Could not find class ChipStructs$ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct"); return nullptr; } - jmethodID energyMeasurementStructStructCtor_1; + jmethodID cumulativeEnergyResetStructStructCtor_1; err = chip::JniReferences::GetInstance().FindMethod( - env, energyMeasurementStructStructClass_1, "", - "(Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &energyMeasurementStructStructCtor_1); - if (err != CHIP_NO_ERROR || energyMeasurementStructStructCtor_1 == nullptr) + env, cumulativeEnergyResetStructStructClass_1, "", + "(Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", + &cumulativeEnergyResetStructStructCtor_1); + if (err != CHIP_NO_ERROR || cumulativeEnergyResetStructStructCtor_1 == nullptr) { ChipLogError( - Zcl, "Could not find ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct constructor"); + Zcl, + "Could not find ChipStructs$ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct constructor"); return nullptr; } - value = env->NewObject(energyMeasurementStructStructClass_1, energyMeasurementStructStructCtor_1, value_energy, - value_startTimestamp, value_endTimestamp, value_startSystime, value_endSystime); + value = env->NewObject(cumulativeEnergyResetStructStructClass_1, cumulativeEnergyResetStructStructCtor_1, + value_importedResetTimestamp, value_exportedResetTimestamp, value_importedResetSystime, + value_exportedResetSystime); } return value; } @@ -23881,6 +25105,198 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } break; } + case app::Clusters::PowerTopology::Id: { + using namespace app::Clusters::PowerTopology; + switch (aPath.mAttributeId) + { + case Attributes::AvailableEndpoints::Id: { + using TypeInfo = Attributes::AvailableEndpoints::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Integer"; + std::string newElement_0CtorSignature = "(I)V"; + jint jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::ActiveEndpoints::Id: { + using TypeInfo = Attributes::ActiveEndpoints::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Integer"; + std::string newElement_0CtorSignature = "(I)V"; + jint jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::GeneratedCommandList::Id: { + using TypeInfo = Attributes::GeneratedCommandList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::AcceptedCommandList::Id: { + using TypeInfo = Attributes::AcceptedCommandList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::EventList::Id: { + using TypeInfo = Attributes::EventList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::AttributeList::Id: { + using TypeInfo = Attributes::AttributeList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::FeatureMap::Id: { + using TypeInfo = Attributes::FeatureMap::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + return value; + } + case Attributes::ClusterRevision::Id: { + using TypeInfo = Attributes::ClusterRevision::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + jint jnivalue = static_cast(cppValue); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, + value); + return value; + } + default: + *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB; + break; + } + break; + } case app::Clusters::EnergyEvseMode::Id: { using namespace app::Clusters::EnergyEvseMode; switch (aPath.mAttributeId) diff --git a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp index ebab2644189f6a..370e510894c121 100644 --- a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp @@ -4055,6 +4055,255 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } break; } + case app::Clusters::ElectricalPowerMeasurement::Id: { + using namespace app::Clusters::ElectricalPowerMeasurement; + switch (aPath.mEventId) + { + case Events::MeasurementPeriodRanges::Id: { + Events::MeasurementPeriodRanges::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value_ranges; + chip::JniReferences::GetInstance().CreateArrayList(value_ranges); + + auto iter_value_ranges_0 = cppValue.ranges.begin(); + while (iter_value_ranges_0.Next()) + { + auto & entry_0 = iter_value_ranges_0.GetValue(); + jobject newElement_0; + jobject newElement_0_measurementType; + std::string newElement_0_measurementTypeClassName = "java/lang/Integer"; + std::string newElement_0_measurementTypeCtorSignature = "(I)V"; + jint jninewElement_0_measurementType = static_cast(entry_0.measurementType); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_measurementTypeClassName.c_str(), newElement_0_measurementTypeCtorSignature.c_str(), + jninewElement_0_measurementType, newElement_0_measurementType); + jobject newElement_0_min; + std::string newElement_0_minClassName = "java/lang/Long"; + std::string newElement_0_minCtorSignature = "(J)V"; + jlong jninewElement_0_min = static_cast(entry_0.min); + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_minClassName.c_str(), + newElement_0_minCtorSignature.c_str(), + jninewElement_0_min, newElement_0_min); + jobject newElement_0_max; + std::string newElement_0_maxClassName = "java/lang/Long"; + std::string newElement_0_maxCtorSignature = "(J)V"; + jlong jninewElement_0_max = static_cast(entry_0.max); + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_maxClassName.c_str(), + newElement_0_maxCtorSignature.c_str(), + jninewElement_0_max, newElement_0_max); + jobject newElement_0_startTimestamp; + if (!entry_0.startTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_startTimestamp); + } + else + { + jobject newElement_0_startTimestampInsideOptional; + std::string newElement_0_startTimestampInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_startTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_startTimestampInsideOptional = static_cast(entry_0.startTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_startTimestampInsideOptionalClassName.c_str(), + newElement_0_startTimestampInsideOptionalCtorSignature.c_str(), + jninewElement_0_startTimestampInsideOptional, newElement_0_startTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_startTimestampInsideOptional, + newElement_0_startTimestamp); + } + jobject newElement_0_endTimestamp; + if (!entry_0.endTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_endTimestamp); + } + else + { + jobject newElement_0_endTimestampInsideOptional; + std::string newElement_0_endTimestampInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_endTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_endTimestampInsideOptional = static_cast(entry_0.endTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_endTimestampInsideOptionalClassName.c_str(), + newElement_0_endTimestampInsideOptionalCtorSignature.c_str(), jninewElement_0_endTimestampInsideOptional, + newElement_0_endTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_endTimestampInsideOptional, + newElement_0_endTimestamp); + } + jobject newElement_0_minTimestamp; + if (!entry_0.minTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_minTimestamp); + } + else + { + jobject newElement_0_minTimestampInsideOptional; + std::string newElement_0_minTimestampInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_minTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_minTimestampInsideOptional = static_cast(entry_0.minTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_minTimestampInsideOptionalClassName.c_str(), + newElement_0_minTimestampInsideOptionalCtorSignature.c_str(), jninewElement_0_minTimestampInsideOptional, + newElement_0_minTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_minTimestampInsideOptional, + newElement_0_minTimestamp); + } + jobject newElement_0_maxTimestamp; + if (!entry_0.maxTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_maxTimestamp); + } + else + { + jobject newElement_0_maxTimestampInsideOptional; + std::string newElement_0_maxTimestampInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_maxTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_maxTimestampInsideOptional = static_cast(entry_0.maxTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_maxTimestampInsideOptionalClassName.c_str(), + newElement_0_maxTimestampInsideOptionalCtorSignature.c_str(), jninewElement_0_maxTimestampInsideOptional, + newElement_0_maxTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_maxTimestampInsideOptional, + newElement_0_maxTimestamp); + } + jobject newElement_0_startSystime; + if (!entry_0.startSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_startSystime); + } + else + { + jobject newElement_0_startSystimeInsideOptional; + std::string newElement_0_startSystimeInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_startSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_startSystimeInsideOptional = static_cast(entry_0.startSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_startSystimeInsideOptionalClassName.c_str(), + newElement_0_startSystimeInsideOptionalCtorSignature.c_str(), jninewElement_0_startSystimeInsideOptional, + newElement_0_startSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_startSystimeInsideOptional, + newElement_0_startSystime); + } + jobject newElement_0_endSystime; + if (!entry_0.endSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_endSystime); + } + else + { + jobject newElement_0_endSystimeInsideOptional; + std::string newElement_0_endSystimeInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_endSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_endSystimeInsideOptional = static_cast(entry_0.endSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_endSystimeInsideOptionalClassName.c_str(), + newElement_0_endSystimeInsideOptionalCtorSignature.c_str(), jninewElement_0_endSystimeInsideOptional, + newElement_0_endSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_endSystimeInsideOptional, + newElement_0_endSystime); + } + jobject newElement_0_minSystime; + if (!entry_0.minSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_minSystime); + } + else + { + jobject newElement_0_minSystimeInsideOptional; + std::string newElement_0_minSystimeInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_minSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_minSystimeInsideOptional = static_cast(entry_0.minSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_minSystimeInsideOptionalClassName.c_str(), + newElement_0_minSystimeInsideOptionalCtorSignature.c_str(), jninewElement_0_minSystimeInsideOptional, + newElement_0_minSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_minSystimeInsideOptional, + newElement_0_minSystime); + } + jobject newElement_0_maxSystime; + if (!entry_0.maxSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_maxSystime); + } + else + { + jobject newElement_0_maxSystimeInsideOptional; + std::string newElement_0_maxSystimeInsideOptionalClassName = "java/lang/Long"; + std::string newElement_0_maxSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_0_maxSystimeInsideOptional = static_cast(entry_0.maxSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_maxSystimeInsideOptionalClassName.c_str(), + newElement_0_maxSystimeInsideOptionalCtorSignature.c_str(), jninewElement_0_maxSystimeInsideOptional, + newElement_0_maxSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_maxSystimeInsideOptional, + newElement_0_maxSystime); + } + + jclass measurementRangeStructStructClass_1; + err = chip::JniReferences::GetInstance().GetLocalClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalPowerMeasurementClusterMeasurementRangeStruct", + measurementRangeStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$ElectricalPowerMeasurementClusterMeasurementRangeStruct"); + return nullptr; + } + + jmethodID measurementRangeStructStructCtor_1; + err = chip::JniReferences::GetInstance().FindMethod( + env, measurementRangeStructStructClass_1, "", + "(Ljava/lang/Integer;Ljava/lang/Long;Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" + "Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" + "Optional;)V", + &measurementRangeStructStructCtor_1); + if (err != CHIP_NO_ERROR || measurementRangeStructStructCtor_1 == nullptr) + { + ChipLogError(Zcl, + "Could not find ChipStructs$ElectricalPowerMeasurementClusterMeasurementRangeStruct constructor"); + return nullptr; + } + + newElement_0 = env->NewObject(measurementRangeStructStructClass_1, measurementRangeStructStructCtor_1, + newElement_0_measurementType, newElement_0_min, newElement_0_max, + newElement_0_startTimestamp, newElement_0_endTimestamp, newElement_0_minTimestamp, + newElement_0_maxTimestamp, newElement_0_startSystime, newElement_0_endSystime, + newElement_0_minSystime, newElement_0_maxSystime); + chip::JniReferences::GetInstance().AddToList(value_ranges, newElement_0); + } + + jclass measurementPeriodRangesStructClass; + err = chip::JniReferences::GetInstance().GetLocalClassRef( + env, "chip/devicecontroller/ChipEventStructs$ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent", + measurementPeriodRangesStructClass); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, + "Could not find class ChipEventStructs$ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent"); + return nullptr; + } + + jmethodID measurementPeriodRangesStructCtor; + err = chip::JniReferences::GetInstance().FindMethod(env, measurementPeriodRangesStructClass, "", + "(Ljava/util/ArrayList;)V", &measurementPeriodRangesStructCtor); + if (err != CHIP_NO_ERROR || measurementPeriodRangesStructCtor == nullptr) + { + ChipLogError( + Zcl, + "Could not find ChipEventStructs$ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent constructor"); + return nullptr; + } + + jobject value = env->NewObject(measurementPeriodRangesStructClass, measurementPeriodRangesStructCtor, value_ranges); + + return value; + } + default: + *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; + break; + } + break; + } case app::Clusters::ElectricalEnergyMeasurement::Id: { using namespace app::Clusters::ElectricalEnergyMeasurement; switch (aPath.mEventId) @@ -5817,6 +6066,16 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } break; } + case app::Clusters::PowerTopology::Id: { + using namespace app::Clusters::PowerTopology; + switch (aPath.mEventId) + { + default: + *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; + break; + } + break; + } case app::Clusters::EnergyEvseMode::Id: { using namespace app::Clusters::EnergyEvseMode; switch (aPath.mEventId) diff --git a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp b/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp deleted file mode 100644 index 81f52531281c3d..00000000000000 --- a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp +++ /dev/null @@ -1,8525 +0,0 @@ -/* - * - * 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. - */ - -// THIS FILE IS GENERATED BY ZAP -#include "CHIPInvokeCallbacks.h" -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace chip { - -CHIPGroupsClusterAddGroupResponseCallback::CHIPGroupsClusterAddGroupResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGroupsClusterAddGroupResponseCallback::~CHIPGroupsClusterAddGroupResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGroupsClusterAddGroupResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr cppCallback( - reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID); -} -CHIPGroupsClusterViewGroupResponseCallback::CHIPGroupsClusterViewGroupResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGroupsClusterViewGroupResponseCallback::~CHIPGroupsClusterViewGroupResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGroupsClusterViewGroupResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::Groups::Commands::ViewGroupResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr cppCallback( - reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/String;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - jobject GroupName; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.groupName, GroupName)); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, GroupName); -} -CHIPGroupsClusterGetGroupMembershipResponseCallback::CHIPGroupsClusterGetGroupMembershipResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGroupsClusterGetGroupMembershipResponseCallback::~CHIPGroupsClusterGetGroupMembershipResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGroupsClusterGetGroupMembershipResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::Groups::Commands::GetGroupMembershipResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/ArrayList;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Capacity; - if (dataResponse.capacity.IsNull()) - { - Capacity = nullptr; - } - else - { - std::string CapacityClassName = "java/lang/Integer"; - std::string CapacityCtorSignature = "(I)V"; - jint jniCapacity = static_cast(dataResponse.capacity.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(CapacityClassName.c_str(), CapacityCtorSignature.c_str(), - jniCapacity, Capacity); - } - jobject GroupList; - chip::JniReferences::GetInstance().CreateArrayList(GroupList); - - auto iter_GroupList_0 = dataResponse.groupList.begin(); - while (iter_GroupList_0.Next()) - { - auto & entry_0 = iter_GroupList_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Integer"; - std::string newElement_0CtorSignature = "(I)V"; - jint jninewElement_0 = static_cast(entry_0); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), - jninewElement_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(GroupList, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Capacity, GroupList); -} -CHIPGroupsClusterRemoveGroupResponseCallback::CHIPGroupsClusterRemoveGroupResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGroupsClusterRemoveGroupResponseCallback::~CHIPGroupsClusterRemoveGroupResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGroupsClusterRemoveGroupResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::Groups::Commands::RemoveGroupResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID); -} -CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback::CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback::~CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImageResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" - "Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject DelayedActionTime; - if (!dataResponse.delayedActionTime.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, DelayedActionTime); - } - else - { - jobject DelayedActionTimeInsideOptional; - std::string DelayedActionTimeInsideOptionalClassName = "java/lang/Long"; - std::string DelayedActionTimeInsideOptionalCtorSignature = "(J)V"; - jlong jniDelayedActionTimeInsideOptional = static_cast(dataResponse.delayedActionTime.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - DelayedActionTimeInsideOptionalClassName.c_str(), DelayedActionTimeInsideOptionalCtorSignature.c_str(), - jniDelayedActionTimeInsideOptional, DelayedActionTimeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(DelayedActionTimeInsideOptional, DelayedActionTime); - } - jobject ImageURI; - if (!dataResponse.imageURI.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, ImageURI); - } - else - { - jobject ImageURIInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.imageURI.Value(), ImageURIInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(ImageURIInsideOptional, ImageURI); - } - jobject SoftwareVersion; - if (!dataResponse.softwareVersion.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, SoftwareVersion); - } - else - { - jobject SoftwareVersionInsideOptional; - std::string SoftwareVersionInsideOptionalClassName = "java/lang/Long"; - std::string SoftwareVersionInsideOptionalCtorSignature = "(J)V"; - jlong jniSoftwareVersionInsideOptional = static_cast(dataResponse.softwareVersion.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - SoftwareVersionInsideOptionalClassName.c_str(), SoftwareVersionInsideOptionalCtorSignature.c_str(), - jniSoftwareVersionInsideOptional, SoftwareVersionInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(SoftwareVersionInsideOptional, SoftwareVersion); - } - jobject SoftwareVersionString; - if (!dataResponse.softwareVersionString.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, SoftwareVersionString); - } - else - { - jobject SoftwareVersionStringInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.softwareVersionString.Value(), - SoftwareVersionStringInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(SoftwareVersionStringInsideOptional, SoftwareVersionString); - } - jobject UpdateToken; - if (!dataResponse.updateToken.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, UpdateToken); - } - else - { - jobject UpdateTokenInsideOptional; - jbyteArray UpdateTokenInsideOptionalByteArray = - env->NewByteArray(static_cast(dataResponse.updateToken.Value().size())); - env->SetByteArrayRegion(UpdateTokenInsideOptionalByteArray, 0, static_cast(dataResponse.updateToken.Value().size()), - reinterpret_cast(dataResponse.updateToken.Value().data())); - UpdateTokenInsideOptional = UpdateTokenInsideOptionalByteArray; - chip::JniReferences::GetInstance().CreateOptional(UpdateTokenInsideOptional, UpdateToken); - } - jobject UserConsentNeeded; - if (!dataResponse.userConsentNeeded.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, UserConsentNeeded); - } - else - { - jobject UserConsentNeededInsideOptional; - std::string UserConsentNeededInsideOptionalClassName = "java/lang/Boolean"; - std::string UserConsentNeededInsideOptionalCtorSignature = "(Z)V"; - jboolean jniUserConsentNeededInsideOptional = static_cast(dataResponse.userConsentNeeded.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - UserConsentNeededInsideOptionalClassName.c_str(), UserConsentNeededInsideOptionalCtorSignature.c_str(), - jniUserConsentNeededInsideOptional, UserConsentNeededInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(UserConsentNeededInsideOptional, UserConsentNeeded); - } - jobject MetadataForRequestor; - if (!dataResponse.metadataForRequestor.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, MetadataForRequestor); - } - else - { - jobject MetadataForRequestorInsideOptional; - jbyteArray MetadataForRequestorInsideOptionalByteArray = - env->NewByteArray(static_cast(dataResponse.metadataForRequestor.Value().size())); - env->SetByteArrayRegion(MetadataForRequestorInsideOptionalByteArray, 0, - static_cast(dataResponse.metadataForRequestor.Value().size()), - reinterpret_cast(dataResponse.metadataForRequestor.Value().data())); - MetadataForRequestorInsideOptional = MetadataForRequestorInsideOptionalByteArray; - chip::JniReferences::GetInstance().CreateOptional(MetadataForRequestorInsideOptional, MetadataForRequestor); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, DelayedActionTime, ImageURI, SoftwareVersion, SoftwareVersionString, - UpdateToken, UserConsentNeeded, MetadataForRequestor); -} -CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback::CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback( - jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback::~CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Long;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Action; - std::string ActionClassName = "java/lang/Integer"; - std::string ActionCtorSignature = "(I)V"; - jint jniAction = static_cast(dataResponse.action); - chip::JniReferences::GetInstance().CreateBoxedObject(ActionClassName.c_str(), ActionCtorSignature.c_str(), jniAction, - Action); - jobject DelayedActionTime; - std::string DelayedActionTimeClassName = "java/lang/Long"; - std::string DelayedActionTimeCtorSignature = "(J)V"; - jlong jniDelayedActionTime = static_cast(dataResponse.delayedActionTime); - chip::JniReferences::GetInstance().CreateBoxedObject( - DelayedActionTimeClassName.c_str(), DelayedActionTimeCtorSignature.c_str(), jniDelayedActionTime, DelayedActionTime); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Action, DelayedActionTime); -} -CHIPGeneralCommissioningClusterArmFailSafeResponseCallback::CHIPGeneralCommissioningClusterArmFailSafeResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGeneralCommissioningClusterArmFailSafeResponseCallback::~CHIPGeneralCommissioningClusterArmFailSafeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGeneralCommissioningClusterArmFailSafeResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::GeneralCommissioning::Commands::ArmFailSafeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/String;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject ErrorCode; - std::string ErrorCodeClassName = "java/lang/Integer"; - std::string ErrorCodeCtorSignature = "(I)V"; - jint jniErrorCode = static_cast(dataResponse.errorCode); - chip::JniReferences::GetInstance().CreateBoxedObject(ErrorCodeClassName.c_str(), ErrorCodeCtorSignature.c_str(), - jniErrorCode, ErrorCode); - jobject DebugText; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText, DebugText)); - - env->CallVoidMethod(javaCallbackRef, javaMethod, ErrorCode, DebugText); -} -CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback:: -CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback::~ -CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfigResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/String;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject ErrorCode; - std::string ErrorCodeClassName = "java/lang/Integer"; - std::string ErrorCodeCtorSignature = "(I)V"; - jint jniErrorCode = static_cast(dataResponse.errorCode); - chip::JniReferences::GetInstance().CreateBoxedObject(ErrorCodeClassName.c_str(), ErrorCodeCtorSignature.c_str(), - jniErrorCode, ErrorCode); - jobject DebugText; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText, DebugText)); - - env->CallVoidMethod(javaCallbackRef, javaMethod, ErrorCode, DebugText); -} -CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback:: -CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback::~ -CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::GeneralCommissioning::Commands::CommissioningCompleteResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/String;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject ErrorCode; - std::string ErrorCodeClassName = "java/lang/Integer"; - std::string ErrorCodeCtorSignature = "(I)V"; - jint jniErrorCode = static_cast(dataResponse.errorCode); - chip::JniReferences::GetInstance().CreateBoxedObject(ErrorCodeClassName.c_str(), ErrorCodeCtorSignature.c_str(), - jniErrorCode, ErrorCode); - jobject DebugText; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText, DebugText)); - - env->CallVoidMethod(javaCallbackRef, javaMethod, ErrorCode, DebugText); -} -CHIPNetworkCommissioningClusterScanNetworksResponseCallback::CHIPNetworkCommissioningClusterScanNetworksResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPNetworkCommissioningClusterScanNetworksResponseCallback::~CHIPNetworkCommissioningClusterScanNetworksResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPNetworkCommissioningClusterScanNetworksResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::NetworkCommissioning::Commands::ScanNetworksResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject NetworkingStatus; - std::string NetworkingStatusClassName = "java/lang/Integer"; - std::string NetworkingStatusCtorSignature = "(I)V"; - jint jniNetworkingStatus = static_cast(dataResponse.networkingStatus); - chip::JniReferences::GetInstance().CreateBoxedObject( - NetworkingStatusClassName.c_str(), NetworkingStatusCtorSignature.c_str(), jniNetworkingStatus, NetworkingStatus); - jobject DebugText; - if (!dataResponse.debugText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, DebugText); - } - else - { - jobject DebugTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); - } - jobject WiFiScanResults; - if (!dataResponse.wiFiScanResults.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, WiFiScanResults); - } - else - { - jobject WiFiScanResultsInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(WiFiScanResultsInsideOptional); - - auto iter_WiFiScanResultsInsideOptional_1 = dataResponse.wiFiScanResults.Value().begin(); - while (iter_WiFiScanResultsInsideOptional_1.Next()) - { - auto & entry_1 = iter_WiFiScanResultsInsideOptional_1.GetValue(); - jobject newElement_1; - jobject newElement_1_security; - std::string newElement_1_securityClassName = "java/lang/Integer"; - std::string newElement_1_securityCtorSignature = "(I)V"; - jint jninewElement_1_security = static_cast(entry_1.security.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_securityClassName.c_str(), - newElement_1_securityCtorSignature.c_str(), - jninewElement_1_security, newElement_1_security); - jobject newElement_1_ssid; - jbyteArray newElement_1_ssidByteArray = env->NewByteArray(static_cast(entry_1.ssid.size())); - env->SetByteArrayRegion(newElement_1_ssidByteArray, 0, static_cast(entry_1.ssid.size()), - reinterpret_cast(entry_1.ssid.data())); - newElement_1_ssid = newElement_1_ssidByteArray; - jobject newElement_1_bssid; - jbyteArray newElement_1_bssidByteArray = env->NewByteArray(static_cast(entry_1.bssid.size())); - env->SetByteArrayRegion(newElement_1_bssidByteArray, 0, static_cast(entry_1.bssid.size()), - reinterpret_cast(entry_1.bssid.data())); - newElement_1_bssid = newElement_1_bssidByteArray; - jobject newElement_1_channel; - std::string newElement_1_channelClassName = "java/lang/Integer"; - std::string newElement_1_channelCtorSignature = "(I)V"; - jint jninewElement_1_channel = static_cast(entry_1.channel); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_channelClassName.c_str(), - newElement_1_channelCtorSignature.c_str(), - jninewElement_1_channel, newElement_1_channel); - jobject newElement_1_wiFiBand; - std::string newElement_1_wiFiBandClassName = "java/lang/Integer"; - std::string newElement_1_wiFiBandCtorSignature = "(I)V"; - jint jninewElement_1_wiFiBand = static_cast(entry_1.wiFiBand); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_wiFiBandClassName.c_str(), - newElement_1_wiFiBandCtorSignature.c_str(), - jninewElement_1_wiFiBand, newElement_1_wiFiBand); - jobject newElement_1_rssi; - std::string newElement_1_rssiClassName = "java/lang/Integer"; - std::string newElement_1_rssiCtorSignature = "(I)V"; - jint jninewElement_1_rssi = static_cast(entry_1.rssi); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_rssiClassName.c_str(), - newElement_1_rssiCtorSignature.c_str(), jninewElement_1_rssi, - newElement_1_rssi); - - jclass wiFiInterfaceScanResultStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$NetworkCommissioningClusterWiFiInterfaceScanResultStruct", - wiFiInterfaceScanResultStructStructClass_2); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$NetworkCommissioningClusterWiFiInterfaceScanResultStruct"); - return; - } - - jmethodID wiFiInterfaceScanResultStructStructCtor_2; - err = chip::JniReferences::GetInstance().FindMethod( - env, wiFiInterfaceScanResultStructStructClass_2, "", - "(Ljava/lang/Integer;[B[BLjava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", - &wiFiInterfaceScanResultStructStructCtor_2); - if (err != CHIP_NO_ERROR || wiFiInterfaceScanResultStructStructCtor_2 == nullptr) - { - ChipLogError(Zcl, - "Could not find ChipStructs$NetworkCommissioningClusterWiFiInterfaceScanResultStruct constructor"); - return; - } - - newElement_1 = env->NewObject(wiFiInterfaceScanResultStructStructClass_2, wiFiInterfaceScanResultStructStructCtor_2, - newElement_1_security, newElement_1_ssid, newElement_1_bssid, newElement_1_channel, - newElement_1_wiFiBand, newElement_1_rssi); - chip::JniReferences::GetInstance().AddToList(WiFiScanResultsInsideOptional, newElement_1); - } - chip::JniReferences::GetInstance().CreateOptional(WiFiScanResultsInsideOptional, WiFiScanResults); - } - jobject ThreadScanResults; - if (!dataResponse.threadScanResults.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, ThreadScanResults); - } - else - { - jobject ThreadScanResultsInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(ThreadScanResultsInsideOptional); - - auto iter_ThreadScanResultsInsideOptional_1 = dataResponse.threadScanResults.Value().begin(); - while (iter_ThreadScanResultsInsideOptional_1.Next()) - { - auto & entry_1 = iter_ThreadScanResultsInsideOptional_1.GetValue(); - jobject newElement_1; - jobject newElement_1_panId; - std::string newElement_1_panIdClassName = "java/lang/Integer"; - std::string newElement_1_panIdCtorSignature = "(I)V"; - jint jninewElement_1_panId = static_cast(entry_1.panId); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_panIdClassName.c_str(), - newElement_1_panIdCtorSignature.c_str(), - jninewElement_1_panId, newElement_1_panId); - jobject newElement_1_extendedPanId; - std::string newElement_1_extendedPanIdClassName = "java/lang/Long"; - std::string newElement_1_extendedPanIdCtorSignature = "(J)V"; - jlong jninewElement_1_extendedPanId = static_cast(entry_1.extendedPanId); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_extendedPanIdClassName.c_str(), - newElement_1_extendedPanIdCtorSignature.c_str(), - jninewElement_1_extendedPanId, newElement_1_extendedPanId); - jobject newElement_1_networkName; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_1.networkName, newElement_1_networkName)); - jobject newElement_1_channel; - std::string newElement_1_channelClassName = "java/lang/Integer"; - std::string newElement_1_channelCtorSignature = "(I)V"; - jint jninewElement_1_channel = static_cast(entry_1.channel); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_channelClassName.c_str(), - newElement_1_channelCtorSignature.c_str(), - jninewElement_1_channel, newElement_1_channel); - jobject newElement_1_version; - std::string newElement_1_versionClassName = "java/lang/Integer"; - std::string newElement_1_versionCtorSignature = "(I)V"; - jint jninewElement_1_version = static_cast(entry_1.version); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_versionClassName.c_str(), - newElement_1_versionCtorSignature.c_str(), - jninewElement_1_version, newElement_1_version); - jobject newElement_1_extendedAddress; - jbyteArray newElement_1_extendedAddressByteArray = - env->NewByteArray(static_cast(entry_1.extendedAddress.size())); - env->SetByteArrayRegion(newElement_1_extendedAddressByteArray, 0, static_cast(entry_1.extendedAddress.size()), - reinterpret_cast(entry_1.extendedAddress.data())); - newElement_1_extendedAddress = newElement_1_extendedAddressByteArray; - jobject newElement_1_rssi; - std::string newElement_1_rssiClassName = "java/lang/Integer"; - std::string newElement_1_rssiCtorSignature = "(I)V"; - jint jninewElement_1_rssi = static_cast(entry_1.rssi); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_rssiClassName.c_str(), - newElement_1_rssiCtorSignature.c_str(), jninewElement_1_rssi, - newElement_1_rssi); - jobject newElement_1_lqi; - std::string newElement_1_lqiClassName = "java/lang/Integer"; - std::string newElement_1_lqiCtorSignature = "(I)V"; - jint jninewElement_1_lqi = static_cast(entry_1.lqi); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_1_lqiClassName.c_str(), newElement_1_lqiCtorSignature.c_str(), jninewElement_1_lqi, newElement_1_lqi); - - jclass threadInterfaceScanResultStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$NetworkCommissioningClusterThreadInterfaceScanResultStruct", - threadInterfaceScanResultStructStructClass_2); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$NetworkCommissioningClusterThreadInterfaceScanResultStruct"); - return; - } - - jmethodID threadInterfaceScanResultStructStructCtor_2; - err = chip::JniReferences::GetInstance().FindMethod( - env, threadInterfaceScanResultStructStructClass_2, "", - "(Ljava/lang/Integer;Ljava/lang/Long;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Integer;[BLjava/lang/" - "Integer;Ljava/lang/Integer;)V", - &threadInterfaceScanResultStructStructCtor_2); - if (err != CHIP_NO_ERROR || threadInterfaceScanResultStructStructCtor_2 == nullptr) - { - ChipLogError(Zcl, - "Could not find ChipStructs$NetworkCommissioningClusterThreadInterfaceScanResultStruct constructor"); - return; - } - - newElement_1 = - env->NewObject(threadInterfaceScanResultStructStructClass_2, threadInterfaceScanResultStructStructCtor_2, - newElement_1_panId, newElement_1_extendedPanId, newElement_1_networkName, newElement_1_channel, - newElement_1_version, newElement_1_extendedAddress, newElement_1_rssi, newElement_1_lqi); - chip::JniReferences::GetInstance().AddToList(ThreadScanResultsInsideOptional, newElement_1); - } - chip::JniReferences::GetInstance().CreateOptional(ThreadScanResultsInsideOptional, ThreadScanResults); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, NetworkingStatus, DebugText, WiFiScanResults, ThreadScanResults); -} -CHIPNetworkCommissioningClusterNetworkConfigResponseCallback::CHIPNetworkCommissioningClusterNetworkConfigResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPNetworkCommissioningClusterNetworkConfigResponseCallback::~CHIPNetworkCommissioningClusterNetworkConfigResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPNetworkCommissioningClusterNetworkConfigResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::NetworkCommissioning::Commands::NetworkConfigResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject NetworkingStatus; - std::string NetworkingStatusClassName = "java/lang/Integer"; - std::string NetworkingStatusCtorSignature = "(I)V"; - jint jniNetworkingStatus = static_cast(dataResponse.networkingStatus); - chip::JniReferences::GetInstance().CreateBoxedObject( - NetworkingStatusClassName.c_str(), NetworkingStatusCtorSignature.c_str(), jniNetworkingStatus, NetworkingStatus); - jobject DebugText; - if (!dataResponse.debugText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, DebugText); - } - else - { - jobject DebugTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); - } - jobject NetworkIndex; - if (!dataResponse.networkIndex.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NetworkIndex); - } - else - { - jobject NetworkIndexInsideOptional; - std::string NetworkIndexInsideOptionalClassName = "java/lang/Integer"; - std::string NetworkIndexInsideOptionalCtorSignature = "(I)V"; - jint jniNetworkIndexInsideOptional = static_cast(dataResponse.networkIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(NetworkIndexInsideOptionalClassName.c_str(), - NetworkIndexInsideOptionalCtorSignature.c_str(), - jniNetworkIndexInsideOptional, NetworkIndexInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(NetworkIndexInsideOptional, NetworkIndex); - } - jobject ClientIdentity; - if (!dataResponse.clientIdentity.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, ClientIdentity); - } - else - { - jobject ClientIdentityInsideOptional; - jbyteArray ClientIdentityInsideOptionalByteArray = - env->NewByteArray(static_cast(dataResponse.clientIdentity.Value().size())); - env->SetByteArrayRegion(ClientIdentityInsideOptionalByteArray, 0, - static_cast(dataResponse.clientIdentity.Value().size()), - reinterpret_cast(dataResponse.clientIdentity.Value().data())); - ClientIdentityInsideOptional = ClientIdentityInsideOptionalByteArray; - chip::JniReferences::GetInstance().CreateOptional(ClientIdentityInsideOptional, ClientIdentity); - } - jobject PossessionSignature; - if (!dataResponse.possessionSignature.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, PossessionSignature); - } - else - { - jobject PossessionSignatureInsideOptional; - jbyteArray PossessionSignatureInsideOptionalByteArray = - env->NewByteArray(static_cast(dataResponse.possessionSignature.Value().size())); - env->SetByteArrayRegion(PossessionSignatureInsideOptionalByteArray, 0, - static_cast(dataResponse.possessionSignature.Value().size()), - reinterpret_cast(dataResponse.possessionSignature.Value().data())); - PossessionSignatureInsideOptional = PossessionSignatureInsideOptionalByteArray; - chip::JniReferences::GetInstance().CreateOptional(PossessionSignatureInsideOptional, PossessionSignature); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, NetworkingStatus, DebugText, NetworkIndex, ClientIdentity, - PossessionSignature); -} -CHIPNetworkCommissioningClusterConnectNetworkResponseCallback::CHIPNetworkCommissioningClusterConnectNetworkResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPNetworkCommissioningClusterConnectNetworkResponseCallback::~CHIPNetworkCommissioningClusterConnectNetworkResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPNetworkCommissioningClusterConnectNetworkResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetworkResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/lang/Long;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject NetworkingStatus; - std::string NetworkingStatusClassName = "java/lang/Integer"; - std::string NetworkingStatusCtorSignature = "(I)V"; - jint jniNetworkingStatus = static_cast(dataResponse.networkingStatus); - chip::JniReferences::GetInstance().CreateBoxedObject( - NetworkingStatusClassName.c_str(), NetworkingStatusCtorSignature.c_str(), jniNetworkingStatus, NetworkingStatus); - jobject DebugText; - if (!dataResponse.debugText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, DebugText); - } - else - { - jobject DebugTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); - } - jobject ErrorValue; - if (dataResponse.errorValue.IsNull()) - { - ErrorValue = nullptr; - } - else - { - std::string ErrorValueClassName = "java/lang/Long"; - std::string ErrorValueCtorSignature = "(J)V"; - jlong jniErrorValue = static_cast(dataResponse.errorValue.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(ErrorValueClassName.c_str(), ErrorValueCtorSignature.c_str(), - jniErrorValue, ErrorValue); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, NetworkingStatus, DebugText, ErrorValue); -} -CHIPNetworkCommissioningClusterQueryIdentityResponseCallback::CHIPNetworkCommissioningClusterQueryIdentityResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPNetworkCommissioningClusterQueryIdentityResponseCallback::~CHIPNetworkCommissioningClusterQueryIdentityResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPNetworkCommissioningClusterQueryIdentityResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::NetworkCommissioning::Commands::QueryIdentityResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([BLjava/util/Optional;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Identity; - jbyteArray IdentityByteArray = env->NewByteArray(static_cast(dataResponse.identity.size())); - env->SetByteArrayRegion(IdentityByteArray, 0, static_cast(dataResponse.identity.size()), - reinterpret_cast(dataResponse.identity.data())); - Identity = IdentityByteArray; - jobject PossessionSignature; - if (!dataResponse.possessionSignature.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, PossessionSignature); - } - else - { - jobject PossessionSignatureInsideOptional; - jbyteArray PossessionSignatureInsideOptionalByteArray = - env->NewByteArray(static_cast(dataResponse.possessionSignature.Value().size())); - env->SetByteArrayRegion(PossessionSignatureInsideOptionalByteArray, 0, - static_cast(dataResponse.possessionSignature.Value().size()), - reinterpret_cast(dataResponse.possessionSignature.Value().data())); - PossessionSignatureInsideOptional = PossessionSignatureInsideOptionalByteArray; - chip::JniReferences::GetInstance().CreateOptional(PossessionSignatureInsideOptional, PossessionSignature); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Identity, PossessionSignature); -} -CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback::CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback::~CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;[BLjava/util/Optional;Ljava/util/Optional;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject LogContent; - jbyteArray LogContentByteArray = env->NewByteArray(static_cast(dataResponse.logContent.size())); - env->SetByteArrayRegion(LogContentByteArray, 0, static_cast(dataResponse.logContent.size()), - reinterpret_cast(dataResponse.logContent.data())); - LogContent = LogContentByteArray; - jobject UTCTimeStamp; - if (!dataResponse.UTCTimeStamp.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, UTCTimeStamp); - } - else - { - jobject UTCTimeStampInsideOptional; - std::string UTCTimeStampInsideOptionalClassName = "java/lang/Long"; - std::string UTCTimeStampInsideOptionalCtorSignature = "(J)V"; - jlong jniUTCTimeStampInsideOptional = static_cast(dataResponse.UTCTimeStamp.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(UTCTimeStampInsideOptionalClassName.c_str(), - UTCTimeStampInsideOptionalCtorSignature.c_str(), - jniUTCTimeStampInsideOptional, UTCTimeStampInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(UTCTimeStampInsideOptional, UTCTimeStamp); - } - jobject TimeSinceBoot; - if (!dataResponse.timeSinceBoot.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, TimeSinceBoot); - } - else - { - jobject TimeSinceBootInsideOptional; - std::string TimeSinceBootInsideOptionalClassName = "java/lang/Long"; - std::string TimeSinceBootInsideOptionalCtorSignature = "(J)V"; - jlong jniTimeSinceBootInsideOptional = static_cast(dataResponse.timeSinceBoot.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(TimeSinceBootInsideOptionalClassName.c_str(), - TimeSinceBootInsideOptionalCtorSignature.c_str(), - jniTimeSinceBootInsideOptional, TimeSinceBootInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(TimeSinceBootInsideOptional, TimeSinceBoot); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, LogContent, UTCTimeStamp, TimeSinceBoot); -} -CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback::CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback::~CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::GeneralDiagnostics::Commands::TimeSnapshotResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;Ljava/lang/Long;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject SystemTimeMs; - std::string SystemTimeMsClassName = "java/lang/Long"; - std::string SystemTimeMsCtorSignature = "(J)V"; - jlong jniSystemTimeMs = static_cast(dataResponse.systemTimeMs); - chip::JniReferences::GetInstance().CreateBoxedObject(SystemTimeMsClassName.c_str(), SystemTimeMsCtorSignature.c_str(), - jniSystemTimeMs, SystemTimeMs); - jobject PosixTimeMs; - if (dataResponse.posixTimeMs.IsNull()) - { - PosixTimeMs = nullptr; - } - else - { - std::string PosixTimeMsClassName = "java/lang/Long"; - std::string PosixTimeMsCtorSignature = "(J)V"; - jlong jniPosixTimeMs = static_cast(dataResponse.posixTimeMs.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(PosixTimeMsClassName.c_str(), PosixTimeMsCtorSignature.c_str(), - jniPosixTimeMs, PosixTimeMs); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, SystemTimeMs, PosixTimeMs); -} -CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback::CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback::~CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject DSTOffsetRequired; - std::string DSTOffsetRequiredClassName = "java/lang/Boolean"; - std::string DSTOffsetRequiredCtorSignature = "(Z)V"; - jboolean jniDSTOffsetRequired = static_cast(dataResponse.DSTOffsetRequired); - chip::JniReferences::GetInstance().CreateBoxedObject( - DSTOffsetRequiredClassName.c_str(), DSTOffsetRequiredCtorSignature.c_str(), jniDSTOffsetRequired, DSTOffsetRequired); - - env->CallVoidMethod(javaCallbackRef, javaMethod, DSTOffsetRequired); -} -CHIPOperationalCredentialsClusterAttestationResponseCallback::CHIPOperationalCredentialsClusterAttestationResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOperationalCredentialsClusterAttestationResponseCallback::~CHIPOperationalCredentialsClusterAttestationResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOperationalCredentialsClusterAttestationResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::OperationalCredentials::Commands::AttestationResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([B[B)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject AttestationElements; - jbyteArray AttestationElementsByteArray = env->NewByteArray(static_cast(dataResponse.attestationElements.size())); - env->SetByteArrayRegion(AttestationElementsByteArray, 0, static_cast(dataResponse.attestationElements.size()), - reinterpret_cast(dataResponse.attestationElements.data())); - AttestationElements = AttestationElementsByteArray; - jobject AttestationSignature; - jbyteArray AttestationSignatureByteArray = env->NewByteArray(static_cast(dataResponse.attestationSignature.size())); - env->SetByteArrayRegion(AttestationSignatureByteArray, 0, static_cast(dataResponse.attestationSignature.size()), - reinterpret_cast(dataResponse.attestationSignature.data())); - AttestationSignature = AttestationSignatureByteArray; - - env->CallVoidMethod(javaCallbackRef, javaMethod, AttestationElements, AttestationSignature); -} -CHIPOperationalCredentialsClusterCertificateChainResponseCallback:: -CHIPOperationalCredentialsClusterCertificateChainResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOperationalCredentialsClusterCertificateChainResponseCallback::~ -CHIPOperationalCredentialsClusterCertificateChainResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOperationalCredentialsClusterCertificateChainResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::OperationalCredentials::Commands::CertificateChainResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([B)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Certificate; - jbyteArray CertificateByteArray = env->NewByteArray(static_cast(dataResponse.certificate.size())); - env->SetByteArrayRegion(CertificateByteArray, 0, static_cast(dataResponse.certificate.size()), - reinterpret_cast(dataResponse.certificate.data())); - Certificate = CertificateByteArray; - - env->CallVoidMethod(javaCallbackRef, javaMethod, Certificate); -} -CHIPOperationalCredentialsClusterCSRResponseCallback::CHIPOperationalCredentialsClusterCSRResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOperationalCredentialsClusterCSRResponseCallback::~CHIPOperationalCredentialsClusterCSRResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOperationalCredentialsClusterCSRResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::OperationalCredentials::Commands::CSRResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([B[B)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject NOCSRElements; - jbyteArray NOCSRElementsByteArray = env->NewByteArray(static_cast(dataResponse.NOCSRElements.size())); - env->SetByteArrayRegion(NOCSRElementsByteArray, 0, static_cast(dataResponse.NOCSRElements.size()), - reinterpret_cast(dataResponse.NOCSRElements.data())); - NOCSRElements = NOCSRElementsByteArray; - jobject AttestationSignature; - jbyteArray AttestationSignatureByteArray = env->NewByteArray(static_cast(dataResponse.attestationSignature.size())); - env->SetByteArrayRegion(AttestationSignatureByteArray, 0, static_cast(dataResponse.attestationSignature.size()), - reinterpret_cast(dataResponse.attestationSignature.data())); - AttestationSignature = AttestationSignatureByteArray; - - env->CallVoidMethod(javaCallbackRef, javaMethod, NOCSRElements, AttestationSignature); -} -CHIPOperationalCredentialsClusterNOCResponseCallback::CHIPOperationalCredentialsClusterNOCResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOperationalCredentialsClusterNOCResponseCallback::~CHIPOperationalCredentialsClusterNOCResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOperationalCredentialsClusterNOCResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::OperationalCredentials::Commands::NOCResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject StatusCode; - std::string StatusCodeClassName = "java/lang/Integer"; - std::string StatusCodeCtorSignature = "(I)V"; - jint jniStatusCode = static_cast(dataResponse.statusCode); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusCodeClassName.c_str(), StatusCodeCtorSignature.c_str(), - jniStatusCode, StatusCode); - jobject FabricIndex; - if (!dataResponse.fabricIndex.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, FabricIndex); - } - else - { - jobject FabricIndexInsideOptional; - std::string FabricIndexInsideOptionalClassName = "java/lang/Integer"; - std::string FabricIndexInsideOptionalCtorSignature = "(I)V"; - jint jniFabricIndexInsideOptional = static_cast(dataResponse.fabricIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(FabricIndexInsideOptionalClassName.c_str(), - FabricIndexInsideOptionalCtorSignature.c_str(), - jniFabricIndexInsideOptional, FabricIndexInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(FabricIndexInsideOptional, FabricIndex); - } - jobject DebugText; - if (!dataResponse.debugText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, DebugText); - } - else - { - jobject DebugTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, StatusCode, FabricIndex, DebugText); -} -CHIPGroupKeyManagementClusterKeySetReadResponseCallback::CHIPGroupKeyManagementClusterKeySetReadResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGroupKeyManagementClusterKeySetReadResponseCallback::~CHIPGroupKeyManagementClusterKeySetReadResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGroupKeyManagementClusterKeySetReadResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Lchip/devicecontroller/ChipStructs$GroupKeyManagementClusterGroupKeySetStruct;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject GroupKeySet; - jobject GroupKeySet_groupKeySetID; - std::string GroupKeySet_groupKeySetIDClassName = "java/lang/Integer"; - std::string GroupKeySet_groupKeySetIDCtorSignature = "(I)V"; - jint jniGroupKeySet_groupKeySetID = static_cast(dataResponse.groupKeySet.groupKeySetID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupKeySet_groupKeySetIDClassName.c_str(), - GroupKeySet_groupKeySetIDCtorSignature.c_str(), - jniGroupKeySet_groupKeySetID, GroupKeySet_groupKeySetID); - jobject GroupKeySet_groupKeySecurityPolicy; - std::string GroupKeySet_groupKeySecurityPolicyClassName = "java/lang/Integer"; - std::string GroupKeySet_groupKeySecurityPolicyCtorSignature = "(I)V"; - jint jniGroupKeySet_groupKeySecurityPolicy = static_cast(dataResponse.groupKeySet.groupKeySecurityPolicy); - chip::JniReferences::GetInstance().CreateBoxedObject( - GroupKeySet_groupKeySecurityPolicyClassName.c_str(), GroupKeySet_groupKeySecurityPolicyCtorSignature.c_str(), - jniGroupKeySet_groupKeySecurityPolicy, GroupKeySet_groupKeySecurityPolicy); - jobject GroupKeySet_epochKey0; - if (dataResponse.groupKeySet.epochKey0.IsNull()) - { - GroupKeySet_epochKey0 = nullptr; - } - else - { - jbyteArray GroupKeySet_epochKey0ByteArray = - env->NewByteArray(static_cast(dataResponse.groupKeySet.epochKey0.Value().size())); - env->SetByteArrayRegion(GroupKeySet_epochKey0ByteArray, 0, - static_cast(dataResponse.groupKeySet.epochKey0.Value().size()), - reinterpret_cast(dataResponse.groupKeySet.epochKey0.Value().data())); - GroupKeySet_epochKey0 = GroupKeySet_epochKey0ByteArray; - } - jobject GroupKeySet_epochStartTime0; - if (dataResponse.groupKeySet.epochStartTime0.IsNull()) - { - GroupKeySet_epochStartTime0 = nullptr; - } - else - { - std::string GroupKeySet_epochStartTime0ClassName = "java/lang/Long"; - std::string GroupKeySet_epochStartTime0CtorSignature = "(J)V"; - jlong jniGroupKeySet_epochStartTime0 = static_cast(dataResponse.groupKeySet.epochStartTime0.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupKeySet_epochStartTime0ClassName.c_str(), - GroupKeySet_epochStartTime0CtorSignature.c_str(), - jniGroupKeySet_epochStartTime0, GroupKeySet_epochStartTime0); - } - jobject GroupKeySet_epochKey1; - if (dataResponse.groupKeySet.epochKey1.IsNull()) - { - GroupKeySet_epochKey1 = nullptr; - } - else - { - jbyteArray GroupKeySet_epochKey1ByteArray = - env->NewByteArray(static_cast(dataResponse.groupKeySet.epochKey1.Value().size())); - env->SetByteArrayRegion(GroupKeySet_epochKey1ByteArray, 0, - static_cast(dataResponse.groupKeySet.epochKey1.Value().size()), - reinterpret_cast(dataResponse.groupKeySet.epochKey1.Value().data())); - GroupKeySet_epochKey1 = GroupKeySet_epochKey1ByteArray; - } - jobject GroupKeySet_epochStartTime1; - if (dataResponse.groupKeySet.epochStartTime1.IsNull()) - { - GroupKeySet_epochStartTime1 = nullptr; - } - else - { - std::string GroupKeySet_epochStartTime1ClassName = "java/lang/Long"; - std::string GroupKeySet_epochStartTime1CtorSignature = "(J)V"; - jlong jniGroupKeySet_epochStartTime1 = static_cast(dataResponse.groupKeySet.epochStartTime1.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupKeySet_epochStartTime1ClassName.c_str(), - GroupKeySet_epochStartTime1CtorSignature.c_str(), - jniGroupKeySet_epochStartTime1, GroupKeySet_epochStartTime1); - } - jobject GroupKeySet_epochKey2; - if (dataResponse.groupKeySet.epochKey2.IsNull()) - { - GroupKeySet_epochKey2 = nullptr; - } - else - { - jbyteArray GroupKeySet_epochKey2ByteArray = - env->NewByteArray(static_cast(dataResponse.groupKeySet.epochKey2.Value().size())); - env->SetByteArrayRegion(GroupKeySet_epochKey2ByteArray, 0, - static_cast(dataResponse.groupKeySet.epochKey2.Value().size()), - reinterpret_cast(dataResponse.groupKeySet.epochKey2.Value().data())); - GroupKeySet_epochKey2 = GroupKeySet_epochKey2ByteArray; - } - jobject GroupKeySet_epochStartTime2; - if (dataResponse.groupKeySet.epochStartTime2.IsNull()) - { - GroupKeySet_epochStartTime2 = nullptr; - } - else - { - std::string GroupKeySet_epochStartTime2ClassName = "java/lang/Long"; - std::string GroupKeySet_epochStartTime2CtorSignature = "(J)V"; - jlong jniGroupKeySet_epochStartTime2 = static_cast(dataResponse.groupKeySet.epochStartTime2.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupKeySet_epochStartTime2ClassName.c_str(), - GroupKeySet_epochStartTime2CtorSignature.c_str(), - jniGroupKeySet_epochStartTime2, GroupKeySet_epochStartTime2); - } - - jclass groupKeySetStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$GroupKeyManagementClusterGroupKeySetStruct", groupKeySetStructStructClass_0); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$GroupKeyManagementClusterGroupKeySetStruct"); - return; - } - - jmethodID groupKeySetStructStructCtor_0; - err = chip::JniReferences::GetInstance().FindMethod( - env, groupKeySetStructStructClass_0, "", - "(Ljava/lang/Integer;Ljava/lang/Integer;[BLjava/lang/Long;[BLjava/lang/Long;[BLjava/lang/Long;)V", - &groupKeySetStructStructCtor_0); - if (err != CHIP_NO_ERROR || groupKeySetStructStructCtor_0 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$GroupKeyManagementClusterGroupKeySetStruct constructor"); - return; - } - - GroupKeySet = - env->NewObject(groupKeySetStructStructClass_0, groupKeySetStructStructCtor_0, GroupKeySet_groupKeySetID, - GroupKeySet_groupKeySecurityPolicy, GroupKeySet_epochKey0, GroupKeySet_epochStartTime0, - GroupKeySet_epochKey1, GroupKeySet_epochStartTime1, GroupKeySet_epochKey2, GroupKeySet_epochStartTime2); - - env->CallVoidMethod(javaCallbackRef, javaMethod, GroupKeySet); -} -CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback:: -CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback::~ -CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadAllIndicesResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/ArrayList;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject GroupKeySetIDs; - chip::JniReferences::GetInstance().CreateArrayList(GroupKeySetIDs); - - auto iter_GroupKeySetIDs_0 = dataResponse.groupKeySetIDs.begin(); - while (iter_GroupKeySetIDs_0.Next()) - { - auto & entry_0 = iter_GroupKeySetIDs_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Integer"; - std::string newElement_0CtorSignature = "(I)V"; - jint jninewElement_0 = static_cast(entry_0); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), - jninewElement_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(GroupKeySetIDs, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, GroupKeySetIDs); -} -CHIPIcdManagementClusterRegisterClientResponseCallback::CHIPIcdManagementClusterRegisterClientResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPIcdManagementClusterRegisterClientResponseCallback::~CHIPIcdManagementClusterRegisterClientResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPIcdManagementClusterRegisterClientResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::IcdManagement::Commands::RegisterClientResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject ICDCounter; - std::string ICDCounterClassName = "java/lang/Long"; - std::string ICDCounterCtorSignature = "(J)V"; - jlong jniICDCounter = static_cast(dataResponse.ICDCounter); - chip::JniReferences::GetInstance().CreateBoxedObject(ICDCounterClassName.c_str(), ICDCounterCtorSignature.c_str(), - jniICDCounter, ICDCounter); - - env->CallVoidMethod(javaCallbackRef, javaMethod, ICDCounter); -} -CHIPIcdManagementClusterStayActiveResponseCallback::CHIPIcdManagementClusterStayActiveResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPIcdManagementClusterStayActiveResponseCallback::~CHIPIcdManagementClusterStayActiveResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPIcdManagementClusterStayActiveResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::IcdManagement::Commands::StayActiveResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject PromisedActiveDuration; - std::string PromisedActiveDurationClassName = "java/lang/Long"; - std::string PromisedActiveDurationCtorSignature = "(J)V"; - jlong jniPromisedActiveDuration = static_cast(dataResponse.promisedActiveDuration); - chip::JniReferences::GetInstance().CreateBoxedObject(PromisedActiveDurationClassName.c_str(), - PromisedActiveDurationCtorSignature.c_str(), - jniPromisedActiveDuration, PromisedActiveDuration); - - env->CallVoidMethod(javaCallbackRef, javaMethod, PromisedActiveDuration); -} -CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback:: -CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback::~ -CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::OvenCavityOperationalState::Commands::OperationalCommandResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Lchip/devicecontroller/ChipStructs$OvenCavityOperationalStateClusterErrorStateStruct;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject CommandResponseState; - jobject CommandResponseState_errorStateID; - std::string CommandResponseState_errorStateIDClassName = "java/lang/Integer"; - std::string CommandResponseState_errorStateIDCtorSignature = "(I)V"; - jint jniCommandResponseState_errorStateID = static_cast(dataResponse.commandResponseState.errorStateID); - chip::JniReferences::GetInstance().CreateBoxedObject( - CommandResponseState_errorStateIDClassName.c_str(), CommandResponseState_errorStateIDCtorSignature.c_str(), - jniCommandResponseState_errorStateID, CommandResponseState_errorStateID); - jobject CommandResponseState_errorStateLabel; - if (!dataResponse.commandResponseState.errorStateLabel.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateLabel); - } - else - { - jobject CommandResponseState_errorStateLabelInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.commandResponseState.errorStateLabel.Value(), CommandResponseState_errorStateLabelInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateLabelInsideOptional, - CommandResponseState_errorStateLabel); - } - jobject CommandResponseState_errorStateDetails; - if (!dataResponse.commandResponseState.errorStateDetails.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateDetails); - } - else - { - jobject CommandResponseState_errorStateDetailsInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.commandResponseState.errorStateDetails.Value(), CommandResponseState_errorStateDetailsInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateDetailsInsideOptional, - CommandResponseState_errorStateDetails); - } - - jclass errorStateStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$OvenCavityOperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$OvenCavityOperationalStateClusterErrorStateStruct"); - return; - } - - jmethodID errorStateStructStructCtor_0; - err = chip::JniReferences::GetInstance().FindMethod(env, errorStateStructStructClass_0, "", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", - &errorStateStructStructCtor_0); - if (err != CHIP_NO_ERROR || errorStateStructStructCtor_0 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$OvenCavityOperationalStateClusterErrorStateStruct constructor"); - return; - } - - CommandResponseState = - env->NewObject(errorStateStructStructClass_0, errorStateStructStructCtor_0, CommandResponseState_errorStateID, - CommandResponseState_errorStateLabel, CommandResponseState_errorStateDetails); - - env->CallVoidMethod(javaCallbackRef, javaMethod, CommandResponseState); -} -CHIPOvenModeClusterChangeToModeResponseCallback::CHIPOvenModeClusterChangeToModeResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOvenModeClusterChangeToModeResponseCallback::~CHIPOvenModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOvenModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::OvenMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPLaundryWasherModeClusterChangeToModeResponseCallback::CHIPLaundryWasherModeClusterChangeToModeResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPLaundryWasherModeClusterChangeToModeResponseCallback::~CHIPLaundryWasherModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPLaundryWasherModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::LaundryWasherMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback:: -CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback::~ -CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::RefrigeratorAndTemperatureControlledCabinetMode::Commands::ChangeToModeResponse::DecodableType & - dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback( - reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPRvcRunModeClusterChangeToModeResponseCallback::CHIPRvcRunModeClusterChangeToModeResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPRvcRunModeClusterChangeToModeResponseCallback::~CHIPRvcRunModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPRvcRunModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::RvcRunMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPRvcCleanModeClusterChangeToModeResponseCallback::CHIPRvcCleanModeClusterChangeToModeResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPRvcCleanModeClusterChangeToModeResponseCallback::~CHIPRvcCleanModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPRvcCleanModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::RvcCleanMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPDishwasherModeClusterChangeToModeResponseCallback::CHIPDishwasherModeClusterChangeToModeResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDishwasherModeClusterChangeToModeResponseCallback::~CHIPDishwasherModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDishwasherModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DishwasherMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPOperationalStateClusterOperationalCommandResponseCallback::CHIPOperationalStateClusterOperationalCommandResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOperationalStateClusterOperationalCommandResponseCallback::~CHIPOperationalStateClusterOperationalCommandResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOperationalStateClusterOperationalCommandResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::OperationalState::Commands::OperationalCommandResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Lchip/devicecontroller/ChipStructs$OperationalStateClusterErrorStateStruct;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject CommandResponseState; - jobject CommandResponseState_errorStateID; - std::string CommandResponseState_errorStateIDClassName = "java/lang/Integer"; - std::string CommandResponseState_errorStateIDCtorSignature = "(I)V"; - jint jniCommandResponseState_errorStateID = static_cast(dataResponse.commandResponseState.errorStateID); - chip::JniReferences::GetInstance().CreateBoxedObject( - CommandResponseState_errorStateIDClassName.c_str(), CommandResponseState_errorStateIDCtorSignature.c_str(), - jniCommandResponseState_errorStateID, CommandResponseState_errorStateID); - jobject CommandResponseState_errorStateLabel; - if (!dataResponse.commandResponseState.errorStateLabel.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateLabel); - } - else - { - jobject CommandResponseState_errorStateLabelInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.commandResponseState.errorStateLabel.Value(), CommandResponseState_errorStateLabelInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateLabelInsideOptional, - CommandResponseState_errorStateLabel); - } - jobject CommandResponseState_errorStateDetails; - if (!dataResponse.commandResponseState.errorStateDetails.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateDetails); - } - else - { - jobject CommandResponseState_errorStateDetailsInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.commandResponseState.errorStateDetails.Value(), CommandResponseState_errorStateDetailsInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateDetailsInsideOptional, - CommandResponseState_errorStateDetails); - } - - jclass errorStateStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$OperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$OperationalStateClusterErrorStateStruct"); - return; - } - - jmethodID errorStateStructStructCtor_0; - err = chip::JniReferences::GetInstance().FindMethod(env, errorStateStructStructClass_0, "", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", - &errorStateStructStructCtor_0); - if (err != CHIP_NO_ERROR || errorStateStructStructCtor_0 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$OperationalStateClusterErrorStateStruct constructor"); - return; - } - - CommandResponseState = - env->NewObject(errorStateStructStructClass_0, errorStateStructStructCtor_0, CommandResponseState_errorStateID, - CommandResponseState_errorStateLabel, CommandResponseState_errorStateDetails); - - env->CallVoidMethod(javaCallbackRef, javaMethod, CommandResponseState); -} -CHIPRvcOperationalStateClusterOperationalCommandResponseCallback::CHIPRvcOperationalStateClusterOperationalCommandResponseCallback( - jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPRvcOperationalStateClusterOperationalCommandResponseCallback::~ -CHIPRvcOperationalStateClusterOperationalCommandResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPRvcOperationalStateClusterOperationalCommandResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Lchip/devicecontroller/ChipStructs$RvcOperationalStateClusterErrorStateStruct;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject CommandResponseState; - jobject CommandResponseState_errorStateID; - std::string CommandResponseState_errorStateIDClassName = "java/lang/Integer"; - std::string CommandResponseState_errorStateIDCtorSignature = "(I)V"; - jint jniCommandResponseState_errorStateID = static_cast(dataResponse.commandResponseState.errorStateID); - chip::JniReferences::GetInstance().CreateBoxedObject( - CommandResponseState_errorStateIDClassName.c_str(), CommandResponseState_errorStateIDCtorSignature.c_str(), - jniCommandResponseState_errorStateID, CommandResponseState_errorStateID); - jobject CommandResponseState_errorStateLabel; - if (!dataResponse.commandResponseState.errorStateLabel.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateLabel); - } - else - { - jobject CommandResponseState_errorStateLabelInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.commandResponseState.errorStateLabel.Value(), CommandResponseState_errorStateLabelInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateLabelInsideOptional, - CommandResponseState_errorStateLabel); - } - jobject CommandResponseState_errorStateDetails; - if (!dataResponse.commandResponseState.errorStateDetails.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateDetails); - } - else - { - jobject CommandResponseState_errorStateDetailsInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.commandResponseState.errorStateDetails.Value(), CommandResponseState_errorStateDetailsInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateDetailsInsideOptional, - CommandResponseState_errorStateDetails); - } - - jclass errorStateStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$RvcOperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$RvcOperationalStateClusterErrorStateStruct"); - return; - } - - jmethodID errorStateStructStructCtor_0; - err = chip::JniReferences::GetInstance().FindMethod(env, errorStateStructStructClass_0, "", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", - &errorStateStructStructCtor_0); - if (err != CHIP_NO_ERROR || errorStateStructStructCtor_0 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$RvcOperationalStateClusterErrorStateStruct constructor"); - return; - } - - CommandResponseState = - env->NewObject(errorStateStructStructClass_0, errorStateStructStructCtor_0, CommandResponseState_errorStateID, - CommandResponseState_errorStateLabel, CommandResponseState_errorStateDetails); - - env->CallVoidMethod(javaCallbackRef, javaMethod, CommandResponseState); -} -CHIPScenesManagementClusterAddSceneResponseCallback::CHIPScenesManagementClusterAddSceneResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPScenesManagementClusterAddSceneResponseCallback::~CHIPScenesManagementClusterAddSceneResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPScenesManagementClusterAddSceneResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ScenesManagement::Commands::AddSceneResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - jobject SceneID; - std::string SceneIDClassName = "java/lang/Integer"; - std::string SceneIDCtorSignature = "(I)V"; - jint jniSceneID = static_cast(dataResponse.sceneID); - chip::JniReferences::GetInstance().CreateBoxedObject(SceneIDClassName.c_str(), SceneIDCtorSignature.c_str(), jniSceneID, - SceneID); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, SceneID); -} -CHIPScenesManagementClusterViewSceneResponseCallback::CHIPScenesManagementClusterViewSceneResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPScenesManagementClusterViewSceneResponseCallback::~CHIPScenesManagementClusterViewSceneResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPScenesManagementClusterViewSceneResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ScenesManagement::Commands::ViewSceneResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - jobject SceneID; - std::string SceneIDClassName = "java/lang/Integer"; - std::string SceneIDCtorSignature = "(I)V"; - jint jniSceneID = static_cast(dataResponse.sceneID); - chip::JniReferences::GetInstance().CreateBoxedObject(SceneIDClassName.c_str(), SceneIDCtorSignature.c_str(), jniSceneID, - SceneID); - jobject TransitionTime; - if (!dataResponse.transitionTime.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, TransitionTime); - } - else - { - jobject TransitionTimeInsideOptional; - std::string TransitionTimeInsideOptionalClassName = "java/lang/Long"; - std::string TransitionTimeInsideOptionalCtorSignature = "(J)V"; - jlong jniTransitionTimeInsideOptional = static_cast(dataResponse.transitionTime.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(TransitionTimeInsideOptionalClassName.c_str(), - TransitionTimeInsideOptionalCtorSignature.c_str(), - jniTransitionTimeInsideOptional, TransitionTimeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(TransitionTimeInsideOptional, TransitionTime); - } - jobject SceneName; - if (!dataResponse.sceneName.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, SceneName); - } - else - { - jobject SceneNameInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.sceneName.Value(), SceneNameInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(SceneNameInsideOptional, SceneName); - } - jobject ExtensionFieldSets; - if (!dataResponse.extensionFieldSets.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, ExtensionFieldSets); - } - else - { - jobject ExtensionFieldSetsInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(ExtensionFieldSetsInsideOptional); - - auto iter_ExtensionFieldSetsInsideOptional_1 = dataResponse.extensionFieldSets.Value().begin(); - while (iter_ExtensionFieldSetsInsideOptional_1.Next()) - { - auto & entry_1 = iter_ExtensionFieldSetsInsideOptional_1.GetValue(); - jobject newElement_1; - jobject newElement_1_clusterID; - std::string newElement_1_clusterIDClassName = "java/lang/Long"; - std::string newElement_1_clusterIDCtorSignature = "(J)V"; - jlong jninewElement_1_clusterID = static_cast(entry_1.clusterID); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_clusterIDClassName.c_str(), - newElement_1_clusterIDCtorSignature.c_str(), - jninewElement_1_clusterID, newElement_1_clusterID); - jobject newElement_1_attributeValueList; - chip::JniReferences::GetInstance().CreateArrayList(newElement_1_attributeValueList); - - auto iter_newElement_1_attributeValueList_3 = entry_1.attributeValueList.begin(); - while (iter_newElement_1_attributeValueList_3.Next()) - { - auto & entry_3 = iter_newElement_1_attributeValueList_3.GetValue(); - jobject newElement_3; - jobject newElement_3_attributeID; - std::string newElement_3_attributeIDClassName = "java/lang/Long"; - std::string newElement_3_attributeIDCtorSignature = "(J)V"; - jlong jninewElement_3_attributeID = static_cast(entry_3.attributeID); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_3_attributeIDClassName.c_str(), - newElement_3_attributeIDCtorSignature.c_str(), - jninewElement_3_attributeID, newElement_3_attributeID); - jobject newElement_3_attributeValue; - std::string newElement_3_attributeValueClassName = "java/lang/Long"; - std::string newElement_3_attributeValueCtorSignature = "(J)V"; - jlong jninewElement_3_attributeValue = static_cast(entry_3.attributeValue); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_3_attributeValueClassName.c_str(), newElement_3_attributeValueCtorSignature.c_str(), - jninewElement_3_attributeValue, newElement_3_attributeValue); - - jclass attributeValuePairStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ScenesManagementClusterAttributeValuePair", - attributeValuePairStructClass_4); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ScenesManagementClusterAttributeValuePair"); - return; - } - - jmethodID attributeValuePairStructCtor_4; - err = chip::JniReferences::GetInstance().FindMethod(env, attributeValuePairStructClass_4, "", - "(Ljava/lang/Long;Ljava/lang/Long;)V", - &attributeValuePairStructCtor_4); - if (err != CHIP_NO_ERROR || attributeValuePairStructCtor_4 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ScenesManagementClusterAttributeValuePair constructor"); - return; - } - - newElement_3 = env->NewObject(attributeValuePairStructClass_4, attributeValuePairStructCtor_4, - newElement_3_attributeID, newElement_3_attributeValue); - chip::JniReferences::GetInstance().AddToList(newElement_1_attributeValueList, newElement_3); - } - - jclass extensionFieldSetStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ScenesManagementClusterExtensionFieldSet", extensionFieldSetStructClass_2); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ScenesManagementClusterExtensionFieldSet"); - return; - } - - jmethodID extensionFieldSetStructCtor_2; - err = chip::JniReferences::GetInstance().FindMethod(env, extensionFieldSetStructClass_2, "", - "(Ljava/lang/Long;Ljava/util/ArrayList;)V", - &extensionFieldSetStructCtor_2); - if (err != CHIP_NO_ERROR || extensionFieldSetStructCtor_2 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ScenesManagementClusterExtensionFieldSet constructor"); - return; - } - - newElement_1 = env->NewObject(extensionFieldSetStructClass_2, extensionFieldSetStructCtor_2, newElement_1_clusterID, - newElement_1_attributeValueList); - chip::JniReferences::GetInstance().AddToList(ExtensionFieldSetsInsideOptional, newElement_1); - } - chip::JniReferences::GetInstance().CreateOptional(ExtensionFieldSetsInsideOptional, ExtensionFieldSets); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, SceneID, TransitionTime, SceneName, ExtensionFieldSets); -} -CHIPScenesManagementClusterRemoveSceneResponseCallback::CHIPScenesManagementClusterRemoveSceneResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPScenesManagementClusterRemoveSceneResponseCallback::~CHIPScenesManagementClusterRemoveSceneResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPScenesManagementClusterRemoveSceneResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ScenesManagement::Commands::RemoveSceneResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - jobject SceneID; - std::string SceneIDClassName = "java/lang/Integer"; - std::string SceneIDCtorSignature = "(I)V"; - jint jniSceneID = static_cast(dataResponse.sceneID); - chip::JniReferences::GetInstance().CreateBoxedObject(SceneIDClassName.c_str(), SceneIDCtorSignature.c_str(), jniSceneID, - SceneID); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, SceneID); -} -CHIPScenesManagementClusterRemoveAllScenesResponseCallback::CHIPScenesManagementClusterRemoveAllScenesResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPScenesManagementClusterRemoveAllScenesResponseCallback::~CHIPScenesManagementClusterRemoveAllScenesResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPScenesManagementClusterRemoveAllScenesResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ScenesManagement::Commands::RemoveAllScenesResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID); -} -CHIPScenesManagementClusterStoreSceneResponseCallback::CHIPScenesManagementClusterStoreSceneResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPScenesManagementClusterStoreSceneResponseCallback::~CHIPScenesManagementClusterStoreSceneResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPScenesManagementClusterStoreSceneResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ScenesManagement::Commands::StoreSceneResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - jobject SceneID; - std::string SceneIDClassName = "java/lang/Integer"; - std::string SceneIDCtorSignature = "(I)V"; - jint jniSceneID = static_cast(dataResponse.sceneID); - chip::JniReferences::GetInstance().CreateBoxedObject(SceneIDClassName.c_str(), SceneIDCtorSignature.c_str(), jniSceneID, - SceneID); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, SceneID); -} -CHIPScenesManagementClusterGetSceneMembershipResponseCallback::CHIPScenesManagementClusterGetSceneMembershipResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPScenesManagementClusterGetSceneMembershipResponseCallback::~CHIPScenesManagementClusterGetSceneMembershipResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPScenesManagementClusterGetSceneMembershipResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ScenesManagement::Commands::GetSceneMembershipResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject Capacity; - if (dataResponse.capacity.IsNull()) - { - Capacity = nullptr; - } - else - { - std::string CapacityClassName = "java/lang/Integer"; - std::string CapacityCtorSignature = "(I)V"; - jint jniCapacity = static_cast(dataResponse.capacity.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(CapacityClassName.c_str(), CapacityCtorSignature.c_str(), - jniCapacity, Capacity); - } - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - jobject SceneList; - if (!dataResponse.sceneList.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, SceneList); - } - else - { - jobject SceneListInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(SceneListInsideOptional); - - auto iter_SceneListInsideOptional_1 = dataResponse.sceneList.Value().begin(); - while (iter_SceneListInsideOptional_1.Next()) - { - auto & entry_1 = iter_SceneListInsideOptional_1.GetValue(); - jobject newElement_1; - std::string newElement_1ClassName = "java/lang/Integer"; - std::string newElement_1CtorSignature = "(I)V"; - jint jninewElement_1 = static_cast(entry_1); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_1ClassName.c_str(), newElement_1CtorSignature.c_str(), jninewElement_1, newElement_1); - chip::JniReferences::GetInstance().AddToList(SceneListInsideOptional, newElement_1); - } - chip::JniReferences::GetInstance().CreateOptional(SceneListInsideOptional, SceneList); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Capacity, GroupID, SceneList); -} -CHIPScenesManagementClusterCopySceneResponseCallback::CHIPScenesManagementClusterCopySceneResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPScenesManagementClusterCopySceneResponseCallback::~CHIPScenesManagementClusterCopySceneResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPScenesManagementClusterCopySceneResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ScenesManagement::Commands::CopySceneResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupIdentifierFrom; - std::string GroupIdentifierFromClassName = "java/lang/Integer"; - std::string GroupIdentifierFromCtorSignature = "(I)V"; - jint jniGroupIdentifierFrom = static_cast(dataResponse.groupIdentifierFrom); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIdentifierFromClassName.c_str(), - GroupIdentifierFromCtorSignature.c_str(), jniGroupIdentifierFrom, - GroupIdentifierFrom); - jobject SceneIdentifierFrom; - std::string SceneIdentifierFromClassName = "java/lang/Integer"; - std::string SceneIdentifierFromCtorSignature = "(I)V"; - jint jniSceneIdentifierFrom = static_cast(dataResponse.sceneIdentifierFrom); - chip::JniReferences::GetInstance().CreateBoxedObject(SceneIdentifierFromClassName.c_str(), - SceneIdentifierFromCtorSignature.c_str(), jniSceneIdentifierFrom, - SceneIdentifierFrom); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupIdentifierFrom, SceneIdentifierFrom); -} -CHIPEnergyEvseClusterGetTargetsResponseCallback::CHIPEnergyEvseClusterGetTargetsResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPEnergyEvseClusterGetTargetsResponseCallback::~CHIPEnergyEvseClusterGetTargetsResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPEnergyEvseClusterGetTargetsResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::EnergyEvse::Commands::GetTargetsResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/ArrayList;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject ChargingTargetSchedules; - chip::JniReferences::GetInstance().CreateArrayList(ChargingTargetSchedules); - - auto iter_ChargingTargetSchedules_0 = dataResponse.chargingTargetSchedules.begin(); - while (iter_ChargingTargetSchedules_0.Next()) - { - auto & entry_0 = iter_ChargingTargetSchedules_0.GetValue(); - jobject newElement_0; - jobject newElement_0_dayOfWeekForSequence; - std::string newElement_0_dayOfWeekForSequenceClassName = "java/lang/Integer"; - std::string newElement_0_dayOfWeekForSequenceCtorSignature = "(I)V"; - jint jninewElement_0_dayOfWeekForSequence = static_cast(entry_0.dayOfWeekForSequence.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_dayOfWeekForSequenceClassName.c_str(), newElement_0_dayOfWeekForSequenceCtorSignature.c_str(), - jninewElement_0_dayOfWeekForSequence, newElement_0_dayOfWeekForSequence); - jobject newElement_0_chargingTargets; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_chargingTargets); - - auto iter_newElement_0_chargingTargets_2 = entry_0.chargingTargets.begin(); - while (iter_newElement_0_chargingTargets_2.Next()) - { - auto & entry_2 = iter_newElement_0_chargingTargets_2.GetValue(); - jobject newElement_2; - jobject newElement_2_targetTimeMinutesPastMidnight; - std::string newElement_2_targetTimeMinutesPastMidnightClassName = "java/lang/Integer"; - std::string newElement_2_targetTimeMinutesPastMidnightCtorSignature = "(I)V"; - jint jninewElement_2_targetTimeMinutesPastMidnight = static_cast(entry_2.targetTimeMinutesPastMidnight); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_targetTimeMinutesPastMidnightClassName.c_str(), - newElement_2_targetTimeMinutesPastMidnightCtorSignature.c_str(), jninewElement_2_targetTimeMinutesPastMidnight, - newElement_2_targetTimeMinutesPastMidnight); - jobject newElement_2_targetSoC; - if (!entry_2.targetSoC.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_targetSoC); - } - else - { - jobject newElement_2_targetSoCInsideOptional; - std::string newElement_2_targetSoCInsideOptionalClassName = "java/lang/Integer"; - std::string newElement_2_targetSoCInsideOptionalCtorSignature = "(I)V"; - jint jninewElement_2_targetSoCInsideOptional = static_cast(entry_2.targetSoC.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_targetSoCInsideOptionalClassName.c_str(), - newElement_2_targetSoCInsideOptionalCtorSignature.c_str(), jninewElement_2_targetSoCInsideOptional, - newElement_2_targetSoCInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(newElement_2_targetSoCInsideOptional, newElement_2_targetSoC); - } - jobject newElement_2_addedEnergy; - if (!entry_2.addedEnergy.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_addedEnergy); - } - else - { - jobject newElement_2_addedEnergyInsideOptional; - std::string newElement_2_addedEnergyInsideOptionalClassName = "java/lang/Long"; - std::string newElement_2_addedEnergyInsideOptionalCtorSignature = "(J)V"; - jlong jninewElement_2_addedEnergyInsideOptional = static_cast(entry_2.addedEnergy.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_addedEnergyInsideOptionalClassName.c_str(), - newElement_2_addedEnergyInsideOptionalCtorSignature.c_str(), jninewElement_2_addedEnergyInsideOptional, - newElement_2_addedEnergyInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(newElement_2_addedEnergyInsideOptional, newElement_2_addedEnergy); - } - - jclass chargingTargetStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$EnergyEvseClusterChargingTargetStruct", chargingTargetStructStructClass_3); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$EnergyEvseClusterChargingTargetStruct"); - return; - } - - jmethodID chargingTargetStructStructCtor_3; - err = chip::JniReferences::GetInstance().FindMethod(env, chargingTargetStructStructClass_3, "", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", - &chargingTargetStructStructCtor_3); - if (err != CHIP_NO_ERROR || chargingTargetStructStructCtor_3 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$EnergyEvseClusterChargingTargetStruct constructor"); - return; - } - - newElement_2 = - env->NewObject(chargingTargetStructStructClass_3, chargingTargetStructStructCtor_3, - newElement_2_targetTimeMinutesPastMidnight, newElement_2_targetSoC, newElement_2_addedEnergy); - chip::JniReferences::GetInstance().AddToList(newElement_0_chargingTargets, newElement_2); - } - - jclass chargingTargetScheduleStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$EnergyEvseClusterChargingTargetScheduleStruct", - chargingTargetScheduleStructStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$EnergyEvseClusterChargingTargetScheduleStruct"); - return; - } - - jmethodID chargingTargetScheduleStructStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod(env, chargingTargetScheduleStructStructClass_1, "", - "(Ljava/lang/Integer;Ljava/util/ArrayList;)V", - &chargingTargetScheduleStructStructCtor_1); - if (err != CHIP_NO_ERROR || chargingTargetScheduleStructStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$EnergyEvseClusterChargingTargetScheduleStruct constructor"); - return; - } - - newElement_0 = env->NewObject(chargingTargetScheduleStructStructClass_1, chargingTargetScheduleStructStructCtor_1, - newElement_0_dayOfWeekForSequence, newElement_0_chargingTargets); - chip::JniReferences::GetInstance().AddToList(ChargingTargetSchedules, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, ChargingTargetSchedules); -} -CHIPEnergyEvseModeClusterChangeToModeResponseCallback::CHIPEnergyEvseModeClusterChangeToModeResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPEnergyEvseModeClusterChangeToModeResponseCallback::~CHIPEnergyEvseModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPEnergyEvseModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::EnergyEvseMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPDeviceEnergyManagementModeClusterChangeToModeResponseCallback:: -CHIPDeviceEnergyManagementModeClusterChangeToModeResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDeviceEnergyManagementModeClusterChangeToModeResponseCallback::~ -CHIPDeviceEnergyManagementModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDeviceEnergyManagementModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::DeviceEnergyManagementMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPDoorLockClusterGetWeekDayScheduleResponseCallback::CHIPDoorLockClusterGetWeekDayScheduleResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDoorLockClusterGetWeekDayScheduleResponseCallback::~CHIPDoorLockClusterGetWeekDayScheduleResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDoorLockClusterGetWeekDayScheduleResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DoorLock::Commands::GetWeekDayScheduleResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" - "Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject WeekDayIndex; - std::string WeekDayIndexClassName = "java/lang/Integer"; - std::string WeekDayIndexCtorSignature = "(I)V"; - jint jniWeekDayIndex = static_cast(dataResponse.weekDayIndex); - chip::JniReferences::GetInstance().CreateBoxedObject(WeekDayIndexClassName.c_str(), WeekDayIndexCtorSignature.c_str(), - jniWeekDayIndex, WeekDayIndex); - jobject UserIndex; - std::string UserIndexClassName = "java/lang/Integer"; - std::string UserIndexCtorSignature = "(I)V"; - jint jniUserIndex = static_cast(dataResponse.userIndex); - chip::JniReferences::GetInstance().CreateBoxedObject(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), - jniUserIndex, UserIndex); - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject DaysMask; - if (!dataResponse.daysMask.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, DaysMask); - } - else - { - jobject DaysMaskInsideOptional; - std::string DaysMaskInsideOptionalClassName = "java/lang/Integer"; - std::string DaysMaskInsideOptionalCtorSignature = "(I)V"; - jint jniDaysMaskInsideOptional = static_cast(dataResponse.daysMask.Value().Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject(DaysMaskInsideOptionalClassName.c_str(), - DaysMaskInsideOptionalCtorSignature.c_str(), - jniDaysMaskInsideOptional, DaysMaskInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(DaysMaskInsideOptional, DaysMask); - } - jobject StartHour; - if (!dataResponse.startHour.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StartHour); - } - else - { - jobject StartHourInsideOptional; - std::string StartHourInsideOptionalClassName = "java/lang/Integer"; - std::string StartHourInsideOptionalCtorSignature = "(I)V"; - jint jniStartHourInsideOptional = static_cast(dataResponse.startHour.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(StartHourInsideOptionalClassName.c_str(), - StartHourInsideOptionalCtorSignature.c_str(), - jniStartHourInsideOptional, StartHourInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(StartHourInsideOptional, StartHour); - } - jobject StartMinute; - if (!dataResponse.startMinute.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StartMinute); - } - else - { - jobject StartMinuteInsideOptional; - std::string StartMinuteInsideOptionalClassName = "java/lang/Integer"; - std::string StartMinuteInsideOptionalCtorSignature = "(I)V"; - jint jniStartMinuteInsideOptional = static_cast(dataResponse.startMinute.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(StartMinuteInsideOptionalClassName.c_str(), - StartMinuteInsideOptionalCtorSignature.c_str(), - jniStartMinuteInsideOptional, StartMinuteInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(StartMinuteInsideOptional, StartMinute); - } - jobject EndHour; - if (!dataResponse.endHour.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, EndHour); - } - else - { - jobject EndHourInsideOptional; - std::string EndHourInsideOptionalClassName = "java/lang/Integer"; - std::string EndHourInsideOptionalCtorSignature = "(I)V"; - jint jniEndHourInsideOptional = static_cast(dataResponse.endHour.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(EndHourInsideOptionalClassName.c_str(), - EndHourInsideOptionalCtorSignature.c_str(), - jniEndHourInsideOptional, EndHourInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(EndHourInsideOptional, EndHour); - } - jobject EndMinute; - if (!dataResponse.endMinute.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, EndMinute); - } - else - { - jobject EndMinuteInsideOptional; - std::string EndMinuteInsideOptionalClassName = "java/lang/Integer"; - std::string EndMinuteInsideOptionalCtorSignature = "(I)V"; - jint jniEndMinuteInsideOptional = static_cast(dataResponse.endMinute.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(EndMinuteInsideOptionalClassName.c_str(), - EndMinuteInsideOptionalCtorSignature.c_str(), - jniEndMinuteInsideOptional, EndMinuteInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(EndMinuteInsideOptional, EndMinute); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, WeekDayIndex, UserIndex, Status, DaysMask, StartHour, StartMinute, EndHour, - EndMinute); -} -CHIPDoorLockClusterGetYearDayScheduleResponseCallback::CHIPDoorLockClusterGetYearDayScheduleResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDoorLockClusterGetYearDayScheduleResponseCallback::~CHIPDoorLockClusterGetYearDayScheduleResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDoorLockClusterGetYearDayScheduleResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DoorLock::Commands::GetYearDayScheduleResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject YearDayIndex; - std::string YearDayIndexClassName = "java/lang/Integer"; - std::string YearDayIndexCtorSignature = "(I)V"; - jint jniYearDayIndex = static_cast(dataResponse.yearDayIndex); - chip::JniReferences::GetInstance().CreateBoxedObject(YearDayIndexClassName.c_str(), YearDayIndexCtorSignature.c_str(), - jniYearDayIndex, YearDayIndex); - jobject UserIndex; - std::string UserIndexClassName = "java/lang/Integer"; - std::string UserIndexCtorSignature = "(I)V"; - jint jniUserIndex = static_cast(dataResponse.userIndex); - chip::JniReferences::GetInstance().CreateBoxedObject(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), - jniUserIndex, UserIndex); - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject LocalStartTime; - if (!dataResponse.localStartTime.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, LocalStartTime); - } - else - { - jobject LocalStartTimeInsideOptional; - std::string LocalStartTimeInsideOptionalClassName = "java/lang/Long"; - std::string LocalStartTimeInsideOptionalCtorSignature = "(J)V"; - jlong jniLocalStartTimeInsideOptional = static_cast(dataResponse.localStartTime.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(LocalStartTimeInsideOptionalClassName.c_str(), - LocalStartTimeInsideOptionalCtorSignature.c_str(), - jniLocalStartTimeInsideOptional, LocalStartTimeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(LocalStartTimeInsideOptional, LocalStartTime); - } - jobject LocalEndTime; - if (!dataResponse.localEndTime.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, LocalEndTime); - } - else - { - jobject LocalEndTimeInsideOptional; - std::string LocalEndTimeInsideOptionalClassName = "java/lang/Long"; - std::string LocalEndTimeInsideOptionalCtorSignature = "(J)V"; - jlong jniLocalEndTimeInsideOptional = static_cast(dataResponse.localEndTime.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(LocalEndTimeInsideOptionalClassName.c_str(), - LocalEndTimeInsideOptionalCtorSignature.c_str(), - jniLocalEndTimeInsideOptional, LocalEndTimeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(LocalEndTimeInsideOptional, LocalEndTime); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, YearDayIndex, UserIndex, Status, LocalStartTime, LocalEndTime); -} -CHIPDoorLockClusterGetHolidayScheduleResponseCallback::CHIPDoorLockClusterGetHolidayScheduleResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDoorLockClusterGetHolidayScheduleResponseCallback::~CHIPDoorLockClusterGetHolidayScheduleResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDoorLockClusterGetHolidayScheduleResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DoorLock::Commands::GetHolidayScheduleResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject HolidayIndex; - std::string HolidayIndexClassName = "java/lang/Integer"; - std::string HolidayIndexCtorSignature = "(I)V"; - jint jniHolidayIndex = static_cast(dataResponse.holidayIndex); - chip::JniReferences::GetInstance().CreateBoxedObject(HolidayIndexClassName.c_str(), HolidayIndexCtorSignature.c_str(), - jniHolidayIndex, HolidayIndex); - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject LocalStartTime; - if (!dataResponse.localStartTime.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, LocalStartTime); - } - else - { - jobject LocalStartTimeInsideOptional; - std::string LocalStartTimeInsideOptionalClassName = "java/lang/Long"; - std::string LocalStartTimeInsideOptionalCtorSignature = "(J)V"; - jlong jniLocalStartTimeInsideOptional = static_cast(dataResponse.localStartTime.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(LocalStartTimeInsideOptionalClassName.c_str(), - LocalStartTimeInsideOptionalCtorSignature.c_str(), - jniLocalStartTimeInsideOptional, LocalStartTimeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(LocalStartTimeInsideOptional, LocalStartTime); - } - jobject LocalEndTime; - if (!dataResponse.localEndTime.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, LocalEndTime); - } - else - { - jobject LocalEndTimeInsideOptional; - std::string LocalEndTimeInsideOptionalClassName = "java/lang/Long"; - std::string LocalEndTimeInsideOptionalCtorSignature = "(J)V"; - jlong jniLocalEndTimeInsideOptional = static_cast(dataResponse.localEndTime.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(LocalEndTimeInsideOptionalClassName.c_str(), - LocalEndTimeInsideOptionalCtorSignature.c_str(), - jniLocalEndTimeInsideOptional, LocalEndTimeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(LocalEndTimeInsideOptional, LocalEndTime); - } - jobject OperatingMode; - if (!dataResponse.operatingMode.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, OperatingMode); - } - else - { - jobject OperatingModeInsideOptional; - std::string OperatingModeInsideOptionalClassName = "java/lang/Integer"; - std::string OperatingModeInsideOptionalCtorSignature = "(I)V"; - jint jniOperatingModeInsideOptional = static_cast(dataResponse.operatingMode.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(OperatingModeInsideOptionalClassName.c_str(), - OperatingModeInsideOptionalCtorSignature.c_str(), - jniOperatingModeInsideOptional, OperatingModeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(OperatingModeInsideOptional, OperatingMode); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, HolidayIndex, Status, LocalStartTime, LocalEndTime, OperatingMode); -} -CHIPDoorLockClusterGetUserResponseCallback::CHIPDoorLockClusterGetUserResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDoorLockClusterGetUserResponseCallback::~CHIPDoorLockClusterGetUserResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDoorLockClusterGetUserResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DoorLock::Commands::GetUserResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr cppCallback( - reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/" - "ArrayList;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject UserIndex; - std::string UserIndexClassName = "java/lang/Integer"; - std::string UserIndexCtorSignature = "(I)V"; - jint jniUserIndex = static_cast(dataResponse.userIndex); - chip::JniReferences::GetInstance().CreateBoxedObject(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), - jniUserIndex, UserIndex); - jobject UserName; - if (dataResponse.userName.IsNull()) - { - UserName = nullptr; - } - else - { - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.userName.Value(), UserName)); - } - jobject UserUniqueID; - if (dataResponse.userUniqueID.IsNull()) - { - UserUniqueID = nullptr; - } - else - { - std::string UserUniqueIDClassName = "java/lang/Long"; - std::string UserUniqueIDCtorSignature = "(J)V"; - jlong jniUserUniqueID = static_cast(dataResponse.userUniqueID.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - UserUniqueIDClassName.c_str(), UserUniqueIDCtorSignature.c_str(), jniUserUniqueID, UserUniqueID); - } - jobject UserStatus; - if (dataResponse.userStatus.IsNull()) - { - UserStatus = nullptr; - } - else - { - std::string UserStatusClassName = "java/lang/Integer"; - std::string UserStatusCtorSignature = "(I)V"; - jint jniUserStatus = static_cast(dataResponse.userStatus.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(UserStatusClassName.c_str(), UserStatusCtorSignature.c_str(), - jniUserStatus, UserStatus); - } - jobject UserType; - if (dataResponse.userType.IsNull()) - { - UserType = nullptr; - } - else - { - std::string UserTypeClassName = "java/lang/Integer"; - std::string UserTypeCtorSignature = "(I)V"; - jint jniUserType = static_cast(dataResponse.userType.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(UserTypeClassName.c_str(), UserTypeCtorSignature.c_str(), - jniUserType, UserType); - } - jobject CredentialRule; - if (dataResponse.credentialRule.IsNull()) - { - CredentialRule = nullptr; - } - else - { - std::string CredentialRuleClassName = "java/lang/Integer"; - std::string CredentialRuleCtorSignature = "(I)V"; - jint jniCredentialRule = static_cast(dataResponse.credentialRule.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - CredentialRuleClassName.c_str(), CredentialRuleCtorSignature.c_str(), jniCredentialRule, CredentialRule); - } - jobject Credentials; - if (dataResponse.credentials.IsNull()) - { - Credentials = nullptr; - } - else - { - chip::JniReferences::GetInstance().CreateArrayList(Credentials); - - auto iter_Credentials_1 = dataResponse.credentials.Value().begin(); - while (iter_Credentials_1.Next()) - { - auto & entry_1 = iter_Credentials_1.GetValue(); - jobject newElement_1; - jobject newElement_1_credentialType; - std::string newElement_1_credentialTypeClassName = "java/lang/Integer"; - std::string newElement_1_credentialTypeCtorSignature = "(I)V"; - jint jninewElement_1_credentialType = static_cast(entry_1.credentialType); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_credentialTypeClassName.c_str(), - newElement_1_credentialTypeCtorSignature.c_str(), - jninewElement_1_credentialType, newElement_1_credentialType); - jobject newElement_1_credentialIndex; - std::string newElement_1_credentialIndexClassName = "java/lang/Integer"; - std::string newElement_1_credentialIndexCtorSignature = "(I)V"; - jint jninewElement_1_credentialIndex = static_cast(entry_1.credentialIndex); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_1_credentialIndexClassName.c_str(), newElement_1_credentialIndexCtorSignature.c_str(), - jninewElement_1_credentialIndex, newElement_1_credentialIndex); - - jclass credentialStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$DoorLockClusterCredentialStruct", credentialStructStructClass_2); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$DoorLockClusterCredentialStruct"); - return; - } - - jmethodID credentialStructStructCtor_2; - err = chip::JniReferences::GetInstance().FindMethod(env, credentialStructStructClass_2, "", - "(Ljava/lang/Integer;Ljava/lang/Integer;)V", - &credentialStructStructCtor_2); - if (err != CHIP_NO_ERROR || credentialStructStructCtor_2 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$DoorLockClusterCredentialStruct constructor"); - return; - } - - newElement_1 = env->NewObject(credentialStructStructClass_2, credentialStructStructCtor_2, newElement_1_credentialType, - newElement_1_credentialIndex); - chip::JniReferences::GetInstance().AddToList(Credentials, newElement_1); - } - } - jobject CreatorFabricIndex; - if (dataResponse.creatorFabricIndex.IsNull()) - { - CreatorFabricIndex = nullptr; - } - else - { - std::string CreatorFabricIndexClassName = "java/lang/Integer"; - std::string CreatorFabricIndexCtorSignature = "(I)V"; - jint jniCreatorFabricIndex = static_cast(dataResponse.creatorFabricIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(CreatorFabricIndexClassName.c_str(), - CreatorFabricIndexCtorSignature.c_str(), jniCreatorFabricIndex, - CreatorFabricIndex); - } - jobject LastModifiedFabricIndex; - if (dataResponse.lastModifiedFabricIndex.IsNull()) - { - LastModifiedFabricIndex = nullptr; - } - else - { - std::string LastModifiedFabricIndexClassName = "java/lang/Integer"; - std::string LastModifiedFabricIndexCtorSignature = "(I)V"; - jint jniLastModifiedFabricIndex = static_cast(dataResponse.lastModifiedFabricIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(LastModifiedFabricIndexClassName.c_str(), - LastModifiedFabricIndexCtorSignature.c_str(), - jniLastModifiedFabricIndex, LastModifiedFabricIndex); - } - jobject NextUserIndex; - if (dataResponse.nextUserIndex.IsNull()) - { - NextUserIndex = nullptr; - } - else - { - std::string NextUserIndexClassName = "java/lang/Integer"; - std::string NextUserIndexCtorSignature = "(I)V"; - jint jniNextUserIndex = static_cast(dataResponse.nextUserIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NextUserIndexClassName.c_str(), NextUserIndexCtorSignature.c_str(), jniNextUserIndex, NextUserIndex); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, UserIndex, UserName, UserUniqueID, UserStatus, UserType, CredentialRule, - Credentials, CreatorFabricIndex, LastModifiedFabricIndex, NextUserIndex); -} -CHIPDoorLockClusterSetCredentialResponseCallback::CHIPDoorLockClusterSetCredentialResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDoorLockClusterSetCredentialResponseCallback::~CHIPDoorLockClusterSetCredentialResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDoorLockClusterSetCredentialResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DoorLock::Commands::SetCredentialResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject UserIndex; - if (dataResponse.userIndex.IsNull()) - { - UserIndex = nullptr; - } - else - { - std::string UserIndexClassName = "java/lang/Integer"; - std::string UserIndexCtorSignature = "(I)V"; - jint jniUserIndex = static_cast(dataResponse.userIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), - jniUserIndex, UserIndex); - } - jobject NextCredentialIndex; - if (dataResponse.nextCredentialIndex.IsNull()) - { - NextCredentialIndex = nullptr; - } - else - { - std::string NextCredentialIndexClassName = "java/lang/Integer"; - std::string NextCredentialIndexCtorSignature = "(I)V"; - jint jniNextCredentialIndex = static_cast(dataResponse.nextCredentialIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(NextCredentialIndexClassName.c_str(), - NextCredentialIndexCtorSignature.c_str(), jniNextCredentialIndex, - NextCredentialIndex); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, UserIndex, NextCredentialIndex); -} -CHIPDoorLockClusterGetCredentialStatusResponseCallback::CHIPDoorLockClusterGetCredentialStatusResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDoorLockClusterGetCredentialStatusResponseCallback::~CHIPDoorLockClusterGetCredentialStatusResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDoorLockClusterGetCredentialStatusResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DoorLock::Commands::GetCredentialStatusResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Boolean;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject CredentialExists; - std::string CredentialExistsClassName = "java/lang/Boolean"; - std::string CredentialExistsCtorSignature = "(Z)V"; - jboolean jniCredentialExists = static_cast(dataResponse.credentialExists); - chip::JniReferences::GetInstance().CreateBoxedObject( - CredentialExistsClassName.c_str(), CredentialExistsCtorSignature.c_str(), jniCredentialExists, CredentialExists); - jobject UserIndex; - if (dataResponse.userIndex.IsNull()) - { - UserIndex = nullptr; - } - else - { - std::string UserIndexClassName = "java/lang/Integer"; - std::string UserIndexCtorSignature = "(I)V"; - jint jniUserIndex = static_cast(dataResponse.userIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), - jniUserIndex, UserIndex); - } - jobject CreatorFabricIndex; - if (dataResponse.creatorFabricIndex.IsNull()) - { - CreatorFabricIndex = nullptr; - } - else - { - std::string CreatorFabricIndexClassName = "java/lang/Integer"; - std::string CreatorFabricIndexCtorSignature = "(I)V"; - jint jniCreatorFabricIndex = static_cast(dataResponse.creatorFabricIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(CreatorFabricIndexClassName.c_str(), - CreatorFabricIndexCtorSignature.c_str(), jniCreatorFabricIndex, - CreatorFabricIndex); - } - jobject LastModifiedFabricIndex; - if (dataResponse.lastModifiedFabricIndex.IsNull()) - { - LastModifiedFabricIndex = nullptr; - } - else - { - std::string LastModifiedFabricIndexClassName = "java/lang/Integer"; - std::string LastModifiedFabricIndexCtorSignature = "(I)V"; - jint jniLastModifiedFabricIndex = static_cast(dataResponse.lastModifiedFabricIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(LastModifiedFabricIndexClassName.c_str(), - LastModifiedFabricIndexCtorSignature.c_str(), - jniLastModifiedFabricIndex, LastModifiedFabricIndex); - } - jobject NextCredentialIndex; - if (dataResponse.nextCredentialIndex.IsNull()) - { - NextCredentialIndex = nullptr; - } - else - { - std::string NextCredentialIndexClassName = "java/lang/Integer"; - std::string NextCredentialIndexCtorSignature = "(I)V"; - jint jniNextCredentialIndex = static_cast(dataResponse.nextCredentialIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(NextCredentialIndexClassName.c_str(), - NextCredentialIndexCtorSignature.c_str(), jniNextCredentialIndex, - NextCredentialIndex); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, CredentialExists, UserIndex, CreatorFabricIndex, LastModifiedFabricIndex, - NextCredentialIndex); -} -CHIPThermostatClusterGetWeeklyScheduleResponseCallback::CHIPThermostatClusterGetWeeklyScheduleResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPThermostatClusterGetWeeklyScheduleResponseCallback::~CHIPThermostatClusterGetWeeklyScheduleResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPThermostatClusterGetWeeklyScheduleResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::Thermostat::Commands::GetWeeklyScheduleResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/ArrayList;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject NumberOfTransitionsForSequence; - std::string NumberOfTransitionsForSequenceClassName = "java/lang/Integer"; - std::string NumberOfTransitionsForSequenceCtorSignature = "(I)V"; - jint jniNumberOfTransitionsForSequence = static_cast(dataResponse.numberOfTransitionsForSequence); - chip::JniReferences::GetInstance().CreateBoxedObject(NumberOfTransitionsForSequenceClassName.c_str(), - NumberOfTransitionsForSequenceCtorSignature.c_str(), - jniNumberOfTransitionsForSequence, NumberOfTransitionsForSequence); - jobject DayOfWeekForSequence; - std::string DayOfWeekForSequenceClassName = "java/lang/Integer"; - std::string DayOfWeekForSequenceCtorSignature = "(I)V"; - jint jniDayOfWeekForSequence = static_cast(dataResponse.dayOfWeekForSequence.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject(DayOfWeekForSequenceClassName.c_str(), - DayOfWeekForSequenceCtorSignature.c_str(), jniDayOfWeekForSequence, - DayOfWeekForSequence); - jobject ModeForSequence; - std::string ModeForSequenceClassName = "java/lang/Integer"; - std::string ModeForSequenceCtorSignature = "(I)V"; - jint jniModeForSequence = static_cast(dataResponse.modeForSequence.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - ModeForSequenceClassName.c_str(), ModeForSequenceCtorSignature.c_str(), jniModeForSequence, ModeForSequence); - jobject Transitions; - chip::JniReferences::GetInstance().CreateArrayList(Transitions); - - auto iter_Transitions_0 = dataResponse.transitions.begin(); - while (iter_Transitions_0.Next()) - { - auto & entry_0 = iter_Transitions_0.GetValue(); - jobject newElement_0; - jobject newElement_0_transitionTime; - std::string newElement_0_transitionTimeClassName = "java/lang/Integer"; - std::string newElement_0_transitionTimeCtorSignature = "(I)V"; - jint jninewElement_0_transitionTime = static_cast(entry_0.transitionTime); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_transitionTimeClassName.c_str(), - newElement_0_transitionTimeCtorSignature.c_str(), - jninewElement_0_transitionTime, newElement_0_transitionTime); - jobject newElement_0_heatSetpoint; - if (entry_0.heatSetpoint.IsNull()) - { - newElement_0_heatSetpoint = nullptr; - } - else - { - std::string newElement_0_heatSetpointClassName = "java/lang/Integer"; - std::string newElement_0_heatSetpointCtorSignature = "(I)V"; - jint jninewElement_0_heatSetpoint = static_cast(entry_0.heatSetpoint.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_heatSetpointClassName.c_str(), - newElement_0_heatSetpointCtorSignature.c_str(), - jninewElement_0_heatSetpoint, newElement_0_heatSetpoint); - } - jobject newElement_0_coolSetpoint; - if (entry_0.coolSetpoint.IsNull()) - { - newElement_0_coolSetpoint = nullptr; - } - else - { - std::string newElement_0_coolSetpointClassName = "java/lang/Integer"; - std::string newElement_0_coolSetpointCtorSignature = "(I)V"; - jint jninewElement_0_coolSetpoint = static_cast(entry_0.coolSetpoint.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_coolSetpointClassName.c_str(), - newElement_0_coolSetpointCtorSignature.c_str(), - jninewElement_0_coolSetpoint, newElement_0_coolSetpoint); - } - - jclass weeklyScheduleTransitionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ThermostatClusterWeeklyScheduleTransitionStruct", - weeklyScheduleTransitionStructStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ThermostatClusterWeeklyScheduleTransitionStruct"); - return; - } - - jmethodID weeklyScheduleTransitionStructStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod(env, weeklyScheduleTransitionStructStructClass_1, "", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", - &weeklyScheduleTransitionStructStructCtor_1); - if (err != CHIP_NO_ERROR || weeklyScheduleTransitionStructStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ThermostatClusterWeeklyScheduleTransitionStruct constructor"); - return; - } - - newElement_0 = env->NewObject(weeklyScheduleTransitionStructStructClass_1, weeklyScheduleTransitionStructStructCtor_1, - newElement_0_transitionTime, newElement_0_heatSetpoint, newElement_0_coolSetpoint); - chip::JniReferences::GetInstance().AddToList(Transitions, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, NumberOfTransitionsForSequence, DayOfWeekForSequence, ModeForSequence, - Transitions); -} -CHIPChannelClusterChangeChannelResponseCallback::CHIPChannelClusterChangeChannelResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPChannelClusterChangeChannelResponseCallback::~CHIPChannelClusterChangeChannelResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPChannelClusterChangeChannelResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::Channel::Commands::ChangeChannelResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject Data; - if (!dataResponse.data.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); - } - else - { - jobject DataInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); -} -CHIPChannelClusterProgramGuideResponseCallback::CHIPChannelClusterProgramGuideResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPChannelClusterProgramGuideResponseCallback::~CHIPChannelClusterProgramGuideResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPChannelClusterProgramGuideResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::Channel::Commands::ProgramGuideResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Lchip/devicecontroller/ChipStructs$ChannelClusterChannelPagingStruct;Ljava/util/ArrayList;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Paging; - jobject Paging_previousToken; - if (!dataResponse.paging.previousToken.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_previousToken); - } - else - { - jobject Paging_previousTokenInsideOptional; - if (dataResponse.paging.previousToken.Value().IsNull()) - { - Paging_previousTokenInsideOptional = nullptr; - } - else - { - jobject Paging_previousTokenInsideOptional_limit; - if (!dataResponse.paging.previousToken.Value().Value().limit.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_previousTokenInsideOptional_limit); - } - else - { - jobject Paging_previousTokenInsideOptional_limitInsideOptional; - std::string Paging_previousTokenInsideOptional_limitInsideOptionalClassName = "java/lang/Integer"; - std::string Paging_previousTokenInsideOptional_limitInsideOptionalCtorSignature = "(I)V"; - jint jniPaging_previousTokenInsideOptional_limitInsideOptional = - static_cast(dataResponse.paging.previousToken.Value().Value().limit.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - Paging_previousTokenInsideOptional_limitInsideOptionalClassName.c_str(), - Paging_previousTokenInsideOptional_limitInsideOptionalCtorSignature.c_str(), - jniPaging_previousTokenInsideOptional_limitInsideOptional, - Paging_previousTokenInsideOptional_limitInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(Paging_previousTokenInsideOptional_limitInsideOptional, - Paging_previousTokenInsideOptional_limit); - } - jobject Paging_previousTokenInsideOptional_after; - if (!dataResponse.paging.previousToken.Value().Value().after.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_previousTokenInsideOptional_after); - } - else - { - jobject Paging_previousTokenInsideOptional_afterInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.paging.previousToken.Value().Value().after.Value(), - Paging_previousTokenInsideOptional_afterInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(Paging_previousTokenInsideOptional_afterInsideOptional, - Paging_previousTokenInsideOptional_after); - } - jobject Paging_previousTokenInsideOptional_before; - if (!dataResponse.paging.previousToken.Value().Value().before.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_previousTokenInsideOptional_before); - } - else - { - jobject Paging_previousTokenInsideOptional_beforeInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.paging.previousToken.Value().Value().before.Value(), - Paging_previousTokenInsideOptional_beforeInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(Paging_previousTokenInsideOptional_beforeInsideOptional, - Paging_previousTokenInsideOptional_before); - } - - jclass pageTokenStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ChannelClusterPageTokenStruct", pageTokenStructStructClass_3); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterPageTokenStruct"); - return; - } - - jmethodID pageTokenStructStructCtor_3; - err = chip::JniReferences::GetInstance().FindMethod(env, pageTokenStructStructClass_3, "", - "(Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &pageTokenStructStructCtor_3); - if (err != CHIP_NO_ERROR || pageTokenStructStructCtor_3 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterPageTokenStruct constructor"); - return; - } - - Paging_previousTokenInsideOptional = - env->NewObject(pageTokenStructStructClass_3, pageTokenStructStructCtor_3, Paging_previousTokenInsideOptional_limit, - Paging_previousTokenInsideOptional_after, Paging_previousTokenInsideOptional_before); - } - chip::JniReferences::GetInstance().CreateOptional(Paging_previousTokenInsideOptional, Paging_previousToken); - } - jobject Paging_nextToken; - if (!dataResponse.paging.nextToken.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_nextToken); - } - else - { - jobject Paging_nextTokenInsideOptional; - if (dataResponse.paging.nextToken.Value().IsNull()) - { - Paging_nextTokenInsideOptional = nullptr; - } - else - { - jobject Paging_nextTokenInsideOptional_limit; - if (!dataResponse.paging.nextToken.Value().Value().limit.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_nextTokenInsideOptional_limit); - } - else - { - jobject Paging_nextTokenInsideOptional_limitInsideOptional; - std::string Paging_nextTokenInsideOptional_limitInsideOptionalClassName = "java/lang/Integer"; - std::string Paging_nextTokenInsideOptional_limitInsideOptionalCtorSignature = "(I)V"; - jint jniPaging_nextTokenInsideOptional_limitInsideOptional = - static_cast(dataResponse.paging.nextToken.Value().Value().limit.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - Paging_nextTokenInsideOptional_limitInsideOptionalClassName.c_str(), - Paging_nextTokenInsideOptional_limitInsideOptionalCtorSignature.c_str(), - jniPaging_nextTokenInsideOptional_limitInsideOptional, Paging_nextTokenInsideOptional_limitInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(Paging_nextTokenInsideOptional_limitInsideOptional, - Paging_nextTokenInsideOptional_limit); - } - jobject Paging_nextTokenInsideOptional_after; - if (!dataResponse.paging.nextToken.Value().Value().after.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_nextTokenInsideOptional_after); - } - else - { - jobject Paging_nextTokenInsideOptional_afterInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.paging.nextToken.Value().Value().after.Value(), - Paging_nextTokenInsideOptional_afterInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(Paging_nextTokenInsideOptional_afterInsideOptional, - Paging_nextTokenInsideOptional_after); - } - jobject Paging_nextTokenInsideOptional_before; - if (!dataResponse.paging.nextToken.Value().Value().before.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_nextTokenInsideOptional_before); - } - else - { - jobject Paging_nextTokenInsideOptional_beforeInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.paging.nextToken.Value().Value().before.Value(), - Paging_nextTokenInsideOptional_beforeInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(Paging_nextTokenInsideOptional_beforeInsideOptional, - Paging_nextTokenInsideOptional_before); - } - - jclass pageTokenStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ChannelClusterPageTokenStruct", pageTokenStructStructClass_3); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterPageTokenStruct"); - return; - } - - jmethodID pageTokenStructStructCtor_3; - err = chip::JniReferences::GetInstance().FindMethod(env, pageTokenStructStructClass_3, "", - "(Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &pageTokenStructStructCtor_3); - if (err != CHIP_NO_ERROR || pageTokenStructStructCtor_3 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterPageTokenStruct constructor"); - return; - } - - Paging_nextTokenInsideOptional = - env->NewObject(pageTokenStructStructClass_3, pageTokenStructStructCtor_3, Paging_nextTokenInsideOptional_limit, - Paging_nextTokenInsideOptional_after, Paging_nextTokenInsideOptional_before); - } - chip::JniReferences::GetInstance().CreateOptional(Paging_nextTokenInsideOptional, Paging_nextToken); - } - - jclass channelPagingStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs$ChannelClusterChannelPagingStruct", - channelPagingStructStructClass_0); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterChannelPagingStruct"); - return; - } - - jmethodID channelPagingStructStructCtor_0; - err = chip::JniReferences::GetInstance().FindMethod(env, channelPagingStructStructClass_0, "", - "(Ljava/util/Optional;Ljava/util/Optional;)V", - &channelPagingStructStructCtor_0); - if (err != CHIP_NO_ERROR || channelPagingStructStructCtor_0 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterChannelPagingStruct constructor"); - return; - } - - Paging = - env->NewObject(channelPagingStructStructClass_0, channelPagingStructStructCtor_0, Paging_previousToken, Paging_nextToken); - jobject ProgramList; - chip::JniReferences::GetInstance().CreateArrayList(ProgramList); - - auto iter_ProgramList_0 = dataResponse.programList.begin(); - while (iter_ProgramList_0.Next()) - { - auto & entry_0 = iter_ProgramList_0.GetValue(); - jobject newElement_0; - jobject newElement_0_identifier; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.identifier, newElement_0_identifier)); - jobject newElement_0_channel; - jobject newElement_0_channel_majorNumber; - std::string newElement_0_channel_majorNumberClassName = "java/lang/Integer"; - std::string newElement_0_channel_majorNumberCtorSignature = "(I)V"; - jint jninewElement_0_channel_majorNumber = static_cast(entry_0.channel.majorNumber); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_channel_majorNumberClassName.c_str(), newElement_0_channel_majorNumberCtorSignature.c_str(), - jninewElement_0_channel_majorNumber, newElement_0_channel_majorNumber); - jobject newElement_0_channel_minorNumber; - std::string newElement_0_channel_minorNumberClassName = "java/lang/Integer"; - std::string newElement_0_channel_minorNumberCtorSignature = "(I)V"; - jint jninewElement_0_channel_minorNumber = static_cast(entry_0.channel.minorNumber); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_channel_minorNumberClassName.c_str(), newElement_0_channel_minorNumberCtorSignature.c_str(), - jninewElement_0_channel_minorNumber, newElement_0_channel_minorNumber); - jobject newElement_0_channel_name; - if (!entry_0.channel.name.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_name); - } - else - { - jobject newElement_0_channel_nameInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.channel.name.Value(), - newElement_0_channel_nameInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_nameInsideOptional, newElement_0_channel_name); - } - jobject newElement_0_channel_callSign; - if (!entry_0.channel.callSign.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_callSign); - } - else - { - jobject newElement_0_channel_callSignInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.channel.callSign.Value(), - newElement_0_channel_callSignInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_callSignInsideOptional, - newElement_0_channel_callSign); - } - jobject newElement_0_channel_affiliateCallSign; - if (!entry_0.channel.affiliateCallSign.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_affiliateCallSign); - } - else - { - jobject newElement_0_channel_affiliateCallSignInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - entry_0.channel.affiliateCallSign.Value(), newElement_0_channel_affiliateCallSignInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_affiliateCallSignInsideOptional, - newElement_0_channel_affiliateCallSign); - } - jobject newElement_0_channel_identifier; - if (!entry_0.channel.identifier.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_identifier); - } - else - { - jobject newElement_0_channel_identifierInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.channel.identifier.Value(), - newElement_0_channel_identifierInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_identifierInsideOptional, - newElement_0_channel_identifier); - } - jobject newElement_0_channel_type; - if (!entry_0.channel.type.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_type); - } - else - { - jobject newElement_0_channel_typeInsideOptional; - std::string newElement_0_channel_typeInsideOptionalClassName = "java/lang/Integer"; - std::string newElement_0_channel_typeInsideOptionalCtorSignature = "(I)V"; - jint jninewElement_0_channel_typeInsideOptional = static_cast(entry_0.channel.type.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_channel_typeInsideOptionalClassName.c_str(), - newElement_0_channel_typeInsideOptionalCtorSignature.c_str(), - jninewElement_0_channel_typeInsideOptional, - newElement_0_channel_typeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_typeInsideOptional, newElement_0_channel_type); - } - - jclass channelInfoStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ChannelClusterChannelInfoStruct", channelInfoStructStructClass_2); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterChannelInfoStruct"); - return; - } - - jmethodID channelInfoStructStructCtor_2; - err = - chip::JniReferences::GetInstance().FindMethod(env, channelInfoStructStructClass_2, "", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/" - "Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &channelInfoStructStructCtor_2); - if (err != CHIP_NO_ERROR || channelInfoStructStructCtor_2 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterChannelInfoStruct constructor"); - return; - } - - newElement_0_channel = - env->NewObject(channelInfoStructStructClass_2, channelInfoStructStructCtor_2, newElement_0_channel_majorNumber, - newElement_0_channel_minorNumber, newElement_0_channel_name, newElement_0_channel_callSign, - newElement_0_channel_affiliateCallSign, newElement_0_channel_identifier, newElement_0_channel_type); - jobject newElement_0_startTime; - std::string newElement_0_startTimeClassName = "java/lang/Long"; - std::string newElement_0_startTimeCtorSignature = "(J)V"; - jlong jninewElement_0_startTime = static_cast(entry_0.startTime); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_startTimeClassName.c_str(), - newElement_0_startTimeCtorSignature.c_str(), - jninewElement_0_startTime, newElement_0_startTime); - jobject newElement_0_endTime; - std::string newElement_0_endTimeClassName = "java/lang/Long"; - std::string newElement_0_endTimeCtorSignature = "(J)V"; - jlong jninewElement_0_endTime = static_cast(entry_0.endTime); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_endTimeClassName.c_str(), - newElement_0_endTimeCtorSignature.c_str(), - jninewElement_0_endTime, newElement_0_endTime); - jobject newElement_0_title; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.title, newElement_0_title)); - jobject newElement_0_subtitle; - if (!entry_0.subtitle.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_subtitle); - } - else - { - jobject newElement_0_subtitleInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(entry_0.subtitle.Value(), newElement_0_subtitleInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_subtitleInsideOptional, newElement_0_subtitle); - } - jobject newElement_0_description; - if (!entry_0.description.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_description); - } - else - { - jobject newElement_0_descriptionInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.description.Value(), - newElement_0_descriptionInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_descriptionInsideOptional, newElement_0_description); - } - jobject newElement_0_audioLanguages; - if (!entry_0.audioLanguages.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_audioLanguages); - } - else - { - jobject newElement_0_audioLanguagesInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_audioLanguagesInsideOptional); - - auto iter_newElement_0_audioLanguagesInsideOptional_3 = entry_0.audioLanguages.Value().begin(); - while (iter_newElement_0_audioLanguagesInsideOptional_3.Next()) - { - auto & entry_3 = iter_newElement_0_audioLanguagesInsideOptional_3.GetValue(); - jobject newElement_3; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3, newElement_3)); - chip::JniReferences::GetInstance().AddToList(newElement_0_audioLanguagesInsideOptional, newElement_3); - } - chip::JniReferences::GetInstance().CreateOptional(newElement_0_audioLanguagesInsideOptional, - newElement_0_audioLanguages); - } - jobject newElement_0_ratings; - if (!entry_0.ratings.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_ratings); - } - else - { - jobject newElement_0_ratingsInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_ratingsInsideOptional); - - auto iter_newElement_0_ratingsInsideOptional_3 = entry_0.ratings.Value().begin(); - while (iter_newElement_0_ratingsInsideOptional_3.Next()) - { - auto & entry_3 = iter_newElement_0_ratingsInsideOptional_3.GetValue(); - jobject newElement_3; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3, newElement_3)); - chip::JniReferences::GetInstance().AddToList(newElement_0_ratingsInsideOptional, newElement_3); - } - chip::JniReferences::GetInstance().CreateOptional(newElement_0_ratingsInsideOptional, newElement_0_ratings); - } - jobject newElement_0_thumbnailUrl; - if (!entry_0.thumbnailUrl.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_thumbnailUrl); - } - else - { - jobject newElement_0_thumbnailUrlInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.thumbnailUrl.Value(), - newElement_0_thumbnailUrlInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_thumbnailUrlInsideOptional, newElement_0_thumbnailUrl); - } - jobject newElement_0_posterArtUrl; - if (!entry_0.posterArtUrl.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_posterArtUrl); - } - else - { - jobject newElement_0_posterArtUrlInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.posterArtUrl.Value(), - newElement_0_posterArtUrlInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_posterArtUrlInsideOptional, newElement_0_posterArtUrl); - } - jobject newElement_0_dvbiUrl; - if (!entry_0.dvbiUrl.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_dvbiUrl); - } - else - { - jobject newElement_0_dvbiUrlInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(entry_0.dvbiUrl.Value(), newElement_0_dvbiUrlInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_dvbiUrlInsideOptional, newElement_0_dvbiUrl); - } - jobject newElement_0_releaseDate; - if (!entry_0.releaseDate.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_releaseDate); - } - else - { - jobject newElement_0_releaseDateInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.releaseDate.Value(), - newElement_0_releaseDateInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_releaseDateInsideOptional, newElement_0_releaseDate); - } - jobject newElement_0_parentalGuidanceText; - if (!entry_0.parentalGuidanceText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_parentalGuidanceText); - } - else - { - jobject newElement_0_parentalGuidanceTextInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.parentalGuidanceText.Value(), - newElement_0_parentalGuidanceTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_parentalGuidanceTextInsideOptional, - newElement_0_parentalGuidanceText); - } - jobject newElement_0_recordingFlag; - if (!entry_0.recordingFlag.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_recordingFlag); - } - else - { - jobject newElement_0_recordingFlagInsideOptional; - std::string newElement_0_recordingFlagInsideOptionalClassName = "java/lang/Long"; - std::string newElement_0_recordingFlagInsideOptionalCtorSignature = "(J)V"; - jlong jninewElement_0_recordingFlagInsideOptional = static_cast(entry_0.recordingFlag.Value().Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_recordingFlagInsideOptionalClassName.c_str(), - newElement_0_recordingFlagInsideOptionalCtorSignature.c_str(), jninewElement_0_recordingFlagInsideOptional, - newElement_0_recordingFlagInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_recordingFlagInsideOptional, newElement_0_recordingFlag); - } - jobject newElement_0_seriesInfo; - if (!entry_0.seriesInfo.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_seriesInfo); - } - else - { - jobject newElement_0_seriesInfoInsideOptional; - if (entry_0.seriesInfo.Value().IsNull()) - { - newElement_0_seriesInfoInsideOptional = nullptr; - } - else - { - jobject newElement_0_seriesInfoInsideOptional_season; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.seriesInfo.Value().Value().season, - newElement_0_seriesInfoInsideOptional_season)); - jobject newElement_0_seriesInfoInsideOptional_episode; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - entry_0.seriesInfo.Value().Value().episode, newElement_0_seriesInfoInsideOptional_episode)); - - jclass seriesInfoStructStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ChannelClusterSeriesInfoStruct", seriesInfoStructStructClass_4); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterSeriesInfoStruct"); - return; - } - - jmethodID seriesInfoStructStructCtor_4; - err = chip::JniReferences::GetInstance().FindMethod(env, seriesInfoStructStructClass_4, "", - "(Ljava/lang/String;Ljava/lang/String;)V", - &seriesInfoStructStructCtor_4); - if (err != CHIP_NO_ERROR || seriesInfoStructStructCtor_4 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterSeriesInfoStruct constructor"); - return; - } - - newElement_0_seriesInfoInsideOptional = - env->NewObject(seriesInfoStructStructClass_4, seriesInfoStructStructCtor_4, - newElement_0_seriesInfoInsideOptional_season, newElement_0_seriesInfoInsideOptional_episode); - } - chip::JniReferences::GetInstance().CreateOptional(newElement_0_seriesInfoInsideOptional, newElement_0_seriesInfo); - } - jobject newElement_0_categoryList; - if (!entry_0.categoryList.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_categoryList); - } - else - { - jobject newElement_0_categoryListInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_categoryListInsideOptional); - - auto iter_newElement_0_categoryListInsideOptional_3 = entry_0.categoryList.Value().begin(); - while (iter_newElement_0_categoryListInsideOptional_3.Next()) - { - auto & entry_3 = iter_newElement_0_categoryListInsideOptional_3.GetValue(); - jobject newElement_3; - jobject newElement_3_category; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.category, newElement_3_category)); - jobject newElement_3_subCategory; - if (!entry_3.subCategory.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_3_subCategory); - } - else - { - jobject newElement_3_subCategoryInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.subCategory.Value(), - newElement_3_subCategoryInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_3_subCategoryInsideOptional, - newElement_3_subCategory); - } - - jclass programCategoryStructStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ChannelClusterProgramCategoryStruct", - programCategoryStructStructClass_4); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterProgramCategoryStruct"); - return; - } - - jmethodID programCategoryStructStructCtor_4; - err = chip::JniReferences::GetInstance().FindMethod(env, programCategoryStructStructClass_4, "", - "(Ljava/lang/String;Ljava/util/Optional;)V", - &programCategoryStructStructCtor_4); - if (err != CHIP_NO_ERROR || programCategoryStructStructCtor_4 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterProgramCategoryStruct constructor"); - return; - } - - newElement_3 = env->NewObject(programCategoryStructStructClass_4, programCategoryStructStructCtor_4, - newElement_3_category, newElement_3_subCategory); - chip::JniReferences::GetInstance().AddToList(newElement_0_categoryListInsideOptional, newElement_3); - } - chip::JniReferences::GetInstance().CreateOptional(newElement_0_categoryListInsideOptional, newElement_0_categoryList); - } - jobject newElement_0_castList; - if (!entry_0.castList.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_castList); - } - else - { - jobject newElement_0_castListInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_castListInsideOptional); - - auto iter_newElement_0_castListInsideOptional_3 = entry_0.castList.Value().begin(); - while (iter_newElement_0_castListInsideOptional_3.Next()) - { - auto & entry_3 = iter_newElement_0_castListInsideOptional_3.GetValue(); - jobject newElement_3; - jobject newElement_3_name; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.name, newElement_3_name)); - jobject newElement_3_role; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.role, newElement_3_role)); - - jclass programCastStructStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ChannelClusterProgramCastStruct", programCastStructStructClass_4); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterProgramCastStruct"); - return; - } - - jmethodID programCastStructStructCtor_4; - err = chip::JniReferences::GetInstance().FindMethod(env, programCastStructStructClass_4, "", - "(Ljava/lang/String;Ljava/lang/String;)V", - &programCastStructStructCtor_4); - if (err != CHIP_NO_ERROR || programCastStructStructCtor_4 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterProgramCastStruct constructor"); - return; - } - - newElement_3 = env->NewObject(programCastStructStructClass_4, programCastStructStructCtor_4, newElement_3_name, - newElement_3_role); - chip::JniReferences::GetInstance().AddToList(newElement_0_castListInsideOptional, newElement_3); - } - chip::JniReferences::GetInstance().CreateOptional(newElement_0_castListInsideOptional, newElement_0_castList); - } - jobject newElement_0_externalIDList; - if (!entry_0.externalIDList.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_externalIDList); - } - else - { - jobject newElement_0_externalIDListInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_externalIDListInsideOptional); - - auto iter_newElement_0_externalIDListInsideOptional_3 = entry_0.externalIDList.Value().begin(); - while (iter_newElement_0_externalIDListInsideOptional_3.Next()) - { - auto & entry_3 = iter_newElement_0_externalIDListInsideOptional_3.GetValue(); - jobject newElement_3; - jobject newElement_3_name; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.name, newElement_3_name)); - jobject newElement_3_role; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.role, newElement_3_role)); - - jclass programCastStructStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ChannelClusterProgramCastStruct", programCastStructStructClass_4); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterProgramCastStruct"); - return; - } - - jmethodID programCastStructStructCtor_4; - err = chip::JniReferences::GetInstance().FindMethod(env, programCastStructStructClass_4, "", - "(Ljava/lang/String;Ljava/lang/String;)V", - &programCastStructStructCtor_4); - if (err != CHIP_NO_ERROR || programCastStructStructCtor_4 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterProgramCastStruct constructor"); - return; - } - - newElement_3 = env->NewObject(programCastStructStructClass_4, programCastStructStructCtor_4, newElement_3_name, - newElement_3_role); - chip::JniReferences::GetInstance().AddToList(newElement_0_externalIDListInsideOptional, newElement_3); - } - chip::JniReferences::GetInstance().CreateOptional(newElement_0_externalIDListInsideOptional, - newElement_0_externalIDList); - } - - jclass programStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs$ChannelClusterProgramStruct", - programStructStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterProgramStruct"); - return; - } - - jmethodID programStructStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod( - env, programStructStructClass_1, "", - "(Ljava/lang/String;Lchip/devicecontroller/ChipStructs$ChannelClusterChannelInfoStruct;Ljava/lang/Long;Ljava/lang/" - "Long;Ljava/lang/String;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" - "Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/" - "util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &programStructStructCtor_1); - if (err != CHIP_NO_ERROR || programStructStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterProgramStruct constructor"); - return; - } - - newElement_0 = env->NewObject( - programStructStructClass_1, programStructStructCtor_1, newElement_0_identifier, newElement_0_channel, - newElement_0_startTime, newElement_0_endTime, newElement_0_title, newElement_0_subtitle, newElement_0_description, - newElement_0_audioLanguages, newElement_0_ratings, newElement_0_thumbnailUrl, newElement_0_posterArtUrl, - newElement_0_dvbiUrl, newElement_0_releaseDate, newElement_0_parentalGuidanceText, newElement_0_recordingFlag, - newElement_0_seriesInfo, newElement_0_categoryList, newElement_0_castList, newElement_0_externalIDList); - chip::JniReferences::GetInstance().AddToList(ProgramList, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Paging, ProgramList); -} -CHIPTargetNavigatorClusterNavigateTargetResponseCallback::CHIPTargetNavigatorClusterNavigateTargetResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPTargetNavigatorClusterNavigateTargetResponseCallback::~CHIPTargetNavigatorClusterNavigateTargetResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPTargetNavigatorClusterNavigateTargetResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::TargetNavigator::Commands::NavigateTargetResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject Data; - if (!dataResponse.data.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); - } - else - { - jobject DataInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); -} -CHIPMediaPlaybackClusterPlaybackResponseCallback::CHIPMediaPlaybackClusterPlaybackResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPMediaPlaybackClusterPlaybackResponseCallback::~CHIPMediaPlaybackClusterPlaybackResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPMediaPlaybackClusterPlaybackResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::MediaPlayback::Commands::PlaybackResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject Data; - if (!dataResponse.data.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); - } - else - { - jobject DataInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); -} -CHIPKeypadInputClusterSendKeyResponseCallback::CHIPKeypadInputClusterSendKeyResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPKeypadInputClusterSendKeyResponseCallback::~CHIPKeypadInputClusterSendKeyResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPKeypadInputClusterSendKeyResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::KeypadInput::Commands::SendKeyResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status); -} -CHIPContentLauncherClusterLauncherResponseCallback::CHIPContentLauncherClusterLauncherResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPContentLauncherClusterLauncherResponseCallback::~CHIPContentLauncherClusterLauncherResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPContentLauncherClusterLauncherResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ContentLauncher::Commands::LauncherResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject Data; - if (!dataResponse.data.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); - } - else - { - jobject DataInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); -} -CHIPApplicationLauncherClusterLauncherResponseCallback::CHIPApplicationLauncherClusterLauncherResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPApplicationLauncherClusterLauncherResponseCallback::~CHIPApplicationLauncherClusterLauncherResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPApplicationLauncherClusterLauncherResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ApplicationLauncher::Commands::LauncherResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject Data; - if (!dataResponse.data.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); - } - else - { - jobject DataInsideOptional; - jbyteArray DataInsideOptionalByteArray = env->NewByteArray(static_cast(dataResponse.data.Value().size())); - env->SetByteArrayRegion(DataInsideOptionalByteArray, 0, static_cast(dataResponse.data.Value().size()), - reinterpret_cast(dataResponse.data.Value().data())); - DataInsideOptional = DataInsideOptionalByteArray; - chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); -} -CHIPAccountLoginClusterGetSetupPINResponseCallback::CHIPAccountLoginClusterGetSetupPINResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPAccountLoginClusterGetSetupPINResponseCallback::~CHIPAccountLoginClusterGetSetupPINResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPAccountLoginClusterGetSetupPINResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::AccountLogin::Commands::GetSetupPINResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/String;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject SetupPIN; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.setupPIN, SetupPIN)); - - env->CallVoidMethod(javaCallbackRef, javaMethod, SetupPIN); -} -CHIPContentControlClusterResetPINResponseCallback::CHIPContentControlClusterResetPINResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPContentControlClusterResetPINResponseCallback::~CHIPContentControlClusterResetPINResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPContentControlClusterResetPINResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ContentControl::Commands::ResetPINResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/String;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject PINCode; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.PINCode, PINCode)); - - env->CallVoidMethod(javaCallbackRef, javaMethod, PINCode); -} -CHIPContentAppObserverClusterContentAppMessageResponseCallback::CHIPContentAppObserverClusterContentAppMessageResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPContentAppObserverClusterContentAppMessageResponseCallback::~CHIPContentAppObserverClusterContentAppMessageResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPContentAppObserverClusterContentAppMessageResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::ContentAppObserver::Commands::ContentAppMessageResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject Data; - if (!dataResponse.data.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); - } - else - { - jobject DataInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); - } - jobject EncodingHint; - if (!dataResponse.encodingHint.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, EncodingHint); - } - else - { - jobject EncodingHintInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.encodingHint.Value(), EncodingHintInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(EncodingHintInsideOptional, EncodingHint); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data, EncodingHint); -} -CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback:: -CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback::~ -CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback::CallbackFn( - void * context, - const chip::app::Clusters::ElectricalMeasurement::Commands::GetProfileInfoResponseCommand::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/ArrayList;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject profileCount; - std::string profileCountClassName = "java/lang/Integer"; - std::string profileCountCtorSignature = "(I)V"; - jint jniprofileCount = static_cast(dataResponse.profileCount); - chip::JniReferences::GetInstance().CreateBoxedObject(profileCountClassName.c_str(), profileCountCtorSignature.c_str(), - jniprofileCount, profileCount); - jobject profileIntervalPeriod; - std::string profileIntervalPeriodClassName = "java/lang/Integer"; - std::string profileIntervalPeriodCtorSignature = "(I)V"; - jint jniprofileIntervalPeriod = static_cast(dataResponse.profileIntervalPeriod); - chip::JniReferences::GetInstance().CreateBoxedObject(profileIntervalPeriodClassName.c_str(), - profileIntervalPeriodCtorSignature.c_str(), jniprofileIntervalPeriod, - profileIntervalPeriod); - jobject maxNumberOfIntervals; - std::string maxNumberOfIntervalsClassName = "java/lang/Integer"; - std::string maxNumberOfIntervalsCtorSignature = "(I)V"; - jint jnimaxNumberOfIntervals = static_cast(dataResponse.maxNumberOfIntervals); - chip::JniReferences::GetInstance().CreateBoxedObject(maxNumberOfIntervalsClassName.c_str(), - maxNumberOfIntervalsCtorSignature.c_str(), jnimaxNumberOfIntervals, - maxNumberOfIntervals); - jobject listOfAttributes; - chip::JniReferences::GetInstance().CreateArrayList(listOfAttributes); - - auto iter_listOfAttributes_0 = dataResponse.listOfAttributes.begin(); - while (iter_listOfAttributes_0.Next()) - { - auto & entry_0 = iter_listOfAttributes_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Integer"; - std::string newElement_0CtorSignature = "(I)V"; - jint jninewElement_0 = static_cast(entry_0); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), - jninewElement_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(listOfAttributes, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, profileCount, profileIntervalPeriod, maxNumberOfIntervals, listOfAttributes); -} -CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback:: -CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback::~ -CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback::CallbackFn( - void * context, - const chip::app::Clusters::ElectricalMeasurement::Commands::GetMeasurementProfileResponseCommand::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Long;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/ArrayList;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject startTime; - std::string startTimeClassName = "java/lang/Long"; - std::string startTimeCtorSignature = "(J)V"; - jlong jnistartTime = static_cast(dataResponse.startTime); - chip::JniReferences::GetInstance().CreateBoxedObject(startTimeClassName.c_str(), startTimeCtorSignature.c_str(), - jnistartTime, startTime); - jobject status; - std::string statusClassName = "java/lang/Integer"; - std::string statusCtorSignature = "(I)V"; - jint jnistatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(statusClassName.c_str(), statusCtorSignature.c_str(), jnistatus, - status); - jobject profileIntervalPeriod; - std::string profileIntervalPeriodClassName = "java/lang/Integer"; - std::string profileIntervalPeriodCtorSignature = "(I)V"; - jint jniprofileIntervalPeriod = static_cast(dataResponse.profileIntervalPeriod); - chip::JniReferences::GetInstance().CreateBoxedObject(profileIntervalPeriodClassName.c_str(), - profileIntervalPeriodCtorSignature.c_str(), jniprofileIntervalPeriod, - profileIntervalPeriod); - jobject numberOfIntervalsDelivered; - std::string numberOfIntervalsDeliveredClassName = "java/lang/Integer"; - std::string numberOfIntervalsDeliveredCtorSignature = "(I)V"; - jint jninumberOfIntervalsDelivered = static_cast(dataResponse.numberOfIntervalsDelivered); - chip::JniReferences::GetInstance().CreateBoxedObject(numberOfIntervalsDeliveredClassName.c_str(), - numberOfIntervalsDeliveredCtorSignature.c_str(), - jninumberOfIntervalsDelivered, numberOfIntervalsDelivered); - jobject attributeId; - std::string attributeIdClassName = "java/lang/Integer"; - std::string attributeIdCtorSignature = "(I)V"; - jint jniattributeId = static_cast(dataResponse.attributeId); - chip::JniReferences::GetInstance().CreateBoxedObject(attributeIdClassName.c_str(), attributeIdCtorSignature.c_str(), - jniattributeId, attributeId); - jobject intervals; - chip::JniReferences::GetInstance().CreateArrayList(intervals); - - auto iter_intervals_0 = dataResponse.intervals.begin(); - while (iter_intervals_0.Next()) - { - auto & entry_0 = iter_intervals_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Integer"; - std::string newElement_0CtorSignature = "(I)V"; - jint jninewElement_0 = static_cast(entry_0); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), - jninewElement_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(intervals, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, startTime, status, profileIntervalPeriod, numberOfIntervalsDelivered, - attributeId, intervals); -} -CHIPUnitTestingClusterTestSpecificResponseCallback::CHIPUnitTestingClusterTestSpecificResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestSpecificResponseCallback::~CHIPUnitTestingClusterTestSpecificResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestSpecificResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestSpecificResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject returnValue; - std::string returnValueClassName = "java/lang/Integer"; - std::string returnValueCtorSignature = "(I)V"; - jint jnireturnValue = static_cast(dataResponse.returnValue); - chip::JniReferences::GetInstance().CreateBoxedObject(returnValueClassName.c_str(), returnValueCtorSignature.c_str(), - jnireturnValue, returnValue); - - env->CallVoidMethod(javaCallbackRef, javaMethod, returnValue); -} -CHIPUnitTestingClusterTestAddArgumentsResponseCallback::CHIPUnitTestingClusterTestAddArgumentsResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestAddArgumentsResponseCallback::~CHIPUnitTestingClusterTestAddArgumentsResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestAddArgumentsResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestAddArgumentsResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject returnValue; - std::string returnValueClassName = "java/lang/Integer"; - std::string returnValueCtorSignature = "(I)V"; - jint jnireturnValue = static_cast(dataResponse.returnValue); - chip::JniReferences::GetInstance().CreateBoxedObject(returnValueClassName.c_str(), returnValueCtorSignature.c_str(), - jnireturnValue, returnValue); - - env->CallVoidMethod(javaCallbackRef, javaMethod, returnValue); -} -CHIPUnitTestingClusterTestSimpleArgumentResponseCallback::CHIPUnitTestingClusterTestSimpleArgumentResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestSimpleArgumentResponseCallback::~CHIPUnitTestingClusterTestSimpleArgumentResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestSimpleArgumentResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestSimpleArgumentResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject returnValue; - std::string returnValueClassName = "java/lang/Boolean"; - std::string returnValueCtorSignature = "(Z)V"; - jboolean jnireturnValue = static_cast(dataResponse.returnValue); - chip::JniReferences::GetInstance().CreateBoxedObject(returnValueClassName.c_str(), returnValueCtorSignature.c_str(), - jnireturnValue, returnValue); - - env->CallVoidMethod(javaCallbackRef, javaMethod, returnValue); -} -CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback::CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback::~CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestStructArrayArgumentResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/util/ArrayList;Ljava/util/ArrayList;Ljava/util/ArrayList;Ljava/util/" - "ArrayList;Ljava/lang/Integer;Ljava/lang/Boolean;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject arg1; - chip::JniReferences::GetInstance().CreateArrayList(arg1); - - auto iter_arg1_0 = dataResponse.arg1.begin(); - while (iter_arg1_0.Next()) - { - auto & entry_0 = iter_arg1_0.GetValue(); - jobject newElement_0; - jobject newElement_0_a; - std::string newElement_0_aClassName = "java/lang/Integer"; - std::string newElement_0_aCtorSignature = "(I)V"; - jint jninewElement_0_a = static_cast(entry_0.a); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_aClassName.c_str(), newElement_0_aCtorSignature.c_str(), jninewElement_0_a, newElement_0_a); - jobject newElement_0_b; - std::string newElement_0_bClassName = "java/lang/Boolean"; - std::string newElement_0_bCtorSignature = "(Z)V"; - jboolean jninewElement_0_b = static_cast(entry_0.b); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_bClassName.c_str(), newElement_0_bCtorSignature.c_str(), jninewElement_0_b, newElement_0_b); - jobject newElement_0_c; - jobject newElement_0_c_a; - std::string newElement_0_c_aClassName = "java/lang/Integer"; - std::string newElement_0_c_aCtorSignature = "(I)V"; - jint jninewElement_0_c_a = static_cast(entry_0.c.a); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_c_aClassName.c_str(), newElement_0_c_aCtorSignature.c_str(), jninewElement_0_c_a, newElement_0_c_a); - jobject newElement_0_c_b; - std::string newElement_0_c_bClassName = "java/lang/Boolean"; - std::string newElement_0_c_bCtorSignature = "(Z)V"; - jboolean jninewElement_0_c_b = static_cast(entry_0.c.b); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_c_bClassName.c_str(), newElement_0_c_bCtorSignature.c_str(), jninewElement_0_c_b, newElement_0_c_b); - jobject newElement_0_c_c; - std::string newElement_0_c_cClassName = "java/lang/Integer"; - std::string newElement_0_c_cCtorSignature = "(I)V"; - jint jninewElement_0_c_c = static_cast(entry_0.c.c); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_c_cClassName.c_str(), newElement_0_c_cCtorSignature.c_str(), jninewElement_0_c_c, newElement_0_c_c); - jobject newElement_0_c_d; - jbyteArray newElement_0_c_dByteArray = env->NewByteArray(static_cast(entry_0.c.d.size())); - env->SetByteArrayRegion(newElement_0_c_dByteArray, 0, static_cast(entry_0.c.d.size()), - reinterpret_cast(entry_0.c.d.data())); - newElement_0_c_d = newElement_0_c_dByteArray; - jobject newElement_0_c_e; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.c.e, newElement_0_c_e)); - jobject newElement_0_c_f; - std::string newElement_0_c_fClassName = "java/lang/Integer"; - std::string newElement_0_c_fCtorSignature = "(I)V"; - jint jninewElement_0_c_f = static_cast(entry_0.c.f.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_c_fClassName.c_str(), newElement_0_c_fCtorSignature.c_str(), jninewElement_0_c_f, newElement_0_c_f); - jobject newElement_0_c_g; - std::string newElement_0_c_gClassName = "java/lang/Float"; - std::string newElement_0_c_gCtorSignature = "(F)V"; - jfloat jninewElement_0_c_g = static_cast(entry_0.c.g); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_c_gClassName.c_str(), newElement_0_c_gCtorSignature.c_str(), jninewElement_0_c_g, newElement_0_c_g); - jobject newElement_0_c_h; - std::string newElement_0_c_hClassName = "java/lang/Double"; - std::string newElement_0_c_hCtorSignature = "(D)V"; - jdouble jninewElement_0_c_h = static_cast(entry_0.c.h); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_c_hClassName.c_str(), newElement_0_c_hCtorSignature.c_str(), jninewElement_0_c_h, newElement_0_c_h); - - jclass simpleStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_2); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); - return; - } - - jmethodID simpleStructStructCtor_2; - err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_2, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" - "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", - &simpleStructStructCtor_2); - if (err != CHIP_NO_ERROR || simpleStructStructCtor_2 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); - return; - } - - newElement_0_c = env->NewObject(simpleStructStructClass_2, simpleStructStructCtor_2, newElement_0_c_a, newElement_0_c_b, - newElement_0_c_c, newElement_0_c_d, newElement_0_c_e, newElement_0_c_f, newElement_0_c_g, - newElement_0_c_h); - jobject newElement_0_d; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_d); - - auto iter_newElement_0_d_2 = entry_0.d.begin(); - while (iter_newElement_0_d_2.Next()) - { - auto & entry_2 = iter_newElement_0_d_2.GetValue(); - jobject newElement_2; - jobject newElement_2_a; - std::string newElement_2_aClassName = "java/lang/Integer"; - std::string newElement_2_aCtorSignature = "(I)V"; - jint jninewElement_2_a = static_cast(entry_2.a); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_aClassName.c_str(), newElement_2_aCtorSignature.c_str(), jninewElement_2_a, newElement_2_a); - jobject newElement_2_b; - std::string newElement_2_bClassName = "java/lang/Boolean"; - std::string newElement_2_bCtorSignature = "(Z)V"; - jboolean jninewElement_2_b = static_cast(entry_2.b); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_bClassName.c_str(), newElement_2_bCtorSignature.c_str(), jninewElement_2_b, newElement_2_b); - jobject newElement_2_c; - std::string newElement_2_cClassName = "java/lang/Integer"; - std::string newElement_2_cCtorSignature = "(I)V"; - jint jninewElement_2_c = static_cast(entry_2.c); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_cClassName.c_str(), newElement_2_cCtorSignature.c_str(), jninewElement_2_c, newElement_2_c); - jobject newElement_2_d; - jbyteArray newElement_2_dByteArray = env->NewByteArray(static_cast(entry_2.d.size())); - env->SetByteArrayRegion(newElement_2_dByteArray, 0, static_cast(entry_2.d.size()), - reinterpret_cast(entry_2.d.data())); - newElement_2_d = newElement_2_dByteArray; - jobject newElement_2_e; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_2.e, newElement_2_e)); - jobject newElement_2_f; - std::string newElement_2_fClassName = "java/lang/Integer"; - std::string newElement_2_fCtorSignature = "(I)V"; - jint jninewElement_2_f = static_cast(entry_2.f.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_fClassName.c_str(), newElement_2_fCtorSignature.c_str(), jninewElement_2_f, newElement_2_f); - jobject newElement_2_g; - std::string newElement_2_gClassName = "java/lang/Float"; - std::string newElement_2_gCtorSignature = "(F)V"; - jfloat jninewElement_2_g = static_cast(entry_2.g); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_gClassName.c_str(), newElement_2_gCtorSignature.c_str(), jninewElement_2_g, newElement_2_g); - jobject newElement_2_h; - std::string newElement_2_hClassName = "java/lang/Double"; - std::string newElement_2_hCtorSignature = "(D)V"; - jdouble jninewElement_2_h = static_cast(entry_2.h); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_hClassName.c_str(), newElement_2_hCtorSignature.c_str(), jninewElement_2_h, newElement_2_h); - - jclass simpleStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_3); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); - return; - } - - jmethodID simpleStructStructCtor_3; - err = chip::JniReferences::GetInstance().FindMethod( - env, simpleStructStructClass_3, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/lang/String;Ljava/lang/Integer;Ljava/lang/" - "Float;Ljava/lang/Double;)V", - &simpleStructStructCtor_3); - if (err != CHIP_NO_ERROR || simpleStructStructCtor_3 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); - return; - } - - newElement_2 = - env->NewObject(simpleStructStructClass_3, simpleStructStructCtor_3, newElement_2_a, newElement_2_b, newElement_2_c, - newElement_2_d, newElement_2_e, newElement_2_f, newElement_2_g, newElement_2_h); - chip::JniReferences::GetInstance().AddToList(newElement_0_d, newElement_2); - } - jobject newElement_0_e; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_e); - - auto iter_newElement_0_e_2 = entry_0.e.begin(); - while (iter_newElement_0_e_2.Next()) - { - auto & entry_2 = iter_newElement_0_e_2.GetValue(); - jobject newElement_2; - std::string newElement_2ClassName = "java/lang/Long"; - std::string newElement_2CtorSignature = "(J)V"; - jlong jninewElement_2 = static_cast(entry_2); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2ClassName.c_str(), newElement_2CtorSignature.c_str(), jninewElement_2, newElement_2); - chip::JniReferences::GetInstance().AddToList(newElement_0_e, newElement_2); - } - jobject newElement_0_f; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_f); - - auto iter_newElement_0_f_2 = entry_0.f.begin(); - while (iter_newElement_0_f_2.Next()) - { - auto & entry_2 = iter_newElement_0_f_2.GetValue(); - jobject newElement_2; - jbyteArray newElement_2ByteArray = env->NewByteArray(static_cast(entry_2.size())); - env->SetByteArrayRegion(newElement_2ByteArray, 0, static_cast(entry_2.size()), - reinterpret_cast(entry_2.data())); - newElement_2 = newElement_2ByteArray; - chip::JniReferences::GetInstance().AddToList(newElement_0_f, newElement_2); - } - jobject newElement_0_g; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_g); - - auto iter_newElement_0_g_2 = entry_0.g.begin(); - while (iter_newElement_0_g_2.Next()) - { - auto & entry_2 = iter_newElement_0_g_2.GetValue(); - jobject newElement_2; - std::string newElement_2ClassName = "java/lang/Integer"; - std::string newElement_2CtorSignature = "(I)V"; - jint jninewElement_2 = static_cast(entry_2); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2ClassName.c_str(), newElement_2CtorSignature.c_str(), jninewElement_2, newElement_2); - chip::JniReferences::GetInstance().AddToList(newElement_0_g, newElement_2); - } - - jclass nestedStructListStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$UnitTestingClusterNestedStructList", nestedStructListStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterNestedStructList"); - return; - } - - jmethodID nestedStructListStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod( - env, nestedStructListStructClass_1, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Lchip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct;Ljava/util/" - "ArrayList;Ljava/util/ArrayList;Ljava/util/ArrayList;Ljava/util/ArrayList;)V", - &nestedStructListStructCtor_1); - if (err != CHIP_NO_ERROR || nestedStructListStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterNestedStructList constructor"); - return; - } - - newElement_0 = env->NewObject(nestedStructListStructClass_1, nestedStructListStructCtor_1, newElement_0_a, newElement_0_b, - newElement_0_c, newElement_0_d, newElement_0_e, newElement_0_f, newElement_0_g); - chip::JniReferences::GetInstance().AddToList(arg1, newElement_0); - } - jobject arg2; - chip::JniReferences::GetInstance().CreateArrayList(arg2); - - auto iter_arg2_0 = dataResponse.arg2.begin(); - while (iter_arg2_0.Next()) - { - auto & entry_0 = iter_arg2_0.GetValue(); - jobject newElement_0; - jobject newElement_0_a; - std::string newElement_0_aClassName = "java/lang/Integer"; - std::string newElement_0_aCtorSignature = "(I)V"; - jint jninewElement_0_a = static_cast(entry_0.a); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_aClassName.c_str(), newElement_0_aCtorSignature.c_str(), jninewElement_0_a, newElement_0_a); - jobject newElement_0_b; - std::string newElement_0_bClassName = "java/lang/Boolean"; - std::string newElement_0_bCtorSignature = "(Z)V"; - jboolean jninewElement_0_b = static_cast(entry_0.b); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_bClassName.c_str(), newElement_0_bCtorSignature.c_str(), jninewElement_0_b, newElement_0_b); - jobject newElement_0_c; - std::string newElement_0_cClassName = "java/lang/Integer"; - std::string newElement_0_cCtorSignature = "(I)V"; - jint jninewElement_0_c = static_cast(entry_0.c); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_cClassName.c_str(), newElement_0_cCtorSignature.c_str(), jninewElement_0_c, newElement_0_c); - jobject newElement_0_d; - jbyteArray newElement_0_dByteArray = env->NewByteArray(static_cast(entry_0.d.size())); - env->SetByteArrayRegion(newElement_0_dByteArray, 0, static_cast(entry_0.d.size()), - reinterpret_cast(entry_0.d.data())); - newElement_0_d = newElement_0_dByteArray; - jobject newElement_0_e; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.e, newElement_0_e)); - jobject newElement_0_f; - std::string newElement_0_fClassName = "java/lang/Integer"; - std::string newElement_0_fCtorSignature = "(I)V"; - jint jninewElement_0_f = static_cast(entry_0.f.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_fClassName.c_str(), newElement_0_fCtorSignature.c_str(), jninewElement_0_f, newElement_0_f); - jobject newElement_0_g; - std::string newElement_0_gClassName = "java/lang/Float"; - std::string newElement_0_gCtorSignature = "(F)V"; - jfloat jninewElement_0_g = static_cast(entry_0.g); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_gClassName.c_str(), newElement_0_gCtorSignature.c_str(), jninewElement_0_g, newElement_0_g); - jobject newElement_0_h; - std::string newElement_0_hClassName = "java/lang/Double"; - std::string newElement_0_hCtorSignature = "(D)V"; - jdouble jninewElement_0_h = static_cast(entry_0.h); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_hClassName.c_str(), newElement_0_hCtorSignature.c_str(), jninewElement_0_h, newElement_0_h); - - jclass simpleStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); - return; - } - - jmethodID simpleStructStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_1, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" - "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", - &simpleStructStructCtor_1); - if (err != CHIP_NO_ERROR || simpleStructStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); - return; - } - - newElement_0 = - env->NewObject(simpleStructStructClass_1, simpleStructStructCtor_1, newElement_0_a, newElement_0_b, newElement_0_c, - newElement_0_d, newElement_0_e, newElement_0_f, newElement_0_g, newElement_0_h); - chip::JniReferences::GetInstance().AddToList(arg2, newElement_0); - } - jobject arg3; - chip::JniReferences::GetInstance().CreateArrayList(arg3); - - auto iter_arg3_0 = dataResponse.arg3.begin(); - while (iter_arg3_0.Next()) - { - auto & entry_0 = iter_arg3_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Integer"; - std::string newElement_0CtorSignature = "(I)V"; - jint jninewElement_0 = static_cast(entry_0); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), - jninewElement_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(arg3, newElement_0); - } - jobject arg4; - chip::JniReferences::GetInstance().CreateArrayList(arg4); - - auto iter_arg4_0 = dataResponse.arg4.begin(); - while (iter_arg4_0.Next()) - { - auto & entry_0 = iter_arg4_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Boolean"; - std::string newElement_0CtorSignature = "(Z)V"; - jboolean jninewElement_0 = static_cast(entry_0); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(arg4, newElement_0); - } - jobject arg5; - std::string arg5ClassName = "java/lang/Integer"; - std::string arg5CtorSignature = "(I)V"; - jint jniarg5 = static_cast(dataResponse.arg5); - chip::JniReferences::GetInstance().CreateBoxedObject(arg5ClassName.c_str(), arg5CtorSignature.c_str(), jniarg5, arg5); - jobject arg6; - std::string arg6ClassName = "java/lang/Boolean"; - std::string arg6CtorSignature = "(Z)V"; - jboolean jniarg6 = static_cast(dataResponse.arg6); - chip::JniReferences::GetInstance().CreateBoxedObject(arg6ClassName.c_str(), arg6CtorSignature.c_str(), jniarg6, arg6); - - env->CallVoidMethod(javaCallbackRef, javaMethod, arg1, arg2, arg3, arg4, arg5, arg6); -} -CHIPUnitTestingClusterTestListInt8UReverseResponseCallback::CHIPUnitTestingClusterTestListInt8UReverseResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestListInt8UReverseResponseCallback::~CHIPUnitTestingClusterTestListInt8UReverseResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestListInt8UReverseResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestListInt8UReverseResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/ArrayList;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject arg1; - chip::JniReferences::GetInstance().CreateArrayList(arg1); - - auto iter_arg1_0 = dataResponse.arg1.begin(); - while (iter_arg1_0.Next()) - { - auto & entry_0 = iter_arg1_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Integer"; - std::string newElement_0CtorSignature = "(I)V"; - jint jninewElement_0 = static_cast(entry_0); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), - jninewElement_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(arg1, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, arg1); -} -CHIPUnitTestingClusterTestEnumsResponseCallback::CHIPUnitTestingClusterTestEnumsResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestEnumsResponseCallback::~CHIPUnitTestingClusterTestEnumsResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestEnumsResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestEnumsResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject arg1; - std::string arg1ClassName = "java/lang/Integer"; - std::string arg1CtorSignature = "(I)V"; - jint jniarg1 = static_cast(dataResponse.arg1); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1ClassName.c_str(), arg1CtorSignature.c_str(), jniarg1, arg1); - jobject arg2; - std::string arg2ClassName = "java/lang/Integer"; - std::string arg2CtorSignature = "(I)V"; - jint jniarg2 = static_cast(dataResponse.arg2); - chip::JniReferences::GetInstance().CreateBoxedObject(arg2ClassName.c_str(), arg2CtorSignature.c_str(), jniarg2, arg2); - - env->CallVoidMethod(javaCallbackRef, javaMethod, arg1, arg2); -} -CHIPUnitTestingClusterTestNullableOptionalResponseCallback::CHIPUnitTestingClusterTestNullableOptionalResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestNullableOptionalResponseCallback::~CHIPUnitTestingClusterTestNullableOptionalResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestNullableOptionalResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestNullableOptionalResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject wasPresent; - std::string wasPresentClassName = "java/lang/Boolean"; - std::string wasPresentCtorSignature = "(Z)V"; - jboolean jniwasPresent = static_cast(dataResponse.wasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject(wasPresentClassName.c_str(), wasPresentCtorSignature.c_str(), - jniwasPresent, wasPresent); - jobject wasNull; - if (!dataResponse.wasNull.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, wasNull); - } - else - { - jobject wasNullInsideOptional; - std::string wasNullInsideOptionalClassName = "java/lang/Boolean"; - std::string wasNullInsideOptionalCtorSignature = "(Z)V"; - jboolean jniwasNullInsideOptional = static_cast(dataResponse.wasNull.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(wasNullInsideOptionalClassName.c_str(), - wasNullInsideOptionalCtorSignature.c_str(), - jniwasNullInsideOptional, wasNullInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(wasNullInsideOptional, wasNull); - } - jobject value; - if (!dataResponse.value.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, value); - } - else - { - jobject valueInsideOptional; - std::string valueInsideOptionalClassName = "java/lang/Integer"; - std::string valueInsideOptionalCtorSignature = "(I)V"; - jint jnivalueInsideOptional = static_cast(dataResponse.value.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(valueInsideOptionalClassName.c_str(), - valueInsideOptionalCtorSignature.c_str(), jnivalueInsideOptional, - valueInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(valueInsideOptional, value); - } - jobject originalValue; - if (!dataResponse.originalValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, originalValue); - } - else - { - jobject originalValueInsideOptional; - if (dataResponse.originalValue.Value().IsNull()) - { - originalValueInsideOptional = nullptr; - } - else - { - std::string originalValueInsideOptionalClassName = "java/lang/Integer"; - std::string originalValueInsideOptionalCtorSignature = "(I)V"; - jint jnioriginalValueInsideOptional = static_cast(dataResponse.originalValue.Value().Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(originalValueInsideOptionalClassName.c_str(), - originalValueInsideOptionalCtorSignature.c_str(), - jnioriginalValueInsideOptional, originalValueInsideOptional); - } - chip::JniReferences::GetInstance().CreateOptional(originalValueInsideOptional, originalValue); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, wasPresent, wasNull, value, originalValue); -} -CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback:: -CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback::~ -CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::UnitTesting::Commands::TestComplexNullableOptionalResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/" - "Optional;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/" - "Boolean;Ljava/util/Optional;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/" - "Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/" - "Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject NullableIntWasNull; - std::string NullableIntWasNullClassName = "java/lang/Boolean"; - std::string NullableIntWasNullCtorSignature = "(Z)V"; - jboolean jniNullableIntWasNull = static_cast(dataResponse.nullableIntWasNull); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableIntWasNullClassName.c_str(), NullableIntWasNullCtorSignature.c_str(), jniNullableIntWasNull, NullableIntWasNull); - jobject NullableIntValue; - if (!dataResponse.nullableIntValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableIntValue); - } - else - { - jobject NullableIntValueInsideOptional; - std::string NullableIntValueInsideOptionalClassName = "java/lang/Integer"; - std::string NullableIntValueInsideOptionalCtorSignature = "(I)V"; - jint jniNullableIntValueInsideOptional = static_cast(dataResponse.nullableIntValue.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableIntValueInsideOptionalClassName.c_str(), NullableIntValueInsideOptionalCtorSignature.c_str(), - jniNullableIntValueInsideOptional, NullableIntValueInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(NullableIntValueInsideOptional, NullableIntValue); - } - jobject OptionalIntWasPresent; - std::string OptionalIntWasPresentClassName = "java/lang/Boolean"; - std::string OptionalIntWasPresentCtorSignature = "(Z)V"; - jboolean jniOptionalIntWasPresent = static_cast(dataResponse.optionalIntWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject(OptionalIntWasPresentClassName.c_str(), - OptionalIntWasPresentCtorSignature.c_str(), - jniOptionalIntWasPresent, OptionalIntWasPresent); - jobject OptionalIntValue; - if (!dataResponse.optionalIntValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, OptionalIntValue); - } - else - { - jobject OptionalIntValueInsideOptional; - std::string OptionalIntValueInsideOptionalClassName = "java/lang/Integer"; - std::string OptionalIntValueInsideOptionalCtorSignature = "(I)V"; - jint jniOptionalIntValueInsideOptional = static_cast(dataResponse.optionalIntValue.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - OptionalIntValueInsideOptionalClassName.c_str(), OptionalIntValueInsideOptionalCtorSignature.c_str(), - jniOptionalIntValueInsideOptional, OptionalIntValueInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(OptionalIntValueInsideOptional, OptionalIntValue); - } - jobject NullableOptionalIntWasPresent; - std::string NullableOptionalIntWasPresentClassName = "java/lang/Boolean"; - std::string NullableOptionalIntWasPresentCtorSignature = "(Z)V"; - jboolean jniNullableOptionalIntWasPresent = static_cast(dataResponse.nullableOptionalIntWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject(NullableOptionalIntWasPresentClassName.c_str(), - NullableOptionalIntWasPresentCtorSignature.c_str(), - jniNullableOptionalIntWasPresent, NullableOptionalIntWasPresent); - jobject NullableOptionalIntWasNull; - if (!dataResponse.nullableOptionalIntWasNull.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalIntWasNull); - } - else - { - jobject NullableOptionalIntWasNullInsideOptional; - std::string NullableOptionalIntWasNullInsideOptionalClassName = "java/lang/Boolean"; - std::string NullableOptionalIntWasNullInsideOptionalCtorSignature = "(Z)V"; - jboolean jniNullableOptionalIntWasNullInsideOptional = - static_cast(dataResponse.nullableOptionalIntWasNull.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalIntWasNullInsideOptionalClassName.c_str(), - NullableOptionalIntWasNullInsideOptionalCtorSignature.c_str(), jniNullableOptionalIntWasNullInsideOptional, - NullableOptionalIntWasNullInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalIntWasNullInsideOptional, NullableOptionalIntWasNull); - } - jobject NullableOptionalIntValue; - if (!dataResponse.nullableOptionalIntValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalIntValue); - } - else - { - jobject NullableOptionalIntValueInsideOptional; - std::string NullableOptionalIntValueInsideOptionalClassName = "java/lang/Integer"; - std::string NullableOptionalIntValueInsideOptionalCtorSignature = "(I)V"; - jint jniNullableOptionalIntValueInsideOptional = static_cast(dataResponse.nullableOptionalIntValue.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalIntValueInsideOptionalClassName.c_str(), NullableOptionalIntValueInsideOptionalCtorSignature.c_str(), - jniNullableOptionalIntValueInsideOptional, NullableOptionalIntValueInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalIntValueInsideOptional, NullableOptionalIntValue); - } - jobject NullableStringWasNull; - std::string NullableStringWasNullClassName = "java/lang/Boolean"; - std::string NullableStringWasNullCtorSignature = "(Z)V"; - jboolean jniNullableStringWasNull = static_cast(dataResponse.nullableStringWasNull); - chip::JniReferences::GetInstance().CreateBoxedObject(NullableStringWasNullClassName.c_str(), - NullableStringWasNullCtorSignature.c_str(), - jniNullableStringWasNull, NullableStringWasNull); - jobject NullableStringValue; - if (!dataResponse.nullableStringValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableStringValue); - } - else - { - jobject NullableStringValueInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableStringValue.Value(), - NullableStringValueInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(NullableStringValueInsideOptional, NullableStringValue); - } - jobject OptionalStringWasPresent; - std::string OptionalStringWasPresentClassName = "java/lang/Boolean"; - std::string OptionalStringWasPresentCtorSignature = "(Z)V"; - jboolean jniOptionalStringWasPresent = static_cast(dataResponse.optionalStringWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject(OptionalStringWasPresentClassName.c_str(), - OptionalStringWasPresentCtorSignature.c_str(), - jniOptionalStringWasPresent, OptionalStringWasPresent); - jobject OptionalStringValue; - if (!dataResponse.optionalStringValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, OptionalStringValue); - } - else - { - jobject OptionalStringValueInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.optionalStringValue.Value(), - OptionalStringValueInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(OptionalStringValueInsideOptional, OptionalStringValue); - } - jobject NullableOptionalStringWasPresent; - std::string NullableOptionalStringWasPresentClassName = "java/lang/Boolean"; - std::string NullableOptionalStringWasPresentCtorSignature = "(Z)V"; - jboolean jniNullableOptionalStringWasPresent = static_cast(dataResponse.nullableOptionalStringWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalStringWasPresentClassName.c_str(), NullableOptionalStringWasPresentCtorSignature.c_str(), - jniNullableOptionalStringWasPresent, NullableOptionalStringWasPresent); - jobject NullableOptionalStringWasNull; - if (!dataResponse.nullableOptionalStringWasNull.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalStringWasNull); - } - else - { - jobject NullableOptionalStringWasNullInsideOptional; - std::string NullableOptionalStringWasNullInsideOptionalClassName = "java/lang/Boolean"; - std::string NullableOptionalStringWasNullInsideOptionalCtorSignature = "(Z)V"; - jboolean jniNullableOptionalStringWasNullInsideOptional = - static_cast(dataResponse.nullableOptionalStringWasNull.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalStringWasNullInsideOptionalClassName.c_str(), - NullableOptionalStringWasNullInsideOptionalCtorSignature.c_str(), jniNullableOptionalStringWasNullInsideOptional, - NullableOptionalStringWasNullInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalStringWasNullInsideOptional, - NullableOptionalStringWasNull); - } - jobject NullableOptionalStringValue; - if (!dataResponse.nullableOptionalStringValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalStringValue); - } - else - { - jobject NullableOptionalStringValueInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableOptionalStringValue.Value(), - NullableOptionalStringValueInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalStringValueInsideOptional, NullableOptionalStringValue); - } - jobject NullableStructWasNull; - std::string NullableStructWasNullClassName = "java/lang/Boolean"; - std::string NullableStructWasNullCtorSignature = "(Z)V"; - jboolean jniNullableStructWasNull = static_cast(dataResponse.nullableStructWasNull); - chip::JniReferences::GetInstance().CreateBoxedObject(NullableStructWasNullClassName.c_str(), - NullableStructWasNullCtorSignature.c_str(), - jniNullableStructWasNull, NullableStructWasNull); - jobject NullableStructValue; - if (!dataResponse.nullableStructValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableStructValue); - } - else - { - jobject NullableStructValueInsideOptional; - jobject NullableStructValueInsideOptional_a; - std::string NullableStructValueInsideOptional_aClassName = "java/lang/Integer"; - std::string NullableStructValueInsideOptional_aCtorSignature = "(I)V"; - jint jniNullableStructValueInsideOptional_a = static_cast(dataResponse.nullableStructValue.Value().a); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableStructValueInsideOptional_aClassName.c_str(), NullableStructValueInsideOptional_aCtorSignature.c_str(), - jniNullableStructValueInsideOptional_a, NullableStructValueInsideOptional_a); - jobject NullableStructValueInsideOptional_b; - std::string NullableStructValueInsideOptional_bClassName = "java/lang/Boolean"; - std::string NullableStructValueInsideOptional_bCtorSignature = "(Z)V"; - jboolean jniNullableStructValueInsideOptional_b = static_cast(dataResponse.nullableStructValue.Value().b); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableStructValueInsideOptional_bClassName.c_str(), NullableStructValueInsideOptional_bCtorSignature.c_str(), - jniNullableStructValueInsideOptional_b, NullableStructValueInsideOptional_b); - jobject NullableStructValueInsideOptional_c; - std::string NullableStructValueInsideOptional_cClassName = "java/lang/Integer"; - std::string NullableStructValueInsideOptional_cCtorSignature = "(I)V"; - jint jniNullableStructValueInsideOptional_c = static_cast(dataResponse.nullableStructValue.Value().c); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableStructValueInsideOptional_cClassName.c_str(), NullableStructValueInsideOptional_cCtorSignature.c_str(), - jniNullableStructValueInsideOptional_c, NullableStructValueInsideOptional_c); - jobject NullableStructValueInsideOptional_d; - jbyteArray NullableStructValueInsideOptional_dByteArray = - env->NewByteArray(static_cast(dataResponse.nullableStructValue.Value().d.size())); - env->SetByteArrayRegion(NullableStructValueInsideOptional_dByteArray, 0, - static_cast(dataResponse.nullableStructValue.Value().d.size()), - reinterpret_cast(dataResponse.nullableStructValue.Value().d.data())); - NullableStructValueInsideOptional_d = NullableStructValueInsideOptional_dByteArray; - jobject NullableStructValueInsideOptional_e; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableStructValue.Value().e, - NullableStructValueInsideOptional_e)); - jobject NullableStructValueInsideOptional_f; - std::string NullableStructValueInsideOptional_fClassName = "java/lang/Integer"; - std::string NullableStructValueInsideOptional_fCtorSignature = "(I)V"; - jint jniNullableStructValueInsideOptional_f = static_cast(dataResponse.nullableStructValue.Value().f.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableStructValueInsideOptional_fClassName.c_str(), NullableStructValueInsideOptional_fCtorSignature.c_str(), - jniNullableStructValueInsideOptional_f, NullableStructValueInsideOptional_f); - jobject NullableStructValueInsideOptional_g; - std::string NullableStructValueInsideOptional_gClassName = "java/lang/Float"; - std::string NullableStructValueInsideOptional_gCtorSignature = "(F)V"; - jfloat jniNullableStructValueInsideOptional_g = static_cast(dataResponse.nullableStructValue.Value().g); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableStructValueInsideOptional_gClassName.c_str(), NullableStructValueInsideOptional_gCtorSignature.c_str(), - jniNullableStructValueInsideOptional_g, NullableStructValueInsideOptional_g); - jobject NullableStructValueInsideOptional_h; - std::string NullableStructValueInsideOptional_hClassName = "java/lang/Double"; - std::string NullableStructValueInsideOptional_hCtorSignature = "(D)V"; - jdouble jniNullableStructValueInsideOptional_h = static_cast(dataResponse.nullableStructValue.Value().h); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableStructValueInsideOptional_hClassName.c_str(), NullableStructValueInsideOptional_hCtorSignature.c_str(), - jniNullableStructValueInsideOptional_h, NullableStructValueInsideOptional_h); - - jclass simpleStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); - return; - } - - jmethodID simpleStructStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_1, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" - "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", - &simpleStructStructCtor_1); - if (err != CHIP_NO_ERROR || simpleStructStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); - return; - } - - NullableStructValueInsideOptional = env->NewObject( - simpleStructStructClass_1, simpleStructStructCtor_1, NullableStructValueInsideOptional_a, - NullableStructValueInsideOptional_b, NullableStructValueInsideOptional_c, NullableStructValueInsideOptional_d, - NullableStructValueInsideOptional_e, NullableStructValueInsideOptional_f, NullableStructValueInsideOptional_g, - NullableStructValueInsideOptional_h); - chip::JniReferences::GetInstance().CreateOptional(NullableStructValueInsideOptional, NullableStructValue); - } - jobject OptionalStructWasPresent; - std::string OptionalStructWasPresentClassName = "java/lang/Boolean"; - std::string OptionalStructWasPresentCtorSignature = "(Z)V"; - jboolean jniOptionalStructWasPresent = static_cast(dataResponse.optionalStructWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject(OptionalStructWasPresentClassName.c_str(), - OptionalStructWasPresentCtorSignature.c_str(), - jniOptionalStructWasPresent, OptionalStructWasPresent); - jobject OptionalStructValue; - if (!dataResponse.optionalStructValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, OptionalStructValue); - } - else - { - jobject OptionalStructValueInsideOptional; - jobject OptionalStructValueInsideOptional_a; - std::string OptionalStructValueInsideOptional_aClassName = "java/lang/Integer"; - std::string OptionalStructValueInsideOptional_aCtorSignature = "(I)V"; - jint jniOptionalStructValueInsideOptional_a = static_cast(dataResponse.optionalStructValue.Value().a); - chip::JniReferences::GetInstance().CreateBoxedObject( - OptionalStructValueInsideOptional_aClassName.c_str(), OptionalStructValueInsideOptional_aCtorSignature.c_str(), - jniOptionalStructValueInsideOptional_a, OptionalStructValueInsideOptional_a); - jobject OptionalStructValueInsideOptional_b; - std::string OptionalStructValueInsideOptional_bClassName = "java/lang/Boolean"; - std::string OptionalStructValueInsideOptional_bCtorSignature = "(Z)V"; - jboolean jniOptionalStructValueInsideOptional_b = static_cast(dataResponse.optionalStructValue.Value().b); - chip::JniReferences::GetInstance().CreateBoxedObject( - OptionalStructValueInsideOptional_bClassName.c_str(), OptionalStructValueInsideOptional_bCtorSignature.c_str(), - jniOptionalStructValueInsideOptional_b, OptionalStructValueInsideOptional_b); - jobject OptionalStructValueInsideOptional_c; - std::string OptionalStructValueInsideOptional_cClassName = "java/lang/Integer"; - std::string OptionalStructValueInsideOptional_cCtorSignature = "(I)V"; - jint jniOptionalStructValueInsideOptional_c = static_cast(dataResponse.optionalStructValue.Value().c); - chip::JniReferences::GetInstance().CreateBoxedObject( - OptionalStructValueInsideOptional_cClassName.c_str(), OptionalStructValueInsideOptional_cCtorSignature.c_str(), - jniOptionalStructValueInsideOptional_c, OptionalStructValueInsideOptional_c); - jobject OptionalStructValueInsideOptional_d; - jbyteArray OptionalStructValueInsideOptional_dByteArray = - env->NewByteArray(static_cast(dataResponse.optionalStructValue.Value().d.size())); - env->SetByteArrayRegion(OptionalStructValueInsideOptional_dByteArray, 0, - static_cast(dataResponse.optionalStructValue.Value().d.size()), - reinterpret_cast(dataResponse.optionalStructValue.Value().d.data())); - OptionalStructValueInsideOptional_d = OptionalStructValueInsideOptional_dByteArray; - jobject OptionalStructValueInsideOptional_e; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.optionalStructValue.Value().e, - OptionalStructValueInsideOptional_e)); - jobject OptionalStructValueInsideOptional_f; - std::string OptionalStructValueInsideOptional_fClassName = "java/lang/Integer"; - std::string OptionalStructValueInsideOptional_fCtorSignature = "(I)V"; - jint jniOptionalStructValueInsideOptional_f = static_cast(dataResponse.optionalStructValue.Value().f.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - OptionalStructValueInsideOptional_fClassName.c_str(), OptionalStructValueInsideOptional_fCtorSignature.c_str(), - jniOptionalStructValueInsideOptional_f, OptionalStructValueInsideOptional_f); - jobject OptionalStructValueInsideOptional_g; - std::string OptionalStructValueInsideOptional_gClassName = "java/lang/Float"; - std::string OptionalStructValueInsideOptional_gCtorSignature = "(F)V"; - jfloat jniOptionalStructValueInsideOptional_g = static_cast(dataResponse.optionalStructValue.Value().g); - chip::JniReferences::GetInstance().CreateBoxedObject( - OptionalStructValueInsideOptional_gClassName.c_str(), OptionalStructValueInsideOptional_gCtorSignature.c_str(), - jniOptionalStructValueInsideOptional_g, OptionalStructValueInsideOptional_g); - jobject OptionalStructValueInsideOptional_h; - std::string OptionalStructValueInsideOptional_hClassName = "java/lang/Double"; - std::string OptionalStructValueInsideOptional_hCtorSignature = "(D)V"; - jdouble jniOptionalStructValueInsideOptional_h = static_cast(dataResponse.optionalStructValue.Value().h); - chip::JniReferences::GetInstance().CreateBoxedObject( - OptionalStructValueInsideOptional_hClassName.c_str(), OptionalStructValueInsideOptional_hCtorSignature.c_str(), - jniOptionalStructValueInsideOptional_h, OptionalStructValueInsideOptional_h); - - jclass simpleStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); - return; - } - - jmethodID simpleStructStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_1, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" - "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", - &simpleStructStructCtor_1); - if (err != CHIP_NO_ERROR || simpleStructStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); - return; - } - - OptionalStructValueInsideOptional = env->NewObject( - simpleStructStructClass_1, simpleStructStructCtor_1, OptionalStructValueInsideOptional_a, - OptionalStructValueInsideOptional_b, OptionalStructValueInsideOptional_c, OptionalStructValueInsideOptional_d, - OptionalStructValueInsideOptional_e, OptionalStructValueInsideOptional_f, OptionalStructValueInsideOptional_g, - OptionalStructValueInsideOptional_h); - chip::JniReferences::GetInstance().CreateOptional(OptionalStructValueInsideOptional, OptionalStructValue); - } - jobject NullableOptionalStructWasPresent; - std::string NullableOptionalStructWasPresentClassName = "java/lang/Boolean"; - std::string NullableOptionalStructWasPresentCtorSignature = "(Z)V"; - jboolean jniNullableOptionalStructWasPresent = static_cast(dataResponse.nullableOptionalStructWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalStructWasPresentClassName.c_str(), NullableOptionalStructWasPresentCtorSignature.c_str(), - jniNullableOptionalStructWasPresent, NullableOptionalStructWasPresent); - jobject NullableOptionalStructWasNull; - if (!dataResponse.nullableOptionalStructWasNull.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalStructWasNull); - } - else - { - jobject NullableOptionalStructWasNullInsideOptional; - std::string NullableOptionalStructWasNullInsideOptionalClassName = "java/lang/Boolean"; - std::string NullableOptionalStructWasNullInsideOptionalCtorSignature = "(Z)V"; - jboolean jniNullableOptionalStructWasNullInsideOptional = - static_cast(dataResponse.nullableOptionalStructWasNull.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalStructWasNullInsideOptionalClassName.c_str(), - NullableOptionalStructWasNullInsideOptionalCtorSignature.c_str(), jniNullableOptionalStructWasNullInsideOptional, - NullableOptionalStructWasNullInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalStructWasNullInsideOptional, - NullableOptionalStructWasNull); - } - jobject NullableOptionalStructValue; - if (!dataResponse.nullableOptionalStructValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalStructValue); - } - else - { - jobject NullableOptionalStructValueInsideOptional; - jobject NullableOptionalStructValueInsideOptional_a; - std::string NullableOptionalStructValueInsideOptional_aClassName = "java/lang/Integer"; - std::string NullableOptionalStructValueInsideOptional_aCtorSignature = "(I)V"; - jint jniNullableOptionalStructValueInsideOptional_a = static_cast(dataResponse.nullableOptionalStructValue.Value().a); - chip::JniReferences::GetInstance().CreateBoxedObject(NullableOptionalStructValueInsideOptional_aClassName.c_str(), - NullableOptionalStructValueInsideOptional_aCtorSignature.c_str(), - jniNullableOptionalStructValueInsideOptional_a, - NullableOptionalStructValueInsideOptional_a); - jobject NullableOptionalStructValueInsideOptional_b; - std::string NullableOptionalStructValueInsideOptional_bClassName = "java/lang/Boolean"; - std::string NullableOptionalStructValueInsideOptional_bCtorSignature = "(Z)V"; - jboolean jniNullableOptionalStructValueInsideOptional_b = - static_cast(dataResponse.nullableOptionalStructValue.Value().b); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalStructValueInsideOptional_bClassName.c_str(), - NullableOptionalStructValueInsideOptional_bCtorSignature.c_str(), jniNullableOptionalStructValueInsideOptional_b, - NullableOptionalStructValueInsideOptional_b); - jobject NullableOptionalStructValueInsideOptional_c; - std::string NullableOptionalStructValueInsideOptional_cClassName = "java/lang/Integer"; - std::string NullableOptionalStructValueInsideOptional_cCtorSignature = "(I)V"; - jint jniNullableOptionalStructValueInsideOptional_c = static_cast(dataResponse.nullableOptionalStructValue.Value().c); - chip::JniReferences::GetInstance().CreateBoxedObject(NullableOptionalStructValueInsideOptional_cClassName.c_str(), - NullableOptionalStructValueInsideOptional_cCtorSignature.c_str(), - jniNullableOptionalStructValueInsideOptional_c, - NullableOptionalStructValueInsideOptional_c); - jobject NullableOptionalStructValueInsideOptional_d; - jbyteArray NullableOptionalStructValueInsideOptional_dByteArray = - env->NewByteArray(static_cast(dataResponse.nullableOptionalStructValue.Value().d.size())); - env->SetByteArrayRegion(NullableOptionalStructValueInsideOptional_dByteArray, 0, - static_cast(dataResponse.nullableOptionalStructValue.Value().d.size()), - reinterpret_cast(dataResponse.nullableOptionalStructValue.Value().d.data())); - NullableOptionalStructValueInsideOptional_d = NullableOptionalStructValueInsideOptional_dByteArray; - jobject NullableOptionalStructValueInsideOptional_e; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableOptionalStructValue.Value().e, - NullableOptionalStructValueInsideOptional_e)); - jobject NullableOptionalStructValueInsideOptional_f; - std::string NullableOptionalStructValueInsideOptional_fClassName = "java/lang/Integer"; - std::string NullableOptionalStructValueInsideOptional_fCtorSignature = "(I)V"; - jint jniNullableOptionalStructValueInsideOptional_f = - static_cast(dataResponse.nullableOptionalStructValue.Value().f.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject(NullableOptionalStructValueInsideOptional_fClassName.c_str(), - NullableOptionalStructValueInsideOptional_fCtorSignature.c_str(), - jniNullableOptionalStructValueInsideOptional_f, - NullableOptionalStructValueInsideOptional_f); - jobject NullableOptionalStructValueInsideOptional_g; - std::string NullableOptionalStructValueInsideOptional_gClassName = "java/lang/Float"; - std::string NullableOptionalStructValueInsideOptional_gCtorSignature = "(F)V"; - jfloat jniNullableOptionalStructValueInsideOptional_g = - static_cast(dataResponse.nullableOptionalStructValue.Value().g); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalStructValueInsideOptional_gClassName.c_str(), - NullableOptionalStructValueInsideOptional_gCtorSignature.c_str(), jniNullableOptionalStructValueInsideOptional_g, - NullableOptionalStructValueInsideOptional_g); - jobject NullableOptionalStructValueInsideOptional_h; - std::string NullableOptionalStructValueInsideOptional_hClassName = "java/lang/Double"; - std::string NullableOptionalStructValueInsideOptional_hCtorSignature = "(D)V"; - jdouble jniNullableOptionalStructValueInsideOptional_h = - static_cast(dataResponse.nullableOptionalStructValue.Value().h); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalStructValueInsideOptional_hClassName.c_str(), - NullableOptionalStructValueInsideOptional_hCtorSignature.c_str(), jniNullableOptionalStructValueInsideOptional_h, - NullableOptionalStructValueInsideOptional_h); - - jclass simpleStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); - return; - } - - jmethodID simpleStructStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_1, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" - "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", - &simpleStructStructCtor_1); - if (err != CHIP_NO_ERROR || simpleStructStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); - return; - } - - NullableOptionalStructValueInsideOptional = - env->NewObject(simpleStructStructClass_1, simpleStructStructCtor_1, NullableOptionalStructValueInsideOptional_a, - NullableOptionalStructValueInsideOptional_b, NullableOptionalStructValueInsideOptional_c, - NullableOptionalStructValueInsideOptional_d, NullableOptionalStructValueInsideOptional_e, - NullableOptionalStructValueInsideOptional_f, NullableOptionalStructValueInsideOptional_g, - NullableOptionalStructValueInsideOptional_h); - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalStructValueInsideOptional, NullableOptionalStructValue); - } - jobject NullableListWasNull; - std::string NullableListWasNullClassName = "java/lang/Boolean"; - std::string NullableListWasNullCtorSignature = "(Z)V"; - jboolean jniNullableListWasNull = static_cast(dataResponse.nullableListWasNull); - chip::JniReferences::GetInstance().CreateBoxedObject(NullableListWasNullClassName.c_str(), - NullableListWasNullCtorSignature.c_str(), jniNullableListWasNull, - NullableListWasNull); - jobject NullableListValue; - if (!dataResponse.nullableListValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableListValue); - } - else - { - jobject NullableListValueInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(NullableListValueInsideOptional); - - auto iter_NullableListValueInsideOptional_1 = dataResponse.nullableListValue.Value().begin(); - while (iter_NullableListValueInsideOptional_1.Next()) - { - auto & entry_1 = iter_NullableListValueInsideOptional_1.GetValue(); - jobject newElement_1; - std::string newElement_1ClassName = "java/lang/Integer"; - std::string newElement_1CtorSignature = "(I)V"; - jint jninewElement_1 = static_cast(entry_1); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_1ClassName.c_str(), newElement_1CtorSignature.c_str(), jninewElement_1, newElement_1); - chip::JniReferences::GetInstance().AddToList(NullableListValueInsideOptional, newElement_1); - } - chip::JniReferences::GetInstance().CreateOptional(NullableListValueInsideOptional, NullableListValue); - } - jobject OptionalListWasPresent; - std::string OptionalListWasPresentClassName = "java/lang/Boolean"; - std::string OptionalListWasPresentCtorSignature = "(Z)V"; - jboolean jniOptionalListWasPresent = static_cast(dataResponse.optionalListWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject(OptionalListWasPresentClassName.c_str(), - OptionalListWasPresentCtorSignature.c_str(), - jniOptionalListWasPresent, OptionalListWasPresent); - jobject OptionalListValue; - if (!dataResponse.optionalListValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, OptionalListValue); - } - else - { - jobject OptionalListValueInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(OptionalListValueInsideOptional); - - auto iter_OptionalListValueInsideOptional_1 = dataResponse.optionalListValue.Value().begin(); - while (iter_OptionalListValueInsideOptional_1.Next()) - { - auto & entry_1 = iter_OptionalListValueInsideOptional_1.GetValue(); - jobject newElement_1; - std::string newElement_1ClassName = "java/lang/Integer"; - std::string newElement_1CtorSignature = "(I)V"; - jint jninewElement_1 = static_cast(entry_1); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_1ClassName.c_str(), newElement_1CtorSignature.c_str(), jninewElement_1, newElement_1); - chip::JniReferences::GetInstance().AddToList(OptionalListValueInsideOptional, newElement_1); - } - chip::JniReferences::GetInstance().CreateOptional(OptionalListValueInsideOptional, OptionalListValue); - } - jobject NullableOptionalListWasPresent; - std::string NullableOptionalListWasPresentClassName = "java/lang/Boolean"; - std::string NullableOptionalListWasPresentCtorSignature = "(Z)V"; - jboolean jniNullableOptionalListWasPresent = static_cast(dataResponse.nullableOptionalListWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalListWasPresentClassName.c_str(), NullableOptionalListWasPresentCtorSignature.c_str(), - jniNullableOptionalListWasPresent, NullableOptionalListWasPresent); - jobject NullableOptionalListWasNull; - if (!dataResponse.nullableOptionalListWasNull.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalListWasNull); - } - else - { - jobject NullableOptionalListWasNullInsideOptional; - std::string NullableOptionalListWasNullInsideOptionalClassName = "java/lang/Boolean"; - std::string NullableOptionalListWasNullInsideOptionalCtorSignature = "(Z)V"; - jboolean jniNullableOptionalListWasNullInsideOptional = - static_cast(dataResponse.nullableOptionalListWasNull.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalListWasNullInsideOptionalClassName.c_str(), - NullableOptionalListWasNullInsideOptionalCtorSignature.c_str(), jniNullableOptionalListWasNullInsideOptional, - NullableOptionalListWasNullInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalListWasNullInsideOptional, NullableOptionalListWasNull); - } - jobject NullableOptionalListValue; - if (!dataResponse.nullableOptionalListValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalListValue); - } - else - { - jobject NullableOptionalListValueInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(NullableOptionalListValueInsideOptional); - - auto iter_NullableOptionalListValueInsideOptional_1 = dataResponse.nullableOptionalListValue.Value().begin(); - while (iter_NullableOptionalListValueInsideOptional_1.Next()) - { - auto & entry_1 = iter_NullableOptionalListValueInsideOptional_1.GetValue(); - jobject newElement_1; - std::string newElement_1ClassName = "java/lang/Integer"; - std::string newElement_1CtorSignature = "(I)V"; - jint jninewElement_1 = static_cast(entry_1); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_1ClassName.c_str(), newElement_1CtorSignature.c_str(), jninewElement_1, newElement_1); - chip::JniReferences::GetInstance().AddToList(NullableOptionalListValueInsideOptional, newElement_1); - } - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalListValueInsideOptional, NullableOptionalListValue); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, NullableIntWasNull, NullableIntValue, OptionalIntWasPresent, OptionalIntValue, - NullableOptionalIntWasPresent, NullableOptionalIntWasNull, NullableOptionalIntValue, NullableStringWasNull, - NullableStringValue, OptionalStringWasPresent, OptionalStringValue, NullableOptionalStringWasPresent, - NullableOptionalStringWasNull, NullableOptionalStringValue, NullableStructWasNull, NullableStructValue, - OptionalStructWasPresent, OptionalStructValue, NullableOptionalStructWasPresent, - NullableOptionalStructWasNull, NullableOptionalStructValue, NullableListWasNull, NullableListValue, - OptionalListWasPresent, OptionalListValue, NullableOptionalListWasPresent, NullableOptionalListWasNull, - NullableOptionalListValue); -} -CHIPUnitTestingClusterBooleanResponseCallback::CHIPUnitTestingClusterBooleanResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterBooleanResponseCallback::~CHIPUnitTestingClusterBooleanResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterBooleanResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::BooleanResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject value; - std::string valueClassName = "java/lang/Boolean"; - std::string valueCtorSignature = "(Z)V"; - jboolean jnivalue = static_cast(dataResponse.value); - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, - value); - - env->CallVoidMethod(javaCallbackRef, javaMethod, value); -} -CHIPUnitTestingClusterSimpleStructResponseCallback::CHIPUnitTestingClusterSimpleStructResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterSimpleStructResponseCallback::~CHIPUnitTestingClusterSimpleStructResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterSimpleStructResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::SimpleStructResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Lchip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject arg1; - jobject arg1_a; - std::string arg1_aClassName = "java/lang/Integer"; - std::string arg1_aCtorSignature = "(I)V"; - jint jniarg1_a = static_cast(dataResponse.arg1.a); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1_aClassName.c_str(), arg1_aCtorSignature.c_str(), jniarg1_a, - arg1_a); - jobject arg1_b; - std::string arg1_bClassName = "java/lang/Boolean"; - std::string arg1_bCtorSignature = "(Z)V"; - jboolean jniarg1_b = static_cast(dataResponse.arg1.b); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1_bClassName.c_str(), arg1_bCtorSignature.c_str(), jniarg1_b, - arg1_b); - jobject arg1_c; - std::string arg1_cClassName = "java/lang/Integer"; - std::string arg1_cCtorSignature = "(I)V"; - jint jniarg1_c = static_cast(dataResponse.arg1.c); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1_cClassName.c_str(), arg1_cCtorSignature.c_str(), jniarg1_c, - arg1_c); - jobject arg1_d; - jbyteArray arg1_dByteArray = env->NewByteArray(static_cast(dataResponse.arg1.d.size())); - env->SetByteArrayRegion(arg1_dByteArray, 0, static_cast(dataResponse.arg1.d.size()), - reinterpret_cast(dataResponse.arg1.d.data())); - arg1_d = arg1_dByteArray; - jobject arg1_e; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.arg1.e, arg1_e)); - jobject arg1_f; - std::string arg1_fClassName = "java/lang/Integer"; - std::string arg1_fCtorSignature = "(I)V"; - jint jniarg1_f = static_cast(dataResponse.arg1.f.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1_fClassName.c_str(), arg1_fCtorSignature.c_str(), jniarg1_f, - arg1_f); - jobject arg1_g; - std::string arg1_gClassName = "java/lang/Float"; - std::string arg1_gCtorSignature = "(F)V"; - jfloat jniarg1_g = static_cast(dataResponse.arg1.g); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1_gClassName.c_str(), arg1_gCtorSignature.c_str(), jniarg1_g, - arg1_g); - jobject arg1_h; - std::string arg1_hClassName = "java/lang/Double"; - std::string arg1_hCtorSignature = "(D)V"; - jdouble jniarg1_h = static_cast(dataResponse.arg1.h); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1_hClassName.c_str(), arg1_hCtorSignature.c_str(), jniarg1_h, - arg1_h); - - jclass simpleStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", - simpleStructStructClass_0); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); - return; - } - - jmethodID simpleStructStructCtor_0; - err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_0, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/lang/" - "String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", - &simpleStructStructCtor_0); - if (err != CHIP_NO_ERROR || simpleStructStructCtor_0 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); - return; - } - - arg1 = env->NewObject(simpleStructStructClass_0, simpleStructStructCtor_0, arg1_a, arg1_b, arg1_c, arg1_d, arg1_e, arg1_f, - arg1_g, arg1_h); - - env->CallVoidMethod(javaCallbackRef, javaMethod, arg1); -} -CHIPUnitTestingClusterTestEmitTestEventResponseCallback::CHIPUnitTestingClusterTestEmitTestEventResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestEmitTestEventResponseCallback::~CHIPUnitTestingClusterTestEmitTestEventResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestEmitTestEventResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestEmitTestEventResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject value; - std::string valueClassName = "java/lang/Long"; - std::string valueCtorSignature = "(J)V"; - jlong jnivalue = static_cast(dataResponse.value); - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, - value); - - env->CallVoidMethod(javaCallbackRef, javaMethod, value); -} -CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback:: -CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback::~ -CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::UnitTesting::Commands::TestEmitTestFabricScopedEventResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject value; - std::string valueClassName = "java/lang/Long"; - std::string valueCtorSignature = "(J)V"; - jlong jnivalue = static_cast(dataResponse.value); - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, - value); - - env->CallVoidMethod(javaCallbackRef, javaMethod, value); -} -CHIPUnitTestingClusterTestBatchHelperResponseCallback::CHIPUnitTestingClusterTestBatchHelperResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestBatchHelperResponseCallback::~CHIPUnitTestingClusterTestBatchHelperResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestBatchHelperResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestBatchHelperResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([B)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject buffer; - jbyteArray bufferByteArray = env->NewByteArray(static_cast(dataResponse.buffer.size())); - env->SetByteArrayRegion(bufferByteArray, 0, static_cast(dataResponse.buffer.size()), - reinterpret_cast(dataResponse.buffer.data())); - buffer = bufferByteArray; - - env->CallVoidMethod(javaCallbackRef, javaMethod, buffer); -} -CHIPUnitTestingClusterTestDifferentVendorMeiResponseCallback::CHIPUnitTestingClusterTestDifferentVendorMeiResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestDifferentVendorMeiResponseCallback::~CHIPUnitTestingClusterTestDifferentVendorMeiResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestDifferentVendorMeiResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestDifferentVendorMeiResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Long;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject arg1; - std::string arg1ClassName = "java/lang/Integer"; - std::string arg1CtorSignature = "(I)V"; - jint jniarg1 = static_cast(dataResponse.arg1); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1ClassName.c_str(), arg1CtorSignature.c_str(), jniarg1, arg1); - jobject eventNumber; - std::string eventNumberClassName = "java/lang/Long"; - std::string eventNumberCtorSignature = "(J)V"; - jlong jnieventNumber = static_cast(dataResponse.eventNumber); - chip::JniReferences::GetInstance().CreateBoxedObject(eventNumberClassName.c_str(), eventNumberCtorSignature.c_str(), - jnieventNumber, eventNumber); - - env->CallVoidMethod(javaCallbackRef, javaMethod, arg1, eventNumber); -} -CHIPSampleMeiClusterAddArgumentsResponseCallback::CHIPSampleMeiClusterAddArgumentsResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPSampleMeiClusterAddArgumentsResponseCallback::~CHIPSampleMeiClusterAddArgumentsResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPSampleMeiClusterAddArgumentsResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::SampleMei::Commands::AddArgumentsResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject returnValue; - std::string returnValueClassName = "java/lang/Integer"; - std::string returnValueCtorSignature = "(I)V"; - jint jnireturnValue = static_cast(dataResponse.returnValue); - chip::JniReferences::GetInstance().CreateBoxedObject(returnValueClassName.c_str(), returnValueCtorSignature.c_str(), - jnireturnValue, returnValue); - - env->CallVoidMethod(javaCallbackRef, javaMethod, returnValue); -} -} // namespace chip diff --git a/src/controller/python/BUILD.gn b/src/controller/python/BUILD.gn index c8d2ac32779726..e14b7127dec68d 100644 --- a/src/controller/python/BUILD.gn +++ b/src/controller/python/BUILD.gn @@ -130,6 +130,7 @@ shared_library("ChipDeviceCtrl") { public_deps += [ "${chip_root}/src/controller/data_model", "${chip_root}/src/credentials:file_attestation_trust_store", + "${chip_root}/src/lib/support:testing", "${chip_root}/src/tracing/json", "${chip_root}/src/tracing/perfetto", "${chip_root}/src/tracing/perfetto:file_output", diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 402f2b7cea694d..509e6f5e247fcb 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -867,6 +867,9 @@ async def TestOnlySendBatchCommands(self, nodeid: int, commands: typing.List[Clu remoteMaxPathsPerInvoke: Overrides the number of batch commands we think can be sent to remote node. suppressTimedRequestMessage: When set to true, we suppress sending Timed Request Message. commandRefsOverride: List of commandRefs to use for each command with the same index in `commands`. + + Returns: + - TestOnlyBatchCommandResponse ''' self.CheckIsActive() diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index 56486a09e15a42..853fd1f98c38cd 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -2246,6 +2246,15 @@ class ChipClusters: "args": { }, }, + 0x00000003: { + "commandId": 0x00000003, + "commandName": "PayloadTestRequest", + "args": { + "enableKey": "bytes", + "value": "int", + "count": "int", + }, + }, }, "attributes": { 0x00000000: { @@ -6331,6 +6340,164 @@ class ChipClusters: }, }, } + _ELECTRICAL_POWER_MEASUREMENT_CLUSTER_INFO = { + "clusterName": "ElectricalPowerMeasurement", + "clusterId": 0x00000090, + "commands": { + }, + "attributes": { + 0x00000000: { + "attributeName": "PowerMode", + "attributeId": 0x00000000, + "type": "int", + "reportable": True, + }, + 0x00000001: { + "attributeName": "NumberOfMeasurementTypes", + "attributeId": 0x00000001, + "type": "int", + "reportable": True, + }, + 0x00000002: { + "attributeName": "Accuracy", + "attributeId": 0x00000002, + "type": "", + "reportable": True, + }, + 0x00000003: { + "attributeName": "Ranges", + "attributeId": 0x00000003, + "type": "", + "reportable": True, + }, + 0x00000004: { + "attributeName": "Voltage", + "attributeId": 0x00000004, + "type": "int", + "reportable": True, + }, + 0x00000005: { + "attributeName": "ActiveCurrent", + "attributeId": 0x00000005, + "type": "int", + "reportable": True, + }, + 0x00000006: { + "attributeName": "ReactiveCurrent", + "attributeId": 0x00000006, + "type": "int", + "reportable": True, + }, + 0x00000007: { + "attributeName": "ApparentCurrent", + "attributeId": 0x00000007, + "type": "int", + "reportable": True, + }, + 0x00000008: { + "attributeName": "ActivePower", + "attributeId": 0x00000008, + "type": "int", + "reportable": True, + }, + 0x00000009: { + "attributeName": "ReactivePower", + "attributeId": 0x00000009, + "type": "int", + "reportable": True, + }, + 0x0000000A: { + "attributeName": "ApparentPower", + "attributeId": 0x0000000A, + "type": "int", + "reportable": True, + }, + 0x0000000B: { + "attributeName": "RMSVoltage", + "attributeId": 0x0000000B, + "type": "int", + "reportable": True, + }, + 0x0000000C: { + "attributeName": "RMSCurrent", + "attributeId": 0x0000000C, + "type": "int", + "reportable": True, + }, + 0x0000000D: { + "attributeName": "RMSPower", + "attributeId": 0x0000000D, + "type": "int", + "reportable": True, + }, + 0x0000000E: { + "attributeName": "Frequency", + "attributeId": 0x0000000E, + "type": "int", + "reportable": True, + }, + 0x0000000F: { + "attributeName": "HarmonicCurrents", + "attributeId": 0x0000000F, + "type": "", + "reportable": True, + }, + 0x00000010: { + "attributeName": "HarmonicPhases", + "attributeId": 0x00000010, + "type": "", + "reportable": True, + }, + 0x00000011: { + "attributeName": "PowerFactor", + "attributeId": 0x00000011, + "type": "int", + "reportable": True, + }, + 0x00000012: { + "attributeName": "NeutralCurrent", + "attributeId": 0x00000012, + "type": "int", + "reportable": True, + }, + 0x0000FFF8: { + "attributeName": "GeneratedCommandList", + "attributeId": 0x0000FFF8, + "type": "int", + "reportable": True, + }, + 0x0000FFF9: { + "attributeName": "AcceptedCommandList", + "attributeId": 0x0000FFF9, + "type": "int", + "reportable": True, + }, + 0x0000FFFA: { + "attributeName": "EventList", + "attributeId": 0x0000FFFA, + "type": "int", + "reportable": True, + }, + 0x0000FFFB: { + "attributeName": "AttributeList", + "attributeId": 0x0000FFFB, + "type": "int", + "reportable": True, + }, + 0x0000FFFC: { + "attributeName": "FeatureMap", + "attributeId": 0x0000FFFC, + "type": "int", + "reportable": True, + }, + 0x0000FFFD: { + "attributeName": "ClusterRevision", + "attributeId": 0x0000FFFD, + "type": "int", + "reportable": True, + }, + }, + } _ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_INFO = { "clusterName": "ElectricalEnergyMeasurement", "clusterId": 0x00000091, @@ -6367,6 +6534,12 @@ class ChipClusters: "type": "", "reportable": True, }, + 0x00000005: { + "attributeName": "CumulativeEnergyReset", + "attributeId": 0x00000005, + "type": "", + "reportable": True, + }, 0x0000FFF8: { "attributeName": "GeneratedCommandList", "attributeId": 0x0000FFF8, @@ -7071,6 +7244,62 @@ class ChipClusters: }, }, } + _POWER_TOPOLOGY_CLUSTER_INFO = { + "clusterName": "PowerTopology", + "clusterId": 0x0000009C, + "commands": { + }, + "attributes": { + 0x00000000: { + "attributeName": "AvailableEndpoints", + "attributeId": 0x00000000, + "type": "int", + "reportable": True, + }, + 0x00000001: { + "attributeName": "ActiveEndpoints", + "attributeId": 0x00000001, + "type": "int", + "reportable": True, + }, + 0x0000FFF8: { + "attributeName": "GeneratedCommandList", + "attributeId": 0x0000FFF8, + "type": "int", + "reportable": True, + }, + 0x0000FFF9: { + "attributeName": "AcceptedCommandList", + "attributeId": 0x0000FFF9, + "type": "int", + "reportable": True, + }, + 0x0000FFFA: { + "attributeName": "EventList", + "attributeId": 0x0000FFFA, + "type": "int", + "reportable": True, + }, + 0x0000FFFB: { + "attributeName": "AttributeList", + "attributeId": 0x0000FFFB, + "type": "int", + "reportable": True, + }, + 0x0000FFFC: { + "attributeName": "FeatureMap", + "attributeId": 0x0000FFFC, + "type": "int", + "reportable": True, + }, + 0x0000FFFD: { + "attributeName": "ClusterRevision", + "attributeId": 0x0000FFFD, + "type": "int", + "reportable": True, + }, + }, + } _ENERGY_EVSE_MODE_CLUSTER_INFO = { "clusterName": "EnergyEvseMode", "clusterId": 0x0000009D, @@ -14373,12 +14602,14 @@ class ChipClusters: 0x00000072: _ACTIVATED_CARBON_FILTER_MONITORING_CLUSTER_INFO, 0x00000080: _BOOLEAN_STATE_CONFIGURATION_CLUSTER_INFO, 0x00000081: _VALVE_CONFIGURATION_AND_CONTROL_CLUSTER_INFO, + 0x00000090: _ELECTRICAL_POWER_MEASUREMENT_CLUSTER_INFO, 0x00000091: _ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_INFO, 0x00000096: _DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER_INFO, 0x00000097: _MESSAGES_CLUSTER_INFO, 0x00000098: _DEVICE_ENERGY_MANAGEMENT_CLUSTER_INFO, 0x00000099: _ENERGY_EVSE_CLUSTER_INFO, 0x0000009B: _ENERGY_PREFERENCE_CLUSTER_INFO, + 0x0000009C: _POWER_TOPOLOGY_CLUSTER_INFO, 0x0000009D: _ENERGY_EVSE_MODE_CLUSTER_INFO, 0x0000009F: _DEVICE_ENERGY_MANAGEMENT_MODE_CLUSTER_INFO, 0x00000101: _DOOR_LOCK_CLUSTER_INFO, @@ -14492,12 +14723,14 @@ class ChipClusters: "ActivatedCarbonFilterMonitoring": _ACTIVATED_CARBON_FILTER_MONITORING_CLUSTER_INFO, "BooleanStateConfiguration": _BOOLEAN_STATE_CONFIGURATION_CLUSTER_INFO, "ValveConfigurationAndControl": _VALVE_CONFIGURATION_AND_CONTROL_CLUSTER_INFO, + "ElectricalPowerMeasurement": _ELECTRICAL_POWER_MEASUREMENT_CLUSTER_INFO, "ElectricalEnergyMeasurement": _ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_INFO, "DemandResponseLoadControl": _DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER_INFO, "Messages": _MESSAGES_CLUSTER_INFO, "DeviceEnergyManagement": _DEVICE_ENERGY_MANAGEMENT_CLUSTER_INFO, "EnergyEvse": _ENERGY_EVSE_CLUSTER_INFO, "EnergyPreference": _ENERGY_PREFERENCE_CLUSTER_INFO, + "PowerTopology": _POWER_TOPOLOGY_CLUSTER_INFO, "EnergyEvseMode": _ENERGY_EVSE_MODE_CLUSTER_INFO, "DeviceEnergyManagementMode": _DEVICE_ENERGY_MANAGEMENT_MODE_CLUSTER_INFO, "DoorLock": _DOOR_LOCK_CLUSTER_INFO, diff --git a/src/controller/python/chip/clusters/Command.py b/src/controller/python/chip/clusters/Command.py index 4c556fd97f6e45..89aae537c9b3fd 100644 --- a/src/controller/python/chip/clusters/Command.py +++ b/src/controller/python/chip/clusters/Command.py @@ -27,7 +27,7 @@ import chip.exceptions import chip.interaction_model -from chip.interaction_model import PyInvokeRequestData, TestOnlyPyBatchCommandsOverrides +from chip.interaction_model import PyInvokeRequestData, TestOnlyPyBatchCommandsOverrides, TestOnlyPyOnDoneInfo from chip.native import PyChipError from .ClusterObjects import ClusterCommand @@ -56,6 +56,12 @@ class Status: ClusterStatus: int +@dataclass +class TestOnlyBatchCommandResponse: + Responses: object + ResponseMessageCount: int + + def FindCommandClusterObject(isClientSideCommand: bool, path: CommandPath): ''' Locates the right generated cluster object given a set of parameters. @@ -215,12 +221,29 @@ def handleDone(self): ) +class TestOnlyAsyncBatchCommandsTransaction(AsyncBatchCommandsTransaction): + def __init__(self, future: Future, eventLoop, expectTypes: List[Type]): + self._responseMessageCount = 0 + super().__init__(future, eventLoop, expectTypes) + + def _handleDone(self): + # Future might already be set with exception from `handleError` + if not self._future.done(): + self._future.set_result(TestOnlyBatchCommandResponse(self._responses, self._responseMessageCount)) + ctypes.pythonapi.Py_DecRef(ctypes.py_object(self)) + + def testOnlyDoneInfo(self, testOnlyDoneInfo: TestOnlyPyOnDoneInfo): + self._responseMessageCount = testOnlyDoneInfo.responseMessageCount + + _OnCommandSenderResponseCallbackFunct = CFUNCTYPE( None, py_object, c_uint16, c_uint32, c_uint32, c_size_t, c_uint16, c_uint8, c_void_p, c_uint32) _OnCommandSenderErrorCallbackFunct = CFUNCTYPE( None, py_object, c_uint16, c_uint8, PyChipError) _OnCommandSenderDoneCallbackFunct = CFUNCTYPE( None, py_object) +_TestOnlyOnCommandSenderDoneCallbackFunct = CFUNCTYPE( + None, py_object, TestOnlyPyOnDoneInfo) @_OnCommandSenderResponseCallbackFunct @@ -241,6 +264,12 @@ def _OnCommandSenderDoneCallback(closure): closure.handleDone() +@_TestOnlyOnCommandSenderDoneCallbackFunct +def _TestOnlyOnCommandSenderDoneCallback(closure, testOnlyDoneInfo: TestOnlyPyOnDoneInfo): + closure.testOnlyDoneInfo(testOnlyDoneInfo) + closure.handleDone() + + def TestOnlySendCommandTimedRequestFlagWithNoTimedInvoke(future: Future, eventLoop, responseType, device, commandPath, payload): ''' ONLY TO BE USED FOR TEST: Sends the payload with a TimedRequest flag but no TimedInvoke transaction ''' @@ -392,7 +421,7 @@ def TestOnlySendBatchCommands(future: Future, eventLoop, device, commands: List[ pyBatchCommandsData = _BuildPyInvokeRequestData(commands, timedRequestTimeoutMs, responseTypes, suppressTimedRequestMessage=suppressTimedRequestMessage) - transaction = AsyncBatchCommandsTransaction(future, eventLoop, responseTypes) + transaction = TestOnlyAsyncBatchCommandsTransaction(future, eventLoop, responseTypes) ctypes.pythonapi.Py_IncRef(ctypes.py_object(transaction)) testOnlyOverrides = TestOnlyPyBatchCommandsOverrides() @@ -448,7 +477,7 @@ def Init(): setter.Set('pychip_CommandSender_SendGroupCommand', PyChipError, [c_uint16, c_void_p, c_uint32, c_uint32, c_char_p, c_size_t, c_uint16]) setter.Set('pychip_CommandSender_InitCallbacks', None, [ - _OnCommandSenderResponseCallbackFunct, _OnCommandSenderErrorCallbackFunct, _OnCommandSenderDoneCallbackFunct]) + _OnCommandSenderResponseCallbackFunct, _OnCommandSenderErrorCallbackFunct, _OnCommandSenderDoneCallbackFunct, _TestOnlyOnCommandSenderDoneCallbackFunct]) handle.pychip_CommandSender_InitCallbacks( - _OnCommandSenderResponseCallback, _OnCommandSenderErrorCallback, _OnCommandSenderDoneCallback) + _OnCommandSenderResponseCallback, _OnCommandSenderErrorCallback, _OnCommandSenderDoneCallback, _TestOnlyOnCommandSenderDoneCallback) diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 38a40194feff0a..338d93e2568a2c 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -7699,6 +7699,10 @@ class RadioFaultEnum(MatterIntEnum): # enum value. This specific should never be transmitted. kUnknownEnumValue = 7, + class Bitmaps: + class Feature(IntFlag): + kDataModelTest = 0x1 + class Structs: @dataclass class NetworkInterface(ClusterObject): @@ -7775,6 +7779,42 @@ def descriptor(cls) -> ClusterObjectDescriptor: systemTimeMs: 'uint' = 0 posixTimeMs: 'typing.Union[Nullable, uint]' = NullValue + @dataclass + class PayloadTestRequest(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0x00000033 + command_id: typing.ClassVar[int] = 0x00000003 + is_client: typing.ClassVar[bool] = True + response_type: typing.ClassVar[str] = 'PayloadTestResponse' + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="enableKey", Tag=0, Type=bytes), + ClusterObjectFieldDescriptor(Label="value", Tag=1, Type=uint), + ClusterObjectFieldDescriptor(Label="count", Tag=2, Type=uint), + ]) + + enableKey: 'bytes' = b"" + value: 'uint' = 0 + count: 'uint' = 0 + + @dataclass + class PayloadTestResponse(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0x00000033 + command_id: typing.ClassVar[int] = 0x00000004 + is_client: typing.ClassVar[bool] = False + response_type: typing.ClassVar[str] = None + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="payload", Tag=0, Type=bytes), + ]) + + payload: 'bytes' = b"" + class Attributes: @dataclass class NetworkInterfaces(ClusterAttributeDescriptor): @@ -22138,18 +22178,32 @@ def descriptor(cls) -> ClusterObjectDescriptor: @dataclass -class ElectricalEnergyMeasurement(Cluster): - id: typing.ClassVar[int] = 0x00000091 +class ElectricalPowerMeasurement(Cluster): + id: typing.ClassVar[int] = 0x00000090 @ChipUtility.classproperty def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="accuracy", Tag=0x00000000, Type=ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct), - ClusterObjectFieldDescriptor(Label="cumulativeEnergyImported", Tag=0x00000001, Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), - ClusterObjectFieldDescriptor(Label="cumulativeEnergyExported", Tag=0x00000002, Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), - ClusterObjectFieldDescriptor(Label="periodicEnergyImported", Tag=0x00000003, Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), - ClusterObjectFieldDescriptor(Label="periodicEnergyExported", Tag=0x00000004, Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ClusterObjectFieldDescriptor(Label="powerMode", Tag=0x00000000, Type=ElectricalPowerMeasurement.Enums.PowerModeEnum), + ClusterObjectFieldDescriptor(Label="numberOfMeasurementTypes", Tag=0x00000001, Type=uint), + ClusterObjectFieldDescriptor(Label="accuracy", Tag=0x00000002, Type=typing.List[ElectricalPowerMeasurement.Structs.MeasurementAccuracyStruct]), + ClusterObjectFieldDescriptor(Label="ranges", Tag=0x00000003, Type=typing.Optional[typing.List[ElectricalPowerMeasurement.Structs.MeasurementRangeStruct]]), + ClusterObjectFieldDescriptor(Label="voltage", Tag=0x00000004, Type=typing.Union[None, Nullable, int]), + ClusterObjectFieldDescriptor(Label="activeCurrent", Tag=0x00000005, Type=typing.Union[None, Nullable, int]), + ClusterObjectFieldDescriptor(Label="reactiveCurrent", Tag=0x00000006, Type=typing.Union[None, Nullable, int]), + ClusterObjectFieldDescriptor(Label="apparentCurrent", Tag=0x00000007, Type=typing.Union[None, Nullable, int]), + ClusterObjectFieldDescriptor(Label="activePower", Tag=0x00000008, Type=typing.Union[Nullable, int]), + ClusterObjectFieldDescriptor(Label="reactivePower", Tag=0x00000009, Type=typing.Union[None, Nullable, int]), + ClusterObjectFieldDescriptor(Label="apparentPower", Tag=0x0000000A, Type=typing.Union[None, Nullable, int]), + ClusterObjectFieldDescriptor(Label="RMSVoltage", Tag=0x0000000B, Type=typing.Union[None, Nullable, int]), + ClusterObjectFieldDescriptor(Label="RMSCurrent", Tag=0x0000000C, Type=typing.Union[None, Nullable, int]), + ClusterObjectFieldDescriptor(Label="RMSPower", Tag=0x0000000D, Type=typing.Union[None, Nullable, int]), + ClusterObjectFieldDescriptor(Label="frequency", Tag=0x0000000E, Type=typing.Union[None, Nullable, int]), + ClusterObjectFieldDescriptor(Label="harmonicCurrents", Tag=0x0000000F, Type=typing.Union[None, Nullable, typing.List[ElectricalPowerMeasurement.Structs.HarmonicMeasurementStruct]]), + ClusterObjectFieldDescriptor(Label="harmonicPhases", Tag=0x00000010, Type=typing.Union[None, Nullable, typing.List[ElectricalPowerMeasurement.Structs.HarmonicMeasurementStruct]]), + ClusterObjectFieldDescriptor(Label="powerFactor", Tag=0x00000011, Type=typing.Union[None, Nullable, int]), + ClusterObjectFieldDescriptor(Label="neutralCurrent", Tag=0x00000012, Type=typing.Union[None, Nullable, int]), ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="eventList", Tag=0x0000FFFA, Type=typing.List[uint]), @@ -22158,11 +22212,25 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="clusterRevision", Tag=0x0000FFFD, Type=uint), ]) - accuracy: 'ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct' = None - cumulativeEnergyImported: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None - cumulativeEnergyExported: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None - periodicEnergyImported: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None - periodicEnergyExported: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + powerMode: 'ElectricalPowerMeasurement.Enums.PowerModeEnum' = None + numberOfMeasurementTypes: 'uint' = None + accuracy: 'typing.List[ElectricalPowerMeasurement.Structs.MeasurementAccuracyStruct]' = None + ranges: 'typing.Optional[typing.List[ElectricalPowerMeasurement.Structs.MeasurementRangeStruct]]' = None + voltage: 'typing.Union[None, Nullable, int]' = None + activeCurrent: 'typing.Union[None, Nullable, int]' = None + reactiveCurrent: 'typing.Union[None, Nullable, int]' = None + apparentCurrent: 'typing.Union[None, Nullable, int]' = None + activePower: 'typing.Union[Nullable, int]' = None + reactivePower: 'typing.Union[None, Nullable, int]' = None + apparentPower: 'typing.Union[None, Nullable, int]' = None + RMSVoltage: 'typing.Union[None, Nullable, int]' = None + RMSCurrent: 'typing.Union[None, Nullable, int]' = None + RMSPower: 'typing.Union[None, Nullable, int]' = None + frequency: 'typing.Union[None, Nullable, int]' = None + harmonicCurrents: 'typing.Union[None, Nullable, typing.List[ElectricalPowerMeasurement.Structs.HarmonicMeasurementStruct]]' = None + harmonicPhases: 'typing.Union[None, Nullable, typing.List[ElectricalPowerMeasurement.Structs.HarmonicMeasurementStruct]]' = None + powerFactor: 'typing.Union[None, Nullable, int]' = None + neutralCurrent: 'typing.Union[None, Nullable, int]' = None generatedCommandList: 'typing.List[uint]' = None acceptedCommandList: 'typing.List[uint]' = None eventList: 'typing.List[uint]' = None @@ -22193,12 +22261,23 @@ class MeasurementTypeEnum(MatterIntEnum): # enum value. This specific should never be transmitted. kUnknownEnumValue = 15, + class PowerModeEnum(MatterIntEnum): + kUnknown = 0x00 + kDc = 0x01 + kAc = 0x02 + # All received enum values that are not listed above will be mapped + # to kUnknownEnumValue. This is a helper enum value that should only + # be used by code to process how it handles receiving and unknown + # enum value. This specific should never be transmitted. + kUnknownEnumValue = 3, + class Bitmaps: class Feature(IntFlag): - kImportedEnergy = 0x1 - kExportedEnergy = 0x2 - kCumulativeEnergy = 0x4 - kPeriodicEnergy = 0x8 + kDirectCurrent = 0x1 + kAlternatingCurrent = 0x2 + kPolyphasePower = 0x4 + kHarmonics = 0x8 + kPowerQuality = 0x10 class Structs: @dataclass @@ -22232,44 +22311,69 @@ class MeasurementAccuracyStruct(ClusterObject): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="measurementType", Tag=0, Type=ElectricalEnergyMeasurement.Enums.MeasurementTypeEnum), + ClusterObjectFieldDescriptor(Label="measurementType", Tag=0, Type=ElectricalPowerMeasurement.Enums.MeasurementTypeEnum), ClusterObjectFieldDescriptor(Label="measured", Tag=1, Type=bool), ClusterObjectFieldDescriptor(Label="minMeasuredValue", Tag=2, Type=int), ClusterObjectFieldDescriptor(Label="maxMeasuredValue", Tag=3, Type=int), - ClusterObjectFieldDescriptor(Label="accuracyRanges", Tag=4, Type=typing.List[ElectricalEnergyMeasurement.Structs.MeasurementAccuracyRangeStruct]), + ClusterObjectFieldDescriptor(Label="accuracyRanges", Tag=4, Type=typing.List[ElectricalPowerMeasurement.Structs.MeasurementAccuracyRangeStruct]), ]) - measurementType: 'ElectricalEnergyMeasurement.Enums.MeasurementTypeEnum' = 0 + measurementType: 'ElectricalPowerMeasurement.Enums.MeasurementTypeEnum' = 0 measured: 'bool' = False minMeasuredValue: 'int' = 0 maxMeasuredValue: 'int' = 0 - accuracyRanges: 'typing.List[ElectricalEnergyMeasurement.Structs.MeasurementAccuracyRangeStruct]' = field(default_factory=lambda: []) + accuracyRanges: 'typing.List[ElectricalPowerMeasurement.Structs.MeasurementAccuracyRangeStruct]' = field(default_factory=lambda: []) @dataclass - class EnergyMeasurementStruct(ClusterObject): + class HarmonicMeasurementStruct(ClusterObject): @ChipUtility.classproperty def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="energy", Tag=0, Type=int), - ClusterObjectFieldDescriptor(Label="startTimestamp", Tag=1, Type=typing.Optional[uint]), - ClusterObjectFieldDescriptor(Label="endTimestamp", Tag=2, Type=typing.Optional[uint]), - ClusterObjectFieldDescriptor(Label="startSystime", Tag=3, Type=typing.Optional[uint]), - ClusterObjectFieldDescriptor(Label="endSystime", Tag=4, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="order", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="measurement", Tag=1, Type=typing.Union[Nullable, int]), ]) - energy: 'int' = 0 + order: 'uint' = 0 + measurement: 'typing.Union[Nullable, int]' = NullValue + + @dataclass + class MeasurementRangeStruct(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="measurementType", Tag=0, Type=ElectricalPowerMeasurement.Enums.MeasurementTypeEnum), + ClusterObjectFieldDescriptor(Label="min", Tag=1, Type=int), + ClusterObjectFieldDescriptor(Label="max", Tag=2, Type=int), + ClusterObjectFieldDescriptor(Label="startTimestamp", Tag=3, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="endTimestamp", Tag=4, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="minTimestamp", Tag=5, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="maxTimestamp", Tag=6, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="startSystime", Tag=7, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="endSystime", Tag=8, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="minSystime", Tag=9, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="maxSystime", Tag=10, Type=typing.Optional[uint]), + ]) + + measurementType: 'ElectricalPowerMeasurement.Enums.MeasurementTypeEnum' = 0 + min: 'int' = 0 + max: 'int' = 0 startTimestamp: 'typing.Optional[uint]' = None endTimestamp: 'typing.Optional[uint]' = None + minTimestamp: 'typing.Optional[uint]' = None + maxTimestamp: 'typing.Optional[uint]' = None startSystime: 'typing.Optional[uint]' = None endSystime: 'typing.Optional[uint]' = None + minSystime: 'typing.Optional[uint]' = None + maxSystime: 'typing.Optional[uint]' = None class Attributes: @dataclass - class Accuracy(ClusterAttributeDescriptor): + class PowerMode(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: - return 0x00000091 + return 0x00000090 @ChipUtility.classproperty def attribute_id(cls) -> int: @@ -22277,15 +22381,15 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct) + return ClusterObjectFieldDescriptor(Type=ElectricalPowerMeasurement.Enums.PowerModeEnum) - value: 'ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct' = field(default_factory=lambda: ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct()) + value: 'ElectricalPowerMeasurement.Enums.PowerModeEnum' = 0 @dataclass - class CumulativeEnergyImported(ClusterAttributeDescriptor): + class NumberOfMeasurementTypes(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: - return 0x00000091 + return 0x00000090 @ChipUtility.classproperty def attribute_id(cls) -> int: @@ -22293,15 +22397,15 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]) + return ClusterObjectFieldDescriptor(Type=uint) - value: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + value: 'uint' = 0 @dataclass - class CumulativeEnergyExported(ClusterAttributeDescriptor): + class Accuracy(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: - return 0x00000091 + return 0x00000090 @ChipUtility.classproperty def attribute_id(cls) -> int: @@ -22309,15 +22413,15 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]) + return ClusterObjectFieldDescriptor(Type=typing.List[ElectricalPowerMeasurement.Structs.MeasurementAccuracyStruct]) - value: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + value: 'typing.List[ElectricalPowerMeasurement.Structs.MeasurementAccuracyStruct]' = field(default_factory=lambda: []) @dataclass - class PeriodicEnergyImported(ClusterAttributeDescriptor): + class Ranges(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: - return 0x00000091 + return 0x00000090 @ChipUtility.classproperty def attribute_id(cls) -> int: @@ -22325,15 +22429,15 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]) + return ClusterObjectFieldDescriptor(Type=typing.Optional[typing.List[ElectricalPowerMeasurement.Structs.MeasurementRangeStruct]]) - value: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + value: 'typing.Optional[typing.List[ElectricalPowerMeasurement.Structs.MeasurementRangeStruct]]' = None @dataclass - class PeriodicEnergyExported(ClusterAttributeDescriptor): + class Voltage(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: - return 0x00000091 + return 0x00000090 @ChipUtility.classproperty def attribute_id(cls) -> int: @@ -22341,210 +22445,794 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]) + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, int]) - value: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + value: 'typing.Union[None, Nullable, int]' = None @dataclass - class GeneratedCommandList(ClusterAttributeDescriptor): + class ActiveCurrent(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: - return 0x00000091 + return 0x00000090 @ChipUtility.classproperty def attribute_id(cls) -> int: - return 0x0000FFF8 + return 0x00000005 @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, int]) - value: 'typing.List[uint]' = field(default_factory=lambda: []) + value: 'typing.Union[None, Nullable, int]' = None @dataclass - class AcceptedCommandList(ClusterAttributeDescriptor): + class ReactiveCurrent(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: - return 0x00000091 + return 0x00000090 @ChipUtility.classproperty def attribute_id(cls) -> int: - return 0x0000FFF9 + return 0x00000006 @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, int]) - value: 'typing.List[uint]' = field(default_factory=lambda: []) + value: 'typing.Union[None, Nullable, int]' = None @dataclass - class EventList(ClusterAttributeDescriptor): + class ApparentCurrent(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: - return 0x00000091 + return 0x00000090 @ChipUtility.classproperty def attribute_id(cls) -> int: - return 0x0000FFFA + return 0x00000007 @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, int]) - value: 'typing.List[uint]' = field(default_factory=lambda: []) + value: 'typing.Union[None, Nullable, int]' = None @dataclass - class AttributeList(ClusterAttributeDescriptor): + class ActivePower(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: - return 0x00000091 + return 0x00000090 @ChipUtility.classproperty def attribute_id(cls) -> int: - return 0x0000FFFB + return 0x00000008 @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + return ClusterObjectFieldDescriptor(Type=typing.Union[Nullable, int]) - value: 'typing.List[uint]' = field(default_factory=lambda: []) + value: 'typing.Union[Nullable, int]' = NullValue @dataclass - class FeatureMap(ClusterAttributeDescriptor): + class ReactivePower(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: - return 0x00000091 + return 0x00000090 @ChipUtility.classproperty def attribute_id(cls) -> int: - return 0x0000FFFC + return 0x00000009 @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=uint) + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, int]) - value: 'uint' = 0 + value: 'typing.Union[None, Nullable, int]' = None @dataclass - class ClusterRevision(ClusterAttributeDescriptor): + class ApparentPower(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: - return 0x00000091 + return 0x00000090 @ChipUtility.classproperty def attribute_id(cls) -> int: - return 0x0000FFFD + return 0x0000000A @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=uint) + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, int]) - value: 'uint' = 0 + value: 'typing.Union[None, Nullable, int]' = None - class Events: @dataclass - class CumulativeEnergyMeasured(ClusterEvent): + class RMSVoltage(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: - return 0x00000091 + return 0x00000090 @ChipUtility.classproperty - def event_id(cls) -> int: - return 0x00000000 + def attribute_id(cls) -> int: + return 0x0000000B @ChipUtility.classproperty - def descriptor(cls) -> ClusterObjectDescriptor: - return ClusterObjectDescriptor( - Fields=[ - ClusterObjectFieldDescriptor(Label="energyImported", Tag=0, Type=typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), - ClusterObjectFieldDescriptor(Label="energyExported", Tag=1, Type=typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), - ]) + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, int]) - energyImported: 'typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None - energyExported: 'typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + value: 'typing.Union[None, Nullable, int]' = None @dataclass - class PeriodicEnergyMeasured(ClusterEvent): + class RMSCurrent(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: - return 0x00000091 + return 0x00000090 @ChipUtility.classproperty - def event_id(cls) -> int: - return 0x00000001 + def attribute_id(cls) -> int: + return 0x0000000C @ChipUtility.classproperty - def descriptor(cls) -> ClusterObjectDescriptor: - return ClusterObjectDescriptor( - Fields=[ - ClusterObjectFieldDescriptor(Label="energyImported", Tag=0, Type=typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), - ClusterObjectFieldDescriptor(Label="energyExported", Tag=1, Type=typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), - ]) + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, int]) - energyImported: 'typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None - energyExported: 'typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + value: 'typing.Union[None, Nullable, int]' = None + @dataclass + class RMSPower(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000090 -@dataclass -class DemandResponseLoadControl(Cluster): - id: typing.ClassVar[int] = 0x00000096 + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000000D - @ChipUtility.classproperty - def descriptor(cls) -> ClusterObjectDescriptor: - return ClusterObjectDescriptor( - Fields=[ - ClusterObjectFieldDescriptor(Label="loadControlPrograms", Tag=0x00000000, Type=typing.List[DemandResponseLoadControl.Structs.LoadControlProgramStruct]), - ClusterObjectFieldDescriptor(Label="numberOfLoadControlPrograms", Tag=0x00000001, Type=uint), - ClusterObjectFieldDescriptor(Label="events", Tag=0x00000002, Type=typing.List[DemandResponseLoadControl.Structs.LoadControlEventStruct]), - ClusterObjectFieldDescriptor(Label="activeEvents", Tag=0x00000003, Type=typing.List[DemandResponseLoadControl.Structs.LoadControlEventStruct]), - ClusterObjectFieldDescriptor(Label="numberOfEventsPerProgram", Tag=0x00000004, Type=uint), - ClusterObjectFieldDescriptor(Label="numberOfTransitions", Tag=0x00000005, Type=uint), - ClusterObjectFieldDescriptor(Label="defaultRandomStart", Tag=0x00000006, Type=uint), - ClusterObjectFieldDescriptor(Label="defaultRandomDuration", Tag=0x00000007, Type=uint), - ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), - ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), - ClusterObjectFieldDescriptor(Label="eventList", Tag=0x0000FFFA, Type=typing.List[uint]), - ClusterObjectFieldDescriptor(Label="attributeList", Tag=0x0000FFFB, Type=typing.List[uint]), - ClusterObjectFieldDescriptor(Label="featureMap", Tag=0x0000FFFC, Type=uint), - ClusterObjectFieldDescriptor(Label="clusterRevision", Tag=0x0000FFFD, Type=uint), - ]) + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, int]) - loadControlPrograms: 'typing.List[DemandResponseLoadControl.Structs.LoadControlProgramStruct]' = None - numberOfLoadControlPrograms: 'uint' = None - events: 'typing.List[DemandResponseLoadControl.Structs.LoadControlEventStruct]' = None - activeEvents: 'typing.List[DemandResponseLoadControl.Structs.LoadControlEventStruct]' = None - numberOfEventsPerProgram: 'uint' = None - numberOfTransitions: 'uint' = None - defaultRandomStart: 'uint' = None - defaultRandomDuration: 'uint' = None - generatedCommandList: 'typing.List[uint]' = None - acceptedCommandList: 'typing.List[uint]' = None - eventList: 'typing.List[uint]' = None - attributeList: 'typing.List[uint]' = None - featureMap: 'uint' = None - clusterRevision: 'uint' = None + value: 'typing.Union[None, Nullable, int]' = None - class Enums: - class CriticalityLevelEnum(MatterIntEnum): - kUnknown = 0x00 - kGreen = 0x01 - kLevel1 = 0x02 - kLevel2 = 0x03 - kLevel3 = 0x04 - kLevel4 = 0x05 - kLevel5 = 0x06 - kEmergency = 0x07 - kPlannedOutage = 0x08 - kServiceDisconnect = 0x09 - # All received enum values that are not listed above will be mapped - # to kUnknownEnumValue. This is a helper enum value that should only - # be used by code to process how it handles receiving and unknown - # enum value. This specific should never be transmitted. - kUnknownEnumValue = 10, + @dataclass + class Frequency(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000090 - class HeatingSourceEnum(MatterIntEnum): - kAny = 0x00 - kElectric = 0x01 + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000000E + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, int]) + + value: 'typing.Union[None, Nullable, int]' = None + + @dataclass + class HarmonicCurrents(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000090 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000000F + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, typing.List[ElectricalPowerMeasurement.Structs.HarmonicMeasurementStruct]]) + + value: 'typing.Union[None, Nullable, typing.List[ElectricalPowerMeasurement.Structs.HarmonicMeasurementStruct]]' = None + + @dataclass + class HarmonicPhases(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000090 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000010 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, typing.List[ElectricalPowerMeasurement.Structs.HarmonicMeasurementStruct]]) + + value: 'typing.Union[None, Nullable, typing.List[ElectricalPowerMeasurement.Structs.HarmonicMeasurementStruct]]' = None + + @dataclass + class PowerFactor(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000090 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000011 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, int]) + + value: 'typing.Union[None, Nullable, int]' = None + + @dataclass + class NeutralCurrent(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000090 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000012 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, int]) + + value: 'typing.Union[None, Nullable, int]' = None + + @dataclass + class GeneratedCommandList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000090 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFF8 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class AcceptedCommandList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000090 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFF9 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class EventList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000090 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFA + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class AttributeList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000090 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFB + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class FeatureMap(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000090 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFC + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=uint) + + value: 'uint' = 0 + + @dataclass + class ClusterRevision(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000090 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFD + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=uint) + + value: 'uint' = 0 + + class Events: + @dataclass + class MeasurementPeriodRanges(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000090 + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000000 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="ranges", Tag=0, Type=typing.List[ElectricalPowerMeasurement.Structs.MeasurementRangeStruct]), + ]) + + ranges: 'typing.List[ElectricalPowerMeasurement.Structs.MeasurementRangeStruct]' = field(default_factory=lambda: []) + + +@dataclass +class ElectricalEnergyMeasurement(Cluster): + id: typing.ClassVar[int] = 0x00000091 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="accuracy", Tag=0x00000000, Type=ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct), + ClusterObjectFieldDescriptor(Label="cumulativeEnergyImported", Tag=0x00000001, Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ClusterObjectFieldDescriptor(Label="cumulativeEnergyExported", Tag=0x00000002, Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ClusterObjectFieldDescriptor(Label="periodicEnergyImported", Tag=0x00000003, Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ClusterObjectFieldDescriptor(Label="periodicEnergyExported", Tag=0x00000004, Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ClusterObjectFieldDescriptor(Label="cumulativeEnergyReset", Tag=0x00000005, Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.CumulativeEnergyResetStruct]), + ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), + ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), + ClusterObjectFieldDescriptor(Label="eventList", Tag=0x0000FFFA, Type=typing.List[uint]), + ClusterObjectFieldDescriptor(Label="attributeList", Tag=0x0000FFFB, Type=typing.List[uint]), + ClusterObjectFieldDescriptor(Label="featureMap", Tag=0x0000FFFC, Type=uint), + ClusterObjectFieldDescriptor(Label="clusterRevision", Tag=0x0000FFFD, Type=uint), + ]) + + accuracy: 'ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct' = None + cumulativeEnergyImported: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + cumulativeEnergyExported: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + periodicEnergyImported: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + periodicEnergyExported: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + cumulativeEnergyReset: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.CumulativeEnergyResetStruct]' = None + generatedCommandList: 'typing.List[uint]' = None + acceptedCommandList: 'typing.List[uint]' = None + eventList: 'typing.List[uint]' = None + attributeList: 'typing.List[uint]' = None + featureMap: 'uint' = None + clusterRevision: 'uint' = None + + class Enums: + class MeasurementTypeEnum(MatterIntEnum): + kUnspecified = 0x00 + kVoltage = 0x01 + kActiveCurrent = 0x02 + kReactiveCurrent = 0x03 + kApparentCurrent = 0x04 + kActivePower = 0x05 + kReactivePower = 0x06 + kApparentPower = 0x07 + kRMSVoltage = 0x08 + kRMSCurrent = 0x09 + kRMSPower = 0x0A + kFrequency = 0x0B + kPowerFactor = 0x0C + kNeutralCurrent = 0x0D + kElectricalEnergy = 0x0E + # All received enum values that are not listed above will be mapped + # to kUnknownEnumValue. This is a helper enum value that should only + # be used by code to process how it handles receiving and unknown + # enum value. This specific should never be transmitted. + kUnknownEnumValue = 15, + + class Bitmaps: + class Feature(IntFlag): + kImportedEnergy = 0x1 + kExportedEnergy = 0x2 + kCumulativeEnergy = 0x4 + kPeriodicEnergy = 0x8 + + class Structs: + @dataclass + class MeasurementAccuracyRangeStruct(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="rangeMin", Tag=0, Type=int), + ClusterObjectFieldDescriptor(Label="rangeMax", Tag=1, Type=int), + ClusterObjectFieldDescriptor(Label="percentMax", Tag=2, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="percentMin", Tag=3, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="percentTypical", Tag=4, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="fixedMax", Tag=5, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="fixedMin", Tag=6, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="fixedTypical", Tag=7, Type=typing.Optional[uint]), + ]) + + rangeMin: 'int' = 0 + rangeMax: 'int' = 0 + percentMax: 'typing.Optional[uint]' = None + percentMin: 'typing.Optional[uint]' = None + percentTypical: 'typing.Optional[uint]' = None + fixedMax: 'typing.Optional[uint]' = None + fixedMin: 'typing.Optional[uint]' = None + fixedTypical: 'typing.Optional[uint]' = None + + @dataclass + class MeasurementAccuracyStruct(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="measurementType", Tag=0, Type=ElectricalEnergyMeasurement.Enums.MeasurementTypeEnum), + ClusterObjectFieldDescriptor(Label="measured", Tag=1, Type=bool), + ClusterObjectFieldDescriptor(Label="minMeasuredValue", Tag=2, Type=int), + ClusterObjectFieldDescriptor(Label="maxMeasuredValue", Tag=3, Type=int), + ClusterObjectFieldDescriptor(Label="accuracyRanges", Tag=4, Type=typing.List[ElectricalEnergyMeasurement.Structs.MeasurementAccuracyRangeStruct]), + ]) + + measurementType: 'ElectricalEnergyMeasurement.Enums.MeasurementTypeEnum' = 0 + measured: 'bool' = False + minMeasuredValue: 'int' = 0 + maxMeasuredValue: 'int' = 0 + accuracyRanges: 'typing.List[ElectricalEnergyMeasurement.Structs.MeasurementAccuracyRangeStruct]' = field(default_factory=lambda: []) + + @dataclass + class CumulativeEnergyResetStruct(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="importedResetTimestamp", Tag=0, Type=typing.Union[None, Nullable, uint]), + ClusterObjectFieldDescriptor(Label="exportedResetTimestamp", Tag=1, Type=typing.Union[None, Nullable, uint]), + ClusterObjectFieldDescriptor(Label="importedResetSystime", Tag=2, Type=typing.Union[None, Nullable, uint]), + ClusterObjectFieldDescriptor(Label="exportedResetSystime", Tag=3, Type=typing.Union[None, Nullable, uint]), + ]) + + importedResetTimestamp: 'typing.Union[None, Nullable, uint]' = None + exportedResetTimestamp: 'typing.Union[None, Nullable, uint]' = None + importedResetSystime: 'typing.Union[None, Nullable, uint]' = None + exportedResetSystime: 'typing.Union[None, Nullable, uint]' = None + + @dataclass + class EnergyMeasurementStruct(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="energy", Tag=0, Type=int), + ClusterObjectFieldDescriptor(Label="startTimestamp", Tag=1, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="endTimestamp", Tag=2, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="startSystime", Tag=3, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="endSystime", Tag=4, Type=typing.Optional[uint]), + ]) + + energy: 'int' = 0 + startTimestamp: 'typing.Optional[uint]' = None + endTimestamp: 'typing.Optional[uint]' = None + startSystime: 'typing.Optional[uint]' = None + endSystime: 'typing.Optional[uint]' = None + + class Attributes: + @dataclass + class Accuracy(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000000 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct) + + value: 'ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct' = field(default_factory=lambda: ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct()) + + @dataclass + class CumulativeEnergyImported(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000001 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]) + + value: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + + @dataclass + class CumulativeEnergyExported(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000002 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]) + + value: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + + @dataclass + class PeriodicEnergyImported(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000003 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]) + + value: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + + @dataclass + class PeriodicEnergyExported(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000004 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]) + + value: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + + @dataclass + class CumulativeEnergyReset(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000005 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.CumulativeEnergyResetStruct]) + + value: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.CumulativeEnergyResetStruct]' = None + + @dataclass + class GeneratedCommandList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFF8 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class AcceptedCommandList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFF9 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class EventList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFA + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class AttributeList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFB + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class FeatureMap(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFC + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=uint) + + value: 'uint' = 0 + + @dataclass + class ClusterRevision(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFD + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=uint) + + value: 'uint' = 0 + + class Events: + @dataclass + class CumulativeEnergyMeasured(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000000 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="energyImported", Tag=0, Type=typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ClusterObjectFieldDescriptor(Label="energyExported", Tag=1, Type=typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ]) + + energyImported: 'typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + energyExported: 'typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + + @dataclass + class PeriodicEnergyMeasured(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000001 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="energyImported", Tag=0, Type=typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ClusterObjectFieldDescriptor(Label="energyExported", Tag=1, Type=typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ]) + + energyImported: 'typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + energyExported: 'typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + + +@dataclass +class DemandResponseLoadControl(Cluster): + id: typing.ClassVar[int] = 0x00000096 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="loadControlPrograms", Tag=0x00000000, Type=typing.List[DemandResponseLoadControl.Structs.LoadControlProgramStruct]), + ClusterObjectFieldDescriptor(Label="numberOfLoadControlPrograms", Tag=0x00000001, Type=uint), + ClusterObjectFieldDescriptor(Label="events", Tag=0x00000002, Type=typing.List[DemandResponseLoadControl.Structs.LoadControlEventStruct]), + ClusterObjectFieldDescriptor(Label="activeEvents", Tag=0x00000003, Type=typing.List[DemandResponseLoadControl.Structs.LoadControlEventStruct]), + ClusterObjectFieldDescriptor(Label="numberOfEventsPerProgram", Tag=0x00000004, Type=uint), + ClusterObjectFieldDescriptor(Label="numberOfTransitions", Tag=0x00000005, Type=uint), + ClusterObjectFieldDescriptor(Label="defaultRandomStart", Tag=0x00000006, Type=uint), + ClusterObjectFieldDescriptor(Label="defaultRandomDuration", Tag=0x00000007, Type=uint), + ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), + ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), + ClusterObjectFieldDescriptor(Label="eventList", Tag=0x0000FFFA, Type=typing.List[uint]), + ClusterObjectFieldDescriptor(Label="attributeList", Tag=0x0000FFFB, Type=typing.List[uint]), + ClusterObjectFieldDescriptor(Label="featureMap", Tag=0x0000FFFC, Type=uint), + ClusterObjectFieldDescriptor(Label="clusterRevision", Tag=0x0000FFFD, Type=uint), + ]) + + loadControlPrograms: 'typing.List[DemandResponseLoadControl.Structs.LoadControlProgramStruct]' = None + numberOfLoadControlPrograms: 'uint' = None + events: 'typing.List[DemandResponseLoadControl.Structs.LoadControlEventStruct]' = None + activeEvents: 'typing.List[DemandResponseLoadControl.Structs.LoadControlEventStruct]' = None + numberOfEventsPerProgram: 'uint' = None + numberOfTransitions: 'uint' = None + defaultRandomStart: 'uint' = None + defaultRandomDuration: 'uint' = None + generatedCommandList: 'typing.List[uint]' = None + acceptedCommandList: 'typing.List[uint]' = None + eventList: 'typing.List[uint]' = None + attributeList: 'typing.List[uint]' = None + featureMap: 'uint' = None + clusterRevision: 'uint' = None + + class Enums: + class CriticalityLevelEnum(MatterIntEnum): + kUnknown = 0x00 + kGreen = 0x01 + kLevel1 = 0x02 + kLevel2 = 0x03 + kLevel3 = 0x04 + kLevel4 = 0x05 + kLevel5 = 0x06 + kEmergency = 0x07 + kPlannedOutage = 0x08 + kServiceDisconnect = 0x09 + # All received enum values that are not listed above will be mapped + # to kUnknownEnumValue. This is a helper enum value that should only + # be used by code to process how it handles receiving and unknown + # enum value. This specific should never be transmitted. + kUnknownEnumValue = 10, + + class HeatingSourceEnum(MatterIntEnum): + kAny = 0x00 + kElectric = 0x01 kNonElectric = 0x02 # All received enum values that are not listed above will be mapped # to kUnknownEnumValue. This is a helper enum value that should only @@ -25321,6 +26009,170 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'uint' = 0 +@dataclass +class PowerTopology(Cluster): + id: typing.ClassVar[int] = 0x0000009C + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="availableEndpoints", Tag=0x00000000, Type=typing.Optional[typing.List[uint]]), + ClusterObjectFieldDescriptor(Label="activeEndpoints", Tag=0x00000001, Type=typing.Optional[typing.List[uint]]), + ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), + ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), + ClusterObjectFieldDescriptor(Label="eventList", Tag=0x0000FFFA, Type=typing.List[uint]), + ClusterObjectFieldDescriptor(Label="attributeList", Tag=0x0000FFFB, Type=typing.List[uint]), + ClusterObjectFieldDescriptor(Label="featureMap", Tag=0x0000FFFC, Type=uint), + ClusterObjectFieldDescriptor(Label="clusterRevision", Tag=0x0000FFFD, Type=uint), + ]) + + availableEndpoints: 'typing.Optional[typing.List[uint]]' = None + activeEndpoints: 'typing.Optional[typing.List[uint]]' = None + generatedCommandList: 'typing.List[uint]' = None + acceptedCommandList: 'typing.List[uint]' = None + eventList: 'typing.List[uint]' = None + attributeList: 'typing.List[uint]' = None + featureMap: 'uint' = None + clusterRevision: 'uint' = None + + class Bitmaps: + class Feature(IntFlag): + kNodeTopology = 0x1 + kTreeTopology = 0x2 + kSetTopology = 0x4 + kDynamicPowerFlow = 0x8 + + class Attributes: + @dataclass + class AvailableEndpoints(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0000009C + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000000 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Optional[typing.List[uint]]) + + value: 'typing.Optional[typing.List[uint]]' = None + + @dataclass + class ActiveEndpoints(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0000009C + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000001 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Optional[typing.List[uint]]) + + value: 'typing.Optional[typing.List[uint]]' = None + + @dataclass + class GeneratedCommandList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0000009C + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFF8 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class AcceptedCommandList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0000009C + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFF9 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class EventList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0000009C + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFA + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class AttributeList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0000009C + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFB + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class FeatureMap(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0000009C + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFC + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=uint) + + value: 'uint' = 0 + + @dataclass + class ClusterRevision(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0000009C + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFD + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=uint) + + value: 'uint' = 0 + + @dataclass class EnergyEvseMode(Cluster): id: typing.ClassVar[int] = 0x0000009D diff --git a/src/controller/python/chip/clusters/__init__.py b/src/controller/python/chip/clusters/__init__.py index 47a53efde54af1..bd15d261d8962a 100644 --- a/src/controller/python/chip/clusters/__init__.py +++ b/src/controller/python/chip/clusters/__init__.py @@ -28,19 +28,19 @@ BinaryInputBasic, Binding, BooleanState, BooleanStateConfiguration, BridgedDeviceBasicInformation, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, Channel, ColorControl, ContentLauncher, Descriptor, DeviceEnergyManagement, DeviceEnergyManagementMode, DiagnosticLogs, - DishwasherAlarm, DishwasherMode, DoorLock, ElectricalEnergyMeasurement, ElectricalMeasurement, EnergyEvse, - EnergyEvseMode, EthernetNetworkDiagnostics, FanControl, FaultInjection, FixedLabel, FlowMeasurement, - FormaldehydeConcentrationMeasurement, GeneralCommissioning, GeneralDiagnostics, GroupKeyManagement, Groups, - HepaFilterMonitoring, IcdManagement, Identify, IlluminanceMeasurement, KeypadInput, LaundryDryerControls, - LaundryWasherControls, LaundryWasherMode, LevelControl, LocalizationConfiguration, LowPower, MediaInput, - MediaPlayback, MicrowaveOvenControl, MicrowaveOvenMode, ModeSelect, NetworkCommissioning, - NitrogenDioxideConcentrationMeasurement, OccupancySensing, OnOff, OnOffSwitchConfiguration, - OperationalCredentials, OperationalState, OtaSoftwareUpdateProvider, OtaSoftwareUpdateRequestor, - OvenCavityOperationalState, OvenMode, OzoneConcentrationMeasurement, Pm1ConcentrationMeasurement, - Pm10ConcentrationMeasurement, Pm25ConcentrationMeasurement, PowerSource, PowerSourceConfiguration, - PressureMeasurement, ProxyConfiguration, ProxyDiscovery, ProxyValid, PulseWidthModulation, - PumpConfigurationAndControl, RadonConcentrationMeasurement, RefrigeratorAlarm, - RefrigeratorAndTemperatureControlledCabinetMode, RelativeHumidityMeasurement, RvcCleanMode, + DishwasherAlarm, DishwasherMode, DoorLock, ElectricalEnergyMeasurement, ElectricalMeasurement, + ElectricalPowerMeasurement, EnergyEvse, EnergyEvseMode, EthernetNetworkDiagnostics, FanControl, + FaultInjection, FixedLabel, FlowMeasurement, FormaldehydeConcentrationMeasurement, GeneralCommissioning, + GeneralDiagnostics, GroupKeyManagement, Groups, HepaFilterMonitoring, IcdManagement, Identify, + IlluminanceMeasurement, KeypadInput, LaundryDryerControls, LaundryWasherControls, LaundryWasherMode, + LevelControl, LocalizationConfiguration, LowPower, MediaInput, MediaPlayback, MicrowaveOvenControl, + MicrowaveOvenMode, ModeSelect, NetworkCommissioning, NitrogenDioxideConcentrationMeasurement, + OccupancySensing, OnOff, OnOffSwitchConfiguration, OperationalCredentials, OperationalState, + OtaSoftwareUpdateProvider, OtaSoftwareUpdateRequestor, OvenCavityOperationalState, OvenMode, + OzoneConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm10ConcentrationMeasurement, + Pm25ConcentrationMeasurement, PowerSource, PowerSourceConfiguration, PressureMeasurement, ProxyConfiguration, + ProxyDiscovery, ProxyValid, PulseWidthModulation, PumpConfigurationAndControl, RadonConcentrationMeasurement, + RefrigeratorAlarm, RefrigeratorAndTemperatureControlledCabinetMode, RelativeHumidityMeasurement, RvcCleanMode, RvcOperationalState, RvcRunMode, ScenesManagement, SmokeCoAlarm, SoftwareDiagnostics, Switch, TargetNavigator, TemperatureControl, TemperatureMeasurement, Thermostat, ThermostatUserInterfaceConfiguration, ThreadNetworkDiagnostics, TimeFormatLocalization, TimeSynchronization, @@ -52,7 +52,8 @@ BinaryInputBasic, Binding, BooleanState, BooleanStateConfiguration, BridgedDeviceBasicInformation, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, Channel, ColorControl, ContentLauncher, Descriptor, DeviceEnergyManagementMode, DeviceEnergyManagement, DiagnosticLogs, DishwasherAlarm, DishwasherMode, - DoorLock, ElectricalMeasurement, ElectricalEnergyMeasurement, EnergyEvse, EnergyEvseMode, EthernetNetworkDiagnostics, FanControl, FaultInjection, FixedLabel, FlowMeasurement, + DoorLock, ElectricalEnergyMeasurement, ElectricalMeasurement, ElectricalPowerMeasurement, EnergyEvse, EnergyEvseMode, + EthernetNetworkDiagnostics, FanControl, FaultInjection, FixedLabel, FlowMeasurement, FormaldehydeConcentrationMeasurement, GeneralCommissioning, GeneralDiagnostics, GroupKeyManagement, Groups, HepaFilterMonitoring, IcdManagement, Identify, IlluminanceMeasurement, KeypadInput, LaundryDryerControls, LaundryWasherControls, LaundryWasherMode, LevelControl, LocalizationConfiguration, LowPower, MediaInput, MediaPlayback, MicrowaveOvenControl, diff --git a/src/controller/python/chip/clusters/command.cpp b/src/controller/python/chip/clusters/command.cpp index 9d718aa2aca222..87240999b360d0 100644 --- a/src/controller/python/chip/clusters/command.cpp +++ b/src/controller/python/chip/clusters/command.cpp @@ -55,24 +55,26 @@ PyChipError pychip_CommandSender_SendGroupCommand(chip::GroupId groupId, chip::C namespace chip { namespace python { -using OnCommandSenderResponseCallback = void (*)(PyObject appContext, chip::EndpointId endpointId, chip::ClusterId clusterId, +using OnCommandSenderResponseCallback = void (*)(PyObject appContext, chip::EndpointId endpointId, chip::ClusterId clusterId, chip::CommandId commandId, size_t index, std::underlying_type_t status, chip::ClusterStatus clusterStatus, const uint8_t * payload, uint32_t length); -using OnCommandSenderErrorCallback = void (*)(PyObject appContext, +using OnCommandSenderErrorCallback = void (*)(PyObject appContext, std::underlying_type_t status, chip::ClusterStatus clusterStatus, PyChipError chiperror); -using OnCommandSenderDoneCallback = void (*)(PyObject appContext); +using OnCommandSenderDoneCallback = void (*)(PyObject appContext); +using TestOnlyOnCommandSenderDoneCallback = void (*)(PyObject appContext, python::TestOnlyPyOnDoneInfo testOnlyDoneInfo); -OnCommandSenderResponseCallback gOnCommandSenderResponseCallback = nullptr; -OnCommandSenderErrorCallback gOnCommandSenderErrorCallback = nullptr; -OnCommandSenderDoneCallback gOnCommandSenderDoneCallback = nullptr; +OnCommandSenderResponseCallback gOnCommandSenderResponseCallback = nullptr; +OnCommandSenderErrorCallback gOnCommandSenderErrorCallback = nullptr; +OnCommandSenderDoneCallback gOnCommandSenderDoneCallback = nullptr; +TestOnlyOnCommandSenderDoneCallback gTestOnlyOnCommandSenderDoneCallback = nullptr; class CommandSenderCallback : public CommandSender::ExtendableCallback { public: - CommandSenderCallback(PyObject appContext, bool isBatchedCommands) : - mAppContext(appContext), mIsBatchedCommands(isBatchedCommands) + CommandSenderCallback(PyObject appContext, bool isBatchedCommands, bool callTestOnlyOnDone) : + mAppContext(appContext), mIsBatchedCommands(isBatchedCommands), mCallTestOnlyOnDone(callTestOnlyOnDone) {} void OnResponse(CommandSender * apCommandSender, const CommandSender::ResponseData & aResponseData) override @@ -148,7 +150,17 @@ class CommandSenderCallback : public CommandSender::ExtendableCallback void OnDone(CommandSender * apCommandSender) override { - gOnCommandSenderDoneCallback(mAppContext); + if (mCallTestOnlyOnDone) + { + python::TestOnlyPyOnDoneInfo testOnlyOnDoneInfo; + testOnlyOnDoneInfo.responseMessageCount = apCommandSender->GetInvokeResponseMessageCount(); + gTestOnlyOnCommandSenderDoneCallback(mAppContext, testOnlyOnDoneInfo); + } + else + { + gOnCommandSenderDoneCallback(mAppContext); + } + delete apCommandSender; delete this; }; @@ -179,6 +191,7 @@ class CommandSenderCallback : public CommandSender::ExtendableCallback PyObject mAppContext = nullptr; std::unordered_map commandRefToIndex; bool mIsBatchedCommands; + bool mCallTestOnlyOnDone; }; PyChipError SendBatchCommandsInternal(void * appContext, DeviceProxy * device, uint16_t timedRequestTimeoutMs, @@ -220,8 +233,10 @@ PyChipError SendBatchCommandsInternal(void * appContext, DeviceProxy * device, u config.SetRemoteMaxPathsPerInvoke(remoteSessionParameters.GetMaxPathsPerInvoke()); } + bool isBatchedCommands = true; + bool callTestOnlyOnDone = testOnlyOverrides != nullptr; std::unique_ptr callback = - std::make_unique(appContext, /* isBatchedCommands =*/true); + std::make_unique(appContext, isBatchedCommands, callTestOnlyOnDone); bool isTimedRequest = timedRequestTimeoutMs != 0 || testOnlySuppressTimedRequestMessage; std::unique_ptr sender = @@ -315,11 +330,13 @@ using namespace chip::python; extern "C" { void pychip_CommandSender_InitCallbacks(OnCommandSenderResponseCallback onCommandSenderResponseCallback, OnCommandSenderErrorCallback onCommandSenderErrorCallback, - OnCommandSenderDoneCallback onCommandSenderDoneCallback) + OnCommandSenderDoneCallback onCommandSenderDoneCallback, + TestOnlyOnCommandSenderDoneCallback testOnlyOnCommandSenderDoneCallback) { - gOnCommandSenderResponseCallback = onCommandSenderResponseCallback; - gOnCommandSenderErrorCallback = onCommandSenderErrorCallback; - gOnCommandSenderDoneCallback = onCommandSenderDoneCallback; + gOnCommandSenderResponseCallback = onCommandSenderResponseCallback; + gOnCommandSenderErrorCallback = onCommandSenderErrorCallback; + gOnCommandSenderDoneCallback = onCommandSenderDoneCallback; + gTestOnlyOnCommandSenderDoneCallback = testOnlyOnCommandSenderDoneCallback; } PyChipError pychip_CommandSender_SendCommand(void * appContext, DeviceProxy * device, uint16_t timedRequestTimeoutMs, @@ -331,8 +348,10 @@ PyChipError pychip_CommandSender_SendCommand(void * appContext, DeviceProxy * de VerifyOrReturnError(device->GetSecureSession().HasValue(), ToPyChipError(CHIP_ERROR_MISSING_SECURE_SESSION)); + bool isBatchedCommands = false; + bool callTestOnlyOnDone = false; std::unique_ptr callback = - std::make_unique(appContext, /* isBatchedCommands =*/false); + std::make_unique(appContext, isBatchedCommands, callTestOnlyOnDone); std::unique_ptr sender = std::make_unique(callback.get(), device->GetExchangeManager(), /* is timed request */ timedRequestTimeoutMs != 0, suppressResponse); @@ -406,8 +425,10 @@ PyChipError pychip_CommandSender_TestOnlySendCommandTimedRequestNoTimedInvoke( VerifyOrReturnError(device->GetSecureSession().HasValue(), ToPyChipError(CHIP_ERROR_MISSING_SECURE_SESSION)); + bool isBatchedCommands = false; + bool callTestOnlyOnDone = false; std::unique_ptr callback = - std::make_unique(appContext, /* isBatchedCommands =*/false); + std::make_unique(appContext, isBatchedCommands, callTestOnlyOnDone); std::unique_ptr sender = std::make_unique(callback.get(), device->GetExchangeManager(), /* is timed request */ true, suppressResponse); diff --git a/src/controller/python/chip/interaction_model/Delegate.h b/src/controller/python/chip/interaction_model/Delegate.h index 72832a7510f25e..8de5b234443210 100644 --- a/src/controller/python/chip/interaction_model/Delegate.h +++ b/src/controller/python/chip/interaction_model/Delegate.h @@ -71,6 +71,11 @@ struct TestOnlyPyBatchCommandsOverrides size_t overrideCommandRefsListLength; }; +struct TestOnlyPyOnDoneInfo +{ + size_t responseMessageCount; +}; + } // namespace python namespace Controller { diff --git a/src/controller/python/chip/interaction_model/__init__.py b/src/controller/python/chip/interaction_model/__init__.py index f7239d778058eb..61faa7f7d5d741 100644 --- a/src/controller/python/chip/interaction_model/__init__.py +++ b/src/controller/python/chip/interaction_model/__init__.py @@ -28,11 +28,11 @@ from .delegate import (AttributePath, AttributePathIBstruct, DataVersionFilterIBstruct, EventPath, EventPathIBstruct, PyInvokeRequestData, PyWriteAttributeData, SessionParameters, SessionParametersStruct, - TestOnlyPyBatchCommandsOverrides) + TestOnlyPyBatchCommandsOverrides, TestOnlyPyOnDoneInfo) __all__ = ["AttributePath", "AttributePathIBstruct", "DataVersionFilterIBstruct", "EventPath", "EventPathIBstruct", "InteractionModelError", "PyInvokeRequestData", - "PyWriteAttributeData", "SessionParameters", "SessionParametersStruct", "Status", "TestOnlyPyBatchCommandsOverrides"] + "PyWriteAttributeData", "SessionParameters", "SessionParametersStruct", "Status", "TestOnlyPyBatchCommandsOverrides", "TestOnlyPyOnDoneInfo"] # defined src/controller/python/chip/interaction_model/Delegate.h diff --git a/src/controller/python/chip/interaction_model/delegate.py b/src/controller/python/chip/interaction_model/delegate.py index d0ed641fa2a75c..14512000a63bf5 100644 --- a/src/controller/python/chip/interaction_model/delegate.py +++ b/src/controller/python/chip/interaction_model/delegate.py @@ -218,6 +218,21 @@ class TestOnlyPyBatchCommandsOverrides(ctypes.Structure): ('overrideCommandRefsList', POINTER(ctypes.c_uint16)), ('overrideCommandRefsListLength', ctypes.c_size_t)] +class TestOnlyPyOnDoneInfo(ctypes.Structure): + ''' TestOnly struct for overriding aspects of batch command to send invalid commands. + + We are using the following struct for passing the information of TestOnlyPyBatchCommandsOverrides between Python and C++: + + ```c + struct TestOnlyPyOnDoneInfo + { + size_t responseMessageCount; + }; + ``` + ''' + _fields_ = [('responseMessageCount', ctypes.c_size_t)] + + # typedef void (*PythonInteractionModelDelegate_OnCommandResponseStatusCodeReceivedFunct)(uint64_t commandSenderPtr, # void * commandStatusBuf); # typedef void (*PythonInteractionModelDelegate_OnCommandResponseProtocolErrorFunct)(uint64_t commandSenderPtr, diff --git a/src/controller/tests/data_model/BUILD.gn b/src/controller/tests/data_model/BUILD.gn index 3c04f0012f59c6..e7621af5b0359a 100644 --- a/src/controller/tests/data_model/BUILD.gn +++ b/src/controller/tests/data_model/BUILD.gn @@ -34,6 +34,7 @@ chip_test_suite_using_nltest("data_model") { "${chip_root}/src/app/common:cluster-objects", "${chip_root}/src/app/tests:helpers", "${chip_root}/src/app/util/mock:mock_ember", + "${chip_root}/src/controller", "${chip_root}/src/lib/support:testing_nlunit", "${chip_root}/src/messaging/tests:helpers", "${chip_root}/src/transport/raw/tests:helpers", diff --git a/src/credentials/BUILD.gn b/src/credentials/BUILD.gn index cd12f485e32009..df7afc0c1025ba 100644 --- a/src/credentials/BUILD.gn +++ b/src/credentials/BUILD.gn @@ -63,7 +63,9 @@ static_library("credentials") { "CHIPCert.h", "CHIPCertFromX509.cpp", "CHIPCertToX509.cpp", + "CHIPCert_Internal.h", "CHIPCertificateSet.h", + "CertificateValidityPolicy.h", "CertificationDeclaration.cpp", "CertificationDeclaration.h", "DeviceAttestationConstructor.cpp", @@ -76,6 +78,7 @@ static_library("credentials") { "GenerateChipX509Cert.cpp", "GroupDataProvider.h", "GroupDataProviderImpl.cpp", + "GroupDataProviderImpl.h", "LastKnownGoodTime.cpp", "LastKnownGoodTime.h", "OperationalCertificateStore.h", @@ -122,6 +125,7 @@ static_library("credentials") { public_deps = [ ":build_time_header", + "${chip_root}/src/controller:delegates", "${chip_root}/src/crypto", "${chip_root}/src/lib/asn1", "${chip_root}/src/lib/core", diff --git a/src/credentials/tests/BUILD.gn b/src/credentials/tests/BUILD.gn index 101abc31dd890e..3b0458233ac757 100644 --- a/src/credentials/tests/BUILD.gn +++ b/src/credentials/tests/BUILD.gn @@ -70,6 +70,7 @@ chip_test_suite_using_nltest("tests") { "${chip_root}/src/credentials", "${chip_root}/src/credentials:default_attestation_verifier", "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support:testing", "${chip_root}/src/lib/support:testing_nlunit", "${nlunit_test_root}:nlunit-test", ] diff --git a/src/crypto/tests/BUILD.gn b/src/crypto/tests/BUILD.gn index 55fc502484c681..1599b942269ae6 100644 --- a/src/crypto/tests/BUILD.gn +++ b/src/crypto/tests/BUILD.gn @@ -69,6 +69,7 @@ chip_test_suite_using_nltest("tests") { "${chip_root}/src/credentials/tests:cert_test_vectors", "${chip_root}/src/crypto", "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support:testing", "${chip_root}/src/lib/support:testing_nlunit", "${chip_root}/src/platform", "${nlunit_test_root}:nlunit-test", diff --git a/src/darwin/Framework/CHIP/MTRCallbackBridgeBase.h b/src/darwin/Framework/CHIP/MTRCallbackBridgeBase.h index ab6565518f1902..d113b5dedc86a1 100644 --- a/src/darwin/Framework/CHIP/MTRCallbackBridgeBase.h +++ b/src/darwin/Framework/CHIP/MTRCallbackBridgeBase.h @@ -215,6 +215,8 @@ class MTRCallbackBridge : public MTRCallbackBridgeBase { } if (!callbackBridge->mQueue) { + ChipLogDetail(Controller, "%s %f seconds: can't dispatch response; no queue", callbackBridge->mCookie.UTF8String, + -[callbackBridge->mRequestTime timeIntervalSinceNow]); if (!callbackBridge->mKeepAlive) { delete callbackBridge; } diff --git a/src/darwin/Framework/CHIP/MTRClusterNames.h b/src/darwin/Framework/CHIP/MTRClusterNames.h new file mode 100644 index 00000000000000..f4134205228d90 --- /dev/null +++ b/src/darwin/Framework/CHIP/MTRClusterNames.h @@ -0,0 +1,43 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#import +#import + +/** + * This file defines functions to resolve Matter cluster and attribute IDs into + * strings. + */ + +/** + * Resolve Matter cluster IDs into a descriptive string. + * + * For unknown IDs, a string '' will be returned. + */ +MTR_EXTERN MTR_NEWLY_AVAILABLE NSString * MTRClusterNameForID(MTRClusterIDType clusterID); + +/** + * Resolve Matter attribute IDs into a descriptive string. + * + * For unknown IDs, a string '' (if the cluster ID is not known) + * or '' (if the cluster ID is known but the attribute ID is not known) + * will be returned. + */ +MTR_EXTERN MTR_NEWLY_AVAILABLE NSString * MTRAttributeNameForID(MTRClusterIDType clusterID, MTRAttributeIDType attributeID); diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.h b/src/darwin/Framework/CHIP/MTRDeviceController.h index a3757e6353f796..ea2f6497a45edb 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.h +++ b/src/darwin/Framework/CHIP/MTRDeviceController.h @@ -22,6 +22,7 @@ #import @class MTRBaseDevice; +@class MTRServerEndpoint; // Defined in MTRServerEndpoint.h, which imports MTRAccessGrant.h, which imports MTRBaseClusters.h, which imports this file, so we can't import it. #if MTR_PER_CONTROLLER_STORAGE_ENABLED @class MTRDeviceControllerAbstractParameters; @@ -228,6 +229,29 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) - (NSData * _Nullable)attestationChallengeForDeviceID:(NSNumber *)deviceID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +/** + * Add a server endpoint for this controller. The endpoint starts off enabled. + * + * Will fail in the following cases: + * + * 1) There is already an endpoint defined with the given endpoint id. + * 2) There are too many endpoints defined already. + */ +- (BOOL)addServerEndpoint:(MTRServerEndpoint *)endpoint MTR_NEWLY_AVAILABLE; + +/** + * Remove the given server endpoint from this controller. If the endpoint is + * not attached to this controller, will just call the completion and do nothing + * else. + */ +- (void)removeServerEndpoint:(MTRServerEndpoint *)endpoint queue:(dispatch_queue_t)queue completion:(dispatch_block_t)completion MTR_NEWLY_AVAILABLE; + +/** + * Remove the given server endpoint without being notified when the removal + * completes. + */ +- (void)removeServerEndpoint:(MTRServerEndpoint *)endpoint MTR_NEWLY_AVAILABLE; + /** * Compute a PASE verifier for the desired setup passcode. * diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index decd879a657ef3..9621b447fb49b1 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -41,6 +41,7 @@ #import "MTROperationalCredentialsDelegate.h" #import "MTRP256KeypairBridge.h" #import "MTRPersistentStorageDelegateBridge.h" +#import "MTRServerEndpoint_Internal.h" #import "MTRSetupPayload.h" #import "NSDataSpanConversion.h" #import "NSStringSpanConversion.h" @@ -55,6 +56,7 @@ #include #include +#include #include #include #include @@ -62,6 +64,7 @@ #include #include #include +#include #include #include #include @@ -69,6 +72,7 @@ #include #include +#include #import @@ -121,6 +125,9 @@ @implementation MTRDeviceController { os_unfair_lock _deviceMapLock; // protects nodeIDToDeviceMap MTRCommissionableBrowser * _commissionableBrowser; MTRAttestationTrustStoreBridge * _attestationTrustStoreBridge; + + // _serverEndpoints is only touched on the Matter queue. + NSMutableArray * _serverEndpoints; } - (nullable instancetype)initWithParameters:(MTRDeviceControllerAbstractParameters *)parameters error:(NSError * __autoreleasing *)error @@ -221,6 +228,7 @@ - (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory _factory = factory; _deviceMapLock = OS_UNFAIR_LOCK_INIT; _nodeIDToDeviceMap = [NSMutableDictionary dictionary]; + _serverEndpoints = [[NSMutableArray alloc] init]; _commissionableBrowser = nil; _deviceControllerDelegateBridge = new MTRDeviceControllerDelegateBridge(); @@ -285,6 +293,11 @@ - (void)shutDownCppController { assertChipStackLockedByCurrentThread(); + // Shut down all our endpoints. + for (MTRServerEndpoint * endpoint in [_serverEndpoints copy]) { + [self removeServerEndpointOnMatterQueue:endpoint]; + } + if (_cppCommissioner) { auto * commissionerToShutDown = _cppCommissioner; // Flag ourselves as not running before we start shutting down @@ -947,6 +960,71 @@ - (NSData * _Nullable)attestationChallengeForDeviceID:(NSNumber *)deviceID return [self syncRunOnWorkQueueWithReturnValue:block error:nil]; } +- (BOOL)addServerEndpoint:(MTRServerEndpoint *)endpoint +{ + VerifyOrReturnValue([self checkIsRunning], NO); + + if (![_factory addServerEndpoint:endpoint]) { + return NO; + } + + if (![endpoint associateWithController:self]) { + MTR_LOG_ERROR("Failed to associate MTRServerEndpoint with MTRDeviceController"); + [_factory removeServerEndpoint:endpoint]; + return NO; + } + + [self asyncDispatchToMatterQueue:^() { + [self->_serverEndpoints addObject:endpoint]; + [endpoint registerMatterEndpoint]; + } + errorHandler:^(NSError * error) { + MTR_LOG_ERROR("Unexpected failure dispatching to Matter queue on running controller in addServerEndpoint"); + }]; + return YES; +} + +- (void)removeServerEndpoint:(MTRServerEndpoint *)endpoint queue:(dispatch_queue_t)queue completion:(dispatch_block_t)completion +{ + [self removeServerEndpointInternal:endpoint queue:queue completion:completion]; +} + +- (void)removeServerEndpoint:(MTRServerEndpoint *)endpoint +{ + [self removeServerEndpointInternal:endpoint queue:nil completion:nil]; +} + +- (void)removeServerEndpointInternal:(MTRServerEndpoint *)endpoint queue:(dispatch_queue_t _Nullable)queue completion:(dispatch_block_t _Nullable)completion +{ + VerifyOrReturn([self checkIsRunning]); + + // We need to unhook the endpoint from the Matter side before we can start + // tearing it down. + [self asyncDispatchToMatterQueue:^() { + [self removeServerEndpointOnMatterQueue:endpoint]; + if (queue != nil && completion != nil) { + dispatch_async(queue, completion); + } + } + errorHandler:^(NSError * error) { + // Error means we got shut down, so the endpoint is removed now. + if (queue != nil && completion != nil) { + dispatch_async(queue, completion); + } + }]; +} + +- (void)removeServerEndpointOnMatterQueue:(MTRServerEndpoint *)endpoint +{ + assertChipStackLockedByCurrentThread(); + + [endpoint unregisterMatterEndpoint]; + [_serverEndpoints removeObject:endpoint]; + [endpoint invalidate]; + + [_factory removeServerEndpoint:endpoint]; +} + - (BOOL)checkForInitError:(BOOL)condition logMsg:(NSString *)logMsg { if (condition) { @@ -1230,6 +1308,52 @@ - (void)downloadLogFromNodeWithID:(NSNumber *)nodeID completion:completion]; } +- (NSArray *)accessGrantsForClusterPath:(MTRClusterPath *)clusterPath +{ + assertChipStackLockedByCurrentThread(); + + for (MTRServerEndpoint * endpoint in _serverEndpoints) { + if ([clusterPath.endpoint isEqual:endpoint.endpointID]) { + return [endpoint matterAccessGrantsForCluster:clusterPath.cluster]; + } + } + + // Nothing matched, no grants. + return @[]; +} + +- (nullable NSNumber *)neededReadPrivilegeForClusterID:(NSNumber *)clusterID attributeID:(NSNumber *)attributeID +{ + assertChipStackLockedByCurrentThread(); + + for (MTRServerEndpoint * endpoint in _serverEndpoints) { + for (MTRServerCluster * cluster in endpoint.serverClusters) { + if (![cluster.clusterID isEqual:clusterID]) { + continue; + } + + for (MTRServerAttribute * attr in cluster.attributes) { + if (![attr.attributeID isEqual:attributeID]) { + continue; + } + + return @(attr.requiredReadPrivilege); + } + } + } + + return nil; +} + +#ifdef DEBUG ++ (void)forceLocalhostAdvertisingOnly +{ + auto interfaceIndex = chip::Inet::InterfaceId::PlatformType(kDNSServiceInterfaceIndexLocalOnly); + auto interfaceId = chip::Inet::InterfaceId(interfaceIndex); + chip::app::DnssdServer::Instance().SetInterfaceId(interfaceId); +} +#endif // DEBUG + @end /** diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm b/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm index 319c33fdac999e..457abeaed55a5f 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm @@ -25,6 +25,9 @@ #import "MTRDeviceControllerParameters_Wrapper.h" #endif // MTR_PER_CONTROLLER_STORAGE_ENABLED +#import +#import + #import "MTRCertificates.h" #import "MTRDemuxingStorage.h" #import "MTRDeviceController.h" @@ -40,12 +43,15 @@ #import "MTROperationalBrowser.h" #import "MTRP256KeypairBridge.h" #import "MTRPersistentStorageDelegateBridge.h" +#import "MTRServerAccessControl.h" +#import "MTRServerCluster_Internal.h" +#import "MTRServerEndpoint_Internal.h" #import "MTRSessionResumptionStorageBridge.h" #import "NSDataSpanConversion.h" #import -#include +#include #include #include #include @@ -75,12 +81,14 @@ static bool sExitHandlerRegistered = false; static void ShutdownOnExit() { [[MTRDeviceControllerFactory sharedInstance] stopControllerFactory]; } -@interface MTRDeviceControllerFactory () +@interface MTRDeviceControllerFactory () { + MTRServerEndpoint * _otaProviderEndpoint; + std::unique_ptr _otaProviderDelegateBridge; +} @property (atomic, readonly) dispatch_queue_t chipWorkQueue; @property (readonly) DeviceControllerFactory * controllerFactory; @property (readonly) PersistentStorageDelegate * persistentStorageDelegate; -@property (readonly) MTROTAProviderDelegateBridge * otaProviderDelegateBridge; @property (readonly) Crypto::RawKeySessionKeystore * sessionKeystore; // We use TestPersistentStorageDelegate just to get an in-memory store to back // our group data provider impl. We initialize this store correctly on every @@ -170,6 +178,11 @@ @implementation MTRDeviceControllerFactory { // is only accessed on the Matter queue or after the Matter queue has shut // down. FabricIndex _nextAvailableFabricIndex; + + // Array of all server endpoints across all controllers, used to ensure + // in an atomic way that endpoint IDs are unique. + NSMutableArray * _serverEndpoints; + os_unfair_lock _serverEndpointsLock; // Protects access to _serverEndpoints. } + (void)initialize @@ -232,6 +245,9 @@ - (instancetype)init return nil; } + _serverEndpoints = [[NSMutableArray alloc] init]; + _serverEndpointsLock = OS_UNFAIR_LOCK_INIT; + return self; } @@ -319,10 +335,6 @@ - (void)cleanupStartupObjects _keystore = nullptr; } - if (_otaProviderDelegateBridge) { - delete _otaProviderDelegateBridge; - _otaProviderDelegateBridge = nullptr; - } _otaProviderDelegateQueue = nil; _otaProviderDelegate = nil; @@ -410,7 +422,7 @@ - (BOOL)startControllerFactory:(MTRDeviceControllerFactoryParams *)startupParams return; } - app::dynamic_server::InitAccessControl(); + InitializeServerAccessControl(); if (startupParams.hasStorage) { _persistentStorageDelegate = new (std::nothrow) MTRPersistentStorageDelegateBridge(startupParams.storage); @@ -439,7 +451,6 @@ - (BOOL)startControllerFactory:(MTRDeviceControllerFactoryParams *)startupParams _otaProviderDelegateQueue = dispatch_queue_create( "org.csa-iot.matter.framework.otaprovider.workqueue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL); } - _otaProviderDelegateBridge = new MTROTAProviderDelegateBridge(); // TODO: Allow passing a different keystore implementation via startupParams. _keystore = new PersistentStorageOperationalKeystore(); @@ -900,11 +911,44 @@ - (MTRDeviceController * _Nullable)maybeInitializeOTAProvider:(MTRDeviceControll { [self _assertCurrentQueueIsNotMatterQueue]; - VerifyOrReturnValue(_otaProviderDelegateBridge != nil, controller); VerifyOrReturnValue([_controllers count] == 1, controller); + _otaProviderEndpoint = [MTRServerEndpoint rootNodeEndpoint]; + + // TODO: Have the OTA Provider cluster revision accessible somewhere? + auto * otaProviderCluster = [[MTRServerCluster alloc] initWithClusterID:@(MTRClusterIDTypeOTASoftwareUpdateProviderID) revision:@(1)]; + otaProviderCluster.acceptedCommands = @[ + @(MTRCommandIDTypeClusterOTASoftwareUpdateProviderCommandQueryImageID), + @(MTRCommandIDTypeClusterOTASoftwareUpdateProviderCommandApplyUpdateRequestID), + @(MTRCommandIDTypeClusterOTASoftwareUpdateProviderCommandNotifyUpdateAppliedID), + ]; + otaProviderCluster.generatedCommands = @[ + @(MTRCommandIDTypeClusterOTASoftwareUpdateProviderCommandQueryImageResponseID), + @(MTRCommandIDTypeClusterOTASoftwareUpdateProviderCommandApplyUpdateResponseID), + ]; + [otaProviderCluster addAccessGrant:[MTRAccessGrant accessGrantForAllNodesWithPrivilege:MTRAccessControlEntryPrivilegeOperate]]; + + // Not expected to fail, since we are following the rules for clusters here. + [_otaProviderEndpoint addServerCluster:otaProviderCluster]; + + if (![self addServerEndpoint:_otaProviderEndpoint]) { + MTR_LOG_ERROR("Failed to add OTA endpoint on factory. Why?"); + [controller shutdown]; + return nil; + } + + // This endpoint is not actually associated with a specific controller; we + // just need to have a working Matter event loop to bring it up. + [_otaProviderEndpoint associateWithController:nil]; + __block CHIP_ERROR err; dispatch_sync(_chipWorkQueue, ^{ + [self->_otaProviderEndpoint registerMatterEndpoint]; + + // Now that our endpoint exists, go ahead and create the OTA delegate + // bridge. Its constructor relies on the endpoint existing. + _otaProviderDelegateBridge = std::make_unique(); + auto systemState = _controllerFactory->GetSystemState(); err = _otaProviderDelegateBridge->Init(systemState->SystemLayer(), systemState->ExchangeMgr()); }); @@ -982,6 +1026,16 @@ - (void)controllerShuttingDown:(MTRDeviceController *)controller if (_otaProviderDelegateBridge) { _otaProviderDelegateBridge->Shutdown(); + _otaProviderDelegateBridge.reset(); + } + + if (_otaProviderEndpoint != nil) { + [_otaProviderEndpoint unregisterMatterEndpoint]; + [_otaProviderEndpoint invalidate]; + + [self removeServerEndpoint:_otaProviderEndpoint]; + + _otaProviderEndpoint = nil; } sharedCleanupBlock(); @@ -1071,6 +1125,94 @@ - (nullable MTRDeviceController *)runningControllerForFabricIndex:(chip::FabricI return [self runningControllerForFabricIndex:fabricIndex includeControllerStartingUp:YES includeControllerShuttingDown:YES]; } +- (BOOL)addServerEndpoint:(MTRServerEndpoint *)endpoint +{ + os_unfair_lock_lock(&_serverEndpointsLock); + if (_serverEndpoints.count == CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT) { + os_unfair_lock_unlock(&_serverEndpointsLock); + + MTR_LOG_ERROR("Can't add a server endpoint with endpoint ID %u, because we already have %u endpoints defined", static_cast(endpoint.endpointID.unsignedLongLongValue), CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT); + + return NO; + } + + BOOL haveExisting = NO; + for (MTRServerEndpoint * existing in _serverEndpoints) { + if ([endpoint.endpointID isEqual:existing.endpointID]) { + haveExisting = YES; + break; + } + } + + if (!haveExisting) { + [_serverEndpoints addObject:endpoint]; + } + os_unfair_lock_unlock(&_serverEndpointsLock); + + if (haveExisting) { + MTR_LOG_ERROR("Trying to add a server endpoint with endpoint ID %u, which already exists", static_cast(endpoint.endpointID.unsignedLongLongValue)); + } + + return !haveExisting; +} + +- (void)removeServerEndpoint:(MTRServerEndpoint *)endpoint +{ + os_unfair_lock_lock(&_serverEndpointsLock); + [_serverEndpoints removeObject:endpoint]; + os_unfair_lock_unlock(&_serverEndpointsLock); +} + +- (NSArray *)accessGrantsForFabricIndex:(chip::FabricIndex)fabricIndex clusterPath:(MTRClusterPath *)clusterPath +{ + assertChipStackLockedByCurrentThread(); + + if ([clusterPath.endpoint isEqual:_otaProviderEndpoint.endpointID]) { + return [_otaProviderEndpoint matterAccessGrantsForCluster:clusterPath.cluster]; + } + + // We do not want to use _serverEndpoints here, because that might contain + // endpoints that are still being set up and whatnot. Ask the controller + // for the relevant fabric index what the relevant access grants are. + + // Include controllers that are shutting down, since this may be an accesss + // check for event reports they emit as they shut down. + auto * controller = [self runningControllerForFabricIndex:fabricIndex includeControllerStartingUp:NO includeControllerShuttingDown:YES]; + if (controller == nil) { + return @[]; + } + + return [controller accessGrantsForClusterPath:clusterPath]; +} + +- (nullable NSNumber *)neededReadPrivilegeForClusterID:(NSNumber *)clusterID attributeID:(NSNumber *)attributeID +{ + assertChipStackLockedByCurrentThread(); + + for (MTRServerCluster * cluster in _otaProviderEndpoint.serverClusters) { + if (![cluster.clusterID isEqual:clusterID]) { + continue; + } + + for (MTRServerAttribute * attr in cluster.attributes) { + if (![attr.attributeID isEqual:attributeID]) { + continue; + } + + return @(attr.requiredReadPrivilege); + } + } + + for (MTRDeviceController * controller in [self getRunningControllers]) { + NSNumber * _Nullable neededPrivilege = [controller neededReadPrivilegeForClusterID:clusterID attributeID:attributeID]; + if (neededPrivilege != nil) { + return neededPrivilege; + } + } + + return nil; +} + - (void)downloadLogFromNodeWithID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller type:(MTRDiagnosticLogType)type diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerFactory_Internal.h b/src/darwin/Framework/CHIP/MTRDeviceControllerFactory_Internal.h index e41300127be59e..4e0290bc041860 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerFactory_Internal.h +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerFactory_Internal.h @@ -20,9 +20,12 @@ */ #import +#import +#import // for MTRClusterPath #import #import #import +#import #if MTR_PER_CONTROLLER_STORAGE_ENABLED #import @@ -93,6 +96,38 @@ NS_ASSUME_NONNULL_BEGIN withParameters:(MTRDeviceControllerParameters *)parameters error:(NSError * __autoreleasing *)error; +/** + * Add a server endpoint. This will verify that there is no existing server + * endpoint with the provided endpoint ID and return NO if there is one. Can be + * called on any thread. + */ +- (BOOL)addServerEndpoint:(MTRServerEndpoint *)endpoint; + +/** + * Remove a server endpoint. This must happen after all other teardown for the + * endpoint is complete. Can be called on any thread. + */ +- (void)removeServerEndpoint:(MTRServerEndpoint *)endpoint; + +/** + * Get the access grants that apply for the given fabric index and cluster path. + * + * Only called on the Matter queue. + */ +- (NSArray *)accessGrantsForFabricIndex:(chip::FabricIndex)fabricIndex clusterPath:(MTRClusterPath *)clusterPath; + +/** + * Get the privilege level needed to read the given attribute. There's no + * endpoint provided because the expectation is that this information is the + * same for all cluster instances. + * + * Returns nil if we have no such attribute defined on any endpoint, otherwise + * one of MTRAccessControlEntry* constants wrapped in NSNumber. + * + * Only called on the Matter queue. + */ +- (nullable NSNumber *)neededReadPrivilegeForClusterID:(NSNumber *)clusterID attributeID:(NSNumber *)attributeID; + @property (readonly) chip::PersistentStorageDelegate * storageDelegate; @property (readonly) chip::Credentials::GroupDataProvider * groupData; diff --git a/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h b/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h index 92873cf4016b9e..b55d41b8d8a59e 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h +++ b/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h @@ -20,6 +20,8 @@ */ #import +#import +#import // for MTRClusterPath #import "MTRDeviceConnectionBridge.h" // For MTRInternalDeviceConnectionCallback #import "MTRDeviceController.h" @@ -243,6 +245,23 @@ NS_ASSUME_NONNULL_BEGIN queue:(dispatch_queue_t)queue completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion; +/** + * Get the access grants that apply for the given cluster path. + */ +- (NSArray *)accessGrantsForClusterPath:(MTRClusterPath *)clusterPath; + +/** + * Get the privilege level needed to read the given attribute. There's no + * endpoint provided because the expectation is that this information is the + * same for all cluster instances. + * + * Returns nil if we have no such attribute defined on any endpoint, otherwise + * one of MTRAccessControlEntry* constants wrapped in NSNumber. + * + * Only called on the Matter queue. + */ +- (nullable NSNumber *)neededReadPrivilegeForClusterID:(NSNumber *)clusterID attributeID:(NSNumber *)attributeID; + #pragma mark - Device-specific data and SDK access // DeviceController will act as a central repository for this opaque dictionary that MTRDevice manages - (MTRDevice *)deviceForNodeID:(NSNumber *)nodeID; diff --git a/src/darwin/Framework/CHIP/Matter.h b/src/darwin/Framework/CHIP/Matter.h index 37b72902281b1c..ebbe1b3765917c 100644 --- a/src/darwin/Framework/CHIP/Matter.h +++ b/src/darwin/Framework/CHIP/Matter.h @@ -29,6 +29,7 @@ #import #import #import +#import #import #import #import diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRIMDispatch.mm b/src/darwin/Framework/CHIP/ServerEndpoint/MTRIMDispatch.mm new file mode 100644 index 00000000000000..a1f1f47a7dc26e --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRIMDispatch.mm @@ -0,0 +1,104 @@ +/** + * Copyright (c) 2024 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters; + +void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) +{ + assertChipStackLockedByCurrentThread(); + + // No-op: Descriptor and OTA do not need this, and our client-defined + // clusters dont use it. +} + +EmberAfStatus emAfWriteAttributeExternal(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr, + EmberAfAttributeType dataType) +{ + assertChipStackLockedByCurrentThread(); + + // All of our attributes are handled via AttributeAccessInterface, so this + // should be unreached. + return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE; +} + +namespace chip { +namespace app { + + void DispatchSingleClusterCommand(const ConcreteCommandPath & aPath, TLV::TLVReader & aReader, CommandHandler * aCommandObj) + { + // TODO: Consider having MTRServerCluster register a + // CommandHandlerInterface for command dispatch. But OTA would need + // some special-casing in any case, to call into the existing cluster + // implementation. + using Protocols::InteractionModel::Status; + // This command passed ServerClusterCommandExists so we know it's one of our + // supported commands. + using namespace OtaSoftwareUpdateProvider::Commands; + + bool wasHandled = false; + CHIP_ERROR err = CHIP_NO_ERROR; + + switch (aPath.mCommandId) { + case QueryImage::Id: { + QueryImage::DecodableType commandData; + err = DataModel::Decode(aReader, commandData); + if (err == CHIP_NO_ERROR) { + wasHandled = emberAfOtaSoftwareUpdateProviderClusterQueryImageCallback(aCommandObj, aPath, commandData); + } + break; + } + case ApplyUpdateRequest::Id: { + ApplyUpdateRequest::DecodableType commandData; + err = DataModel::Decode(aReader, commandData); + if (err == CHIP_NO_ERROR) { + wasHandled = emberAfOtaSoftwareUpdateProviderClusterApplyUpdateRequestCallback(aCommandObj, aPath, commandData); + } + break; + } + case NotifyUpdateApplied::Id: { + NotifyUpdateApplied::DecodableType commandData; + err = DataModel::Decode(aReader, commandData); + if (err == CHIP_NO_ERROR) { + wasHandled = emberAfOtaSoftwareUpdateProviderClusterNotifyUpdateAppliedCallback(aCommandObj, aPath, commandData); + } + break; + } + default: + break; + } + + if (CHIP_NO_ERROR != err || !wasHandled) { + aCommandObj->AddStatus(aPath, Status::InvalidCommand); + } + } + +} // namespace app +} // namespace chip diff --git a/src/inet/tests/TapAddrAutoconf.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAccessControl.h similarity index 62% rename from src/inet/tests/TapAddrAutoconf.h rename to src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAccessControl.h index 8b1d8c9bd75f5f..49d542a38ce745 100644 --- a/src/inet/tests/TapAddrAutoconf.h +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAccessControl.h @@ -1,8 +1,5 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. +/** + * Copyright (c) 2024 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. @@ -17,12 +14,15 @@ * limitations under the License. */ +#import +#import + +NS_ASSUME_NONNULL_BEGIN + /** - * @file - * This file defines functions for taking configuration for the LwIP stack - * from the corresponding configuration on the tap interface. + * Initialize the access control module. Must be called on the Matter task + * queue. */ +void InitializeServerAccessControl(); -#include - -int CollectTapAddresses(std::vector & addresses, const char * ifName); +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAccessControl.mm b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAccessControl.mm new file mode 100644 index 00000000000000..984716511a7495 --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAccessControl.mm @@ -0,0 +1,192 @@ +/** + * Copyright (c) 2024 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "MTRServerAccessControl.h" + +#import +#import // for MTRClusterPath +#import + +#import "MTRDeviceControllerFactory_Internal.h" +#import "MTRLogging_Internal.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace chip; +using namespace chip::Access; + +namespace { + +class DeviceTypeResolver : public Access::AccessControl::DeviceTypeResolver { +public: + bool IsDeviceTypeOnEndpoint(DeviceTypeId deviceType, EndpointId endpoint) override + { + return app::IsDeviceTypeOnEndpoint(deviceType, endpoint); + } +}; + +class AccessControlDelegate : public AccessControl::Delegate { + CHIP_ERROR Check(const SubjectDescriptor & subjectDescriptor, const RequestPath & requestPath, + Privilege requestPrivilege) override + { + auto * clusterPath = [MTRClusterPath clusterPathWithEndpointID:@(requestPath.endpoint) clusterID:@(requestPath.cluster)]; + auto * grants = [[MTRDeviceControllerFactory sharedInstance] accessGrantsForFabricIndex:subjectDescriptor.fabricIndex clusterPath:clusterPath]; + + for (MTRAccessGrant * grant in grants) { + if (!GrantSubjectMatchesDescriptor(grant, subjectDescriptor)) { + continue; + } + + // Check whether the desired privilege is granted. See the Access Control "Overall + // Algorithm" section in the spec for which privileges imply which other privileges. + switch (grant.grantedPrivilege) { + case MTRAccessControlEntryPrivilegeView: + if (requestPrivilege == Privilege::kView) { + return CHIP_NO_ERROR; + } + break; + case MTRAccessControlEntryPrivilegeProxyView: + if (requestPrivilege == Privilege::kView || requestPrivilege == Privilege::kProxyView) { + return CHIP_NO_ERROR; + } + break; + case MTRAccessControlEntryPrivilegeOperate: + if (requestPrivilege == Privilege::kView || requestPrivilege == Privilege::kOperate) { + return CHIP_NO_ERROR; + } + break; + case MTRAccessControlEntryPrivilegeManage: + if (requestPrivilege == Privilege::kView || requestPrivilege == Privilege::kOperate || requestPrivilege == Privilege::kManage) { + return CHIP_NO_ERROR; + } + break; + case MTRAccessControlEntryPrivilegeAdminister: + if (requestPrivilege == Privilege::kView || requestPrivilege == Privilege::kProxyView || requestPrivilege == Privilege::kOperate || requestPrivilege == Privilege::kManage || requestPrivilege == Privilege::kAdminister) { + return CHIP_NO_ERROR; + } + break; + default: + MTR_LOG_ERROR("Uknown granted privilege %u, ignoring", grant.grantedPrivilege); + break; + } + + // If this grant did not match, just move on to the next one. + } + + // None of the grants matched. + return CHIP_ERROR_ACCESS_DENIED; + } + + bool GrantSubjectMatchesDescriptor(MTRAccessGrant * grant, const SubjectDescriptor & descriptor) + { + if (grant.subjectID == nil) { + // This is an all-nodes grant for CASE access only. + return descriptor.authMode == AuthMode::kCase; + } + + NodeId grantSubjectNodeId = grant.subjectID.unsignedLongLongValue; + if (IsOperationalNodeId(grantSubjectNodeId)) { + return descriptor.authMode == AuthMode::kCase && descriptor.subject == grantSubjectNodeId; + } + + if (IsGroupId(grantSubjectNodeId)) { + return descriptor.authMode == AuthMode::kGroup && descriptor.subject == grantSubjectNodeId; + } + + if (IsCASEAuthTag(grantSubjectNodeId)) { + return descriptor.cats.CheckSubjectAgainstCATs(grantSubjectNodeId); + } + + MTR_LOG_ERROR("Unexpected grant subject: 0x%llx", grantSubjectNodeId); + return false; + } +}; + +struct ControllerAccessControl { + DeviceTypeResolver mDeviceTypeResolver; + AccessControlDelegate mDelegate; + ControllerAccessControl() { GetAccessControl().Init(&mDelegate, mDeviceTypeResolver); } +}; + +Global gControllerAccessControl; + +} // anonymous namespace + +int MatterGetAccessPrivilegeForReadEvent(ClusterId cluster, EventId event) +{ + // We don't support any event bits yet. + return kMatterAccessPrivilegeAdminister; +} + +int MatterGetAccessPrivilegeForInvokeCommand(ClusterId cluster, CommandId command) +{ + // For now we only have OTA, which uses Operate. + return kMatterAccessPrivilegeOperate; +} + +int MatterGetAccessPrivilegeForReadAttribute(ClusterId cluster, AttributeId attribute) +{ + NSNumber * _Nullable neededPrivilege = [[MTRDeviceControllerFactory sharedInstance] neededReadPrivilegeForClusterID:@(cluster) attributeID:@(attribute)]; + if (neededPrivilege == nil) { + // No privileges declared for this attribute on this cluster. Treat as + // "needs admin privileges", so we fail closed. + return kMatterAccessPrivilegeAdminister; + } + + switch (neededPrivilege.unsignedLongLongValue) { + case MTRAccessControlEntryPrivilegeView: + return kMatterAccessPrivilegeView; + case MTRAccessControlEntryPrivilegeOperate: + return kMatterAccessPrivilegeOperate; + case MTRAccessControlEntryPrivilegeManage: + return kMatterAccessPrivilegeManage; + case MTRAccessControlEntryPrivilegeAdminister: + return kMatterAccessPrivilegeAdminister; + case MTRAccessControlEntryPrivilegeProxyView: + // Just treat this as an unknown value; there is no value for this in privilege-storage. + FALLTHROUGH; + default: + break; + } + + // To be safe, treat unknown values as "needs admin privileges". That way the failure case + // disallows access that maybe should be allowed, instead of allowing access that maybe + // should be disallowed. + return kMatterAccessPrivilegeAdminister; +} + +int MatterGetAccessPrivilegeForWriteAttribute(ClusterId cluster, AttributeId attribute) +{ + // We don't have any writable attributes yet, but default to Operate. + return kMatterAccessPrivilegeOperate; +} + +void InitializeServerAccessControl() +{ + assertChipStackLockedByCurrentThread(); + + // Ensure the access control bits are created. No-op after the first call. + gControllerAccessControl.get(); +} diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.mm b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.mm index 0337d555d02f2a..22fd2679894f15 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.mm +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.mm @@ -95,8 +95,13 @@ - (BOOL)setValue:(NSDictionary *)value return NO; } for (id item in dataValueList) { + if (![item isKindOfClass:NSDictionary.class]) { + MTR_LOG_ERROR("MTRServerAttribute value array should contain dictionaries"); + } + NSDictionary * itemDictionary = item; + NSError * encodingError; - NSData * encodedItem = MTREncodeTLVFromDataValueDictionary(item, &encodingError); + NSData * encodedItem = MTREncodeTLVFromDataValueDictionary(itemDictionary[MTRDataKey], &encodingError); if (encodedItem == nil) { return NO; } @@ -132,7 +137,7 @@ - (BOOL)setValue:(NSDictionary *)value return YES; } -- (BOOL)associateWithController:(MTRDeviceController *)controller +- (BOOL)associateWithController:(nullable MTRDeviceController *)controller { MTRDeviceController * existingController = _deviceController; if (existingController != nil) { diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute_Internal.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute_Internal.h index dbc7cebb857a88..f6b423fd628470 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute_Internal.h +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute_Internal.h @@ -21,15 +21,19 @@ #include +NS_ASSUME_NONNULL_BEGIN + @interface MTRServerAttribute () /** - * Mark this attribute as associated with a particular controller. + * Mark this attribute as associated with a particular controller. The + * controller can be nil to indicate that the endpoint is not associated with a + * specific controller but rather with the controller factory. */ -- (BOOL)associateWithController:(MTRDeviceController *)controller; +- (BOOL)associateWithController:(nullable MTRDeviceController *)controller; /** - * Mark this attribute as part of an Defunct-state endpoint. + * Mark this attribute as part of an endpoint that is no longer being used. */ - (void)invalidate; @@ -46,3 +50,5 @@ @property (nonatomic, assign) chip::app::ConcreteClusterPath parentCluster; @end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm index 8af4ca975ffb3d..8de78a675e7eb2 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm @@ -23,12 +23,40 @@ #import #import +#import "NSDataSpanConversion.h" + +#include #include +#include #include #include +#include #include +#include + +// TODO: These attribute-*.h bits are a hack that should eventually go away. +#include +#include using namespace chip; +using namespace chip::app; + +class MTRServerAttributeAccessInterface : public AttributeAccessInterface { +public: + MTRServerAttributeAccessInterface(EndpointId aEndpointID, ClusterId aClusterID, NSArray * aAttributes, + NSNumber * aClusterRevision) + : AttributeAccessInterface(MakeOptional(aEndpointID), aClusterID) + , mAttributes(aAttributes) + , mClusterRevision(aClusterRevision) + { + } + + CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; + +private: + NSArray * mAttributes; + NSNumber * mClusterRevision; +}; MTR_DIRECT_MEMBERS @implementation MTRServerCluster { @@ -39,6 +67,15 @@ @implementation MTRServerCluster { NSMutableSet * _accessGrants; NSMutableArray * _attributes; MTRDeviceController * __weak _deviceController; + + std::unique_ptr _attributeAccessInterface; + // We can't use something like std::unique_ptr + // because EmberAfAttributeMetadata does not have a default constructor, so + // we can't alloc and then initializer later. + std::vector _matterAttributeMetadata; + + std::unique_ptr _matterAcceptedCommandList; + std::unique_ptr _matterGeneratedCommandList; } - (nullable instancetype)initWithClusterID:(NSNumber *)clusterID revision:(NSNumber *)revision @@ -71,7 +108,7 @@ - (nullable instancetype)initWithClusterID:(NSNumber *)clusterID revision:(NSNum + (MTRServerCluster *)newDescriptorCluster { - return [[MTRServerCluster alloc] initInternalWithClusterID:@(MTRClusterIDTypeDescriptorID) revision:@(app::Clusters::Descriptor::kClusterRevision) accessGrants:[NSSet set] attributes:@[]]; + return [[MTRServerCluster alloc] initInternalWithClusterID:@(MTRClusterIDTypeDescriptorID) revision:@(Clusters::Descriptor::kClusterRevision) accessGrants:[NSSet set] attributes:@[]]; } - (instancetype)initInternalWithClusterID:(NSNumber *)clusterID revision:(NSNumber *)revision accessGrants:(NSSet *)accessGrants attributes:(NSArray *)attributes @@ -165,11 +202,18 @@ - (BOOL)addAttribute:(MTRServerAttribute *)attribute } [_attributes addObject:attribute]; - attribute.parentCluster = app::ConcreteClusterPath(_parentEndpoint, static_cast(_clusterID.unsignedLongLongValue)); + attribute.parentCluster = ConcreteClusterPath(_parentEndpoint, static_cast(_clusterID.unsignedLongLongValue)); return YES; } -- (BOOL)associateWithController:(MTRDeviceController *)controller +static constexpr EmberAfAttributeMetadata sDescriptorAttributesMetadata[] = { + DECLARE_DYNAMIC_ATTRIBUTE(MTRAttributeIDTypeClusterDescriptorAttributeDeviceTypeListID, ARRAY, 0, 0), + DECLARE_DYNAMIC_ATTRIBUTE(MTRAttributeIDTypeClusterDescriptorAttributeServerListID, ARRAY, 0, 0), + DECLARE_DYNAMIC_ATTRIBUTE(MTRAttributeIDTypeClusterDescriptorAttributeClientListID, ARRAY, 0, 0), + DECLARE_DYNAMIC_ATTRIBUTE(MTRAttributeIDTypeClusterDescriptorAttributePartsListID, ARRAY, 0, 0), +}; + +- (BOOL)associateWithController:(nullable MTRDeviceController *)controller { MTRDeviceController * existingController = _deviceController; if (existingController != nil) { @@ -191,6 +235,84 @@ - (BOOL)associateWithController:(MTRDeviceController *)controller // Snapshot _matterAccessGrants now; after this point it will only be // updated on the Matter queue. _matterAccessGrants = [_accessGrants copy]; + + // _attributes shouldn't be able to change anymore, so we can now construct + // our EmberAfAttributeMetadata array. + size_t attributeCount = _attributes.count; + + // Figure out whether we need to synthesize a FeatureMap attribute. + bool needsFeatureMap = true; + for (MTRServerAttribute * attr in _attributes) { + if ([attr.attributeID isEqual:@(MTRClusterGlobalAttributeFeatureMapID)]) { + needsFeatureMap = false; + break; + } + } + + bool needsDescriptorAttributes = [_clusterID isEqual:@(MTRClusterIDTypeDescriptorID)]; + + if (needsFeatureMap) { + ++attributeCount; + } + + if (needsDescriptorAttributes) { + attributeCount += ArraySize(sDescriptorAttributesMetadata); + } + + // And add one for ClusterRevision + ++attributeCount; + + if (attributeCount >= UINT16_MAX) { + MTR_LOG_ERROR("Unable to have %llu attributes in a single cluster (clusterID: " ChipLogFormatMEI ")", + static_cast(attributeCount), ChipLogValueMEI(_clusterID.unsignedLongLongValue)); + return NO; + } + + size_t attrIndex = 0; + for (; attrIndex < _attributes.count; ++attrIndex) { + auto * attr = _attributes[attrIndex]; + _matterAttributeMetadata.emplace_back(EmberAfAttributeMetadata(DECLARE_DYNAMIC_ATTRIBUTE(static_cast(attr.attributeID.unsignedLongLongValue), + // The type does not actually matter, since we plan to + // handle this entirely via AttributeAccessInterface. + // Claim Array because that one will keep random IM + // code from trying to do things with the attribute + // store. + ARRAY, + // Size in bytes does not matter, since we plan to + // handle this entirely via AttributeAccessInterface. + 0, + // ATTRIBUTE_MASK_NULLABLE is not relevant because we + // are handling this all via AttributeAccessInterface. + 0))); + } + + if (needsFeatureMap) { + _matterAttributeMetadata.emplace_back(EmberAfAttributeMetadata(DECLARE_DYNAMIC_ATTRIBUTE(MTRAttributeIDTypeGlobalAttributeFeatureMapID, + BITMAP32, 4, 0))); + ++attrIndex; + } + + if (needsDescriptorAttributes) { + for (auto & data : sDescriptorAttributesMetadata) { + _matterAttributeMetadata.emplace_back(data); + ++attrIndex; + } + } + + // Add our ClusterRevision bit. + _matterAttributeMetadata.emplace_back(EmberAfAttributeMetadata(DECLARE_DYNAMIC_ATTRIBUTE(MTRAttributeIDTypeGlobalAttributeClusterRevisionID, + INT16U, 2, 0))); + ++attrIndex; + + _attributeAccessInterface = std::make_unique(_parentEndpoint, + static_cast(_clusterID.unsignedLongLongValue), + _attributes, + _clusterRevision); + // _attributeAccessInterface needs to be registered on the Matter queue; that will happen later. + + _matterAcceptedCommandList = [MTRServerCluster makeMatterCommandList:_acceptedCommands]; + _matterGeneratedCommandList = [MTRServerCluster makeMatterCommandList:_generatedCommands]; + _deviceController = controller; return YES; @@ -198,13 +320,44 @@ - (BOOL)associateWithController:(MTRDeviceController *)controller - (void)invalidate { + // Undo any work associateWithController did. for (MTRServerAttribute * attr in _attributes) { [attr invalidate]; } + // We generally promise to only touch _matterAccessGrants on the Matter + // queue after associateWithController succeeds, but we are no longer being + // looked at from that queue, so it's safe to reset it here. + _matterAccessGrants = [NSSet set]; + _matterAttributeMetadata.clear(); + _attributeAccessInterface.reset(); + _matterAcceptedCommandList.reset(); + _matterGeneratedCommandList.reset(); + _deviceController = nil; } +- (void)registerMatterCluster +{ + assertChipStackLockedByCurrentThread(); + + if (!registerAttributeAccessOverride(_attributeAccessInterface.get())) { + // This should only happen if we somehow managed to register an + // AttributeAccessInterface for the same (endpoint, cluster) pair. + MTR_LOG_ERROR("Could not register AttributeAccessInterface for endpoint %u, cluster 0x%llx", + _parentEndpoint, _clusterID.unsignedLongLongValue); + } +} + +- (void)unregisterMatterCluster +{ + assertChipStackLockedByCurrentThread(); + + if (_attributeAccessInterface != nullptr) { + unregisterAttributeAccessOverride(_attributeAccessInterface.get()); + } +} + - (NSArray *)accessGrants { return [_accessGrants allObjects]; @@ -221,8 +374,87 @@ - (void)setParentEndpoint:(EndpointId)endpoint // Update it on all the attributes, in case the attributes were added to us // before we were added to the endpoint. for (MTRServerAttribute * attr in _attributes) { - attr.parentCluster = app::ConcreteClusterPath(endpoint, static_cast(_clusterID.unsignedLongLongValue)); + attr.parentCluster = ConcreteClusterPath(endpoint, static_cast(_clusterID.unsignedLongLongValue)); } } +- (Span)matterAttributeMetadata +{ + // This is always called after our _matterAttributeMetadata has been set up + // by associateWithController. + return Span(_matterAttributeMetadata.data(), _matterAttributeMetadata.size()); +} + +- (CommandId *)matterAcceptedCommands +{ + return _matterAcceptedCommandList.get(); +} + +- (CommandId *)matterGeneratedCommands +{ + return _matterGeneratedCommandList.get(); +} + ++ (std::unique_ptr)makeMatterCommandList:(NSArray * _Nullable)commandList +{ + if (commandList.count == 0) { + return nullptr; + } + + // Lists of accepted/generated commands are terminated by kInvalidClusterId. + auto matterCommandList = std::make_unique(commandList.count + 1); + for (size_t index = 0; index < commandList.count; ++index) { + matterCommandList[index] = static_cast(commandList[index].unsignedLongLongValue); + } + matterCommandList[commandList.count] = kInvalidClusterId; + return matterCommandList; +} + @end + +CHIP_ERROR MTRServerAttributeAccessInterface::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) +{ + using DataModel::PreEncodedValue; + + // Find the right attribute in our list. + MTRServerAttribute * foundAttr = nil; + for (MTRServerAttribute * attr in mAttributes) { + if ([attr.attributeID isEqual:@(aPath.mAttributeId)]) { + foundAttr = attr; + break; + } + } + + if (foundAttr) { + id value = foundAttr.serializedValue; + if (![value isKindOfClass:NSArray.class]) { + // It's a single value, so NSData. + NSData * data = value; + return aEncoder.Encode(PreEncodedValue(AsByteSpan(data))); + } + + // It's a list of data values. + NSArray * dataList = value; + return aEncoder.EncodeList([dataList](const auto & itemEncoder) { + for (NSData * item in dataList) { + ReturnErrorOnFailure(itemEncoder.Encode(PreEncodedValue(AsByteSpan(item)))); + } + return CHIP_NO_ERROR; + }); + } + + // This must be the FeatureMap attribute we synthesized. + if (aPath.mAttributeId == MTRAttributeIDTypeGlobalAttributeFeatureMapID) { + // Feature map defaults to 0. + constexpr uint32_t defaultFeatureMap = 0; + return aEncoder.Encode(defaultFeatureMap); + } + + if (aPath.mAttributeId == MTRAttributeIDTypeGlobalAttributeClusterRevisionID) { + return aEncoder.Encode(mClusterRevision.unsignedLongLongValue); + } + + // Note: This code is not reached for the descriptor cluster, which uses its own AttributeAccessInterface. + + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); +} diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster_Internal.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster_Internal.h index 5bd9ba0692ed4a..4ae3d0db348533 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster_Internal.h +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster_Internal.h @@ -21,15 +21,38 @@ #include +// TODO: These attribute-*.h and Span bits are a hack that should eventually go away. +#include +#include + +NS_ASSUME_NONNULL_BEGIN + @interface MTRServerCluster () /** - * Mark this cluster as associated with a particular controller. + * Mark this cluster as associated with a particular controller. The + * controller can be nil to indicate that the endpoint is not associated with a + * specific controller but rather with the controller factory. This method does + * NOT perform any cleanup on failure; it's the caller's responsibility to call + * invalidate if it fails. + */ +- (BOOL)associateWithController:(nullable MTRDeviceController *)controller; + +/** + * Register this cluster. Always called on the Matter queue. + */ +- (void)registerMatterCluster; + +/** + * Unregister this cluster. Always called on the Matter queue. */ -- (BOOL)associateWithController:(MTRDeviceController *)controller; +- (void)unregisterMatterCluster; /** - * Mark this cluster as part of an Defunct-state endpoint. + * Mark this cluster as part of an endpoint that is no longer being used. Can + * run on any thread, but will either be called before registerMatterCluster or + * after unregisterMatterCluster. This undoes anything associateWithController + * did. */ - (void)invalidate; @@ -44,4 +67,31 @@ */ @property (nonatomic, assign) chip::EndpointId parentEndpoint; +/** + * The attribute metadata for the cluster. Only valid after associateWithController: has succeeded. + */ +@property (nonatomic, assign, readonly) chip::Span matterAttributeMetadata; + +/** + * The list of accepted command IDs. + */ +@property (nonatomic, copy, nullable) NSArray * acceptedCommands; + +/** + * The list of generated command IDs. + */ +@property (nonatomic, copy, nullable) NSArray * generatedCommands; + +/** + * The list of accepted commands IDs in the format the Matter stack needs. + */ +@property (nonatomic, assign, nullable, readonly) chip::CommandId * matterAcceptedCommands; + +/** + * The list of generated commands IDs in the format the Matter stack needs. + */ +@property (nonatomic, assign, nullable, readonly) chip::CommandId * matterGeneratedCommands; + @end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.h index 642dc5fb4ec658..13dbe8454d759e 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.h +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.h @@ -77,8 +77,9 @@ MTR_NEWLY_AVAILABLE /** * A list of server clusters supported on this endpoint. The Descriptor cluster * does not need to be included unless a TagList attribute is desired on it or - * unless it has a non-empty PartsList. If not included, the Descriptor cluster - * will be generated automatically. + * it has a non-empty PartsList, or it needs to have cluster-specific access + * grants. If not included, the Descriptor cluster will be generated + * automatically. */ @property (nonatomic, copy, readonly) NSArray * serverClusters; diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.mm b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.mm index ee35e4da0bc0db..5e6df865115be6 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.mm +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.mm @@ -19,11 +19,22 @@ #import "MTRLogging_Internal.h" #import "MTRServerCluster_Internal.h" #import "MTRServerEndpoint_Internal.h" +#import #import #include #include #include +#include + +// TODO: These af-types.h and att-storage.h and attribute-storage.h and +// endpoint-config-api.h and probably CodeUtils.h bits are a hack that should +// eventually go away. +#include +#include +#include +#include +#include using namespace chip; @@ -36,6 +47,13 @@ @implementation MTRServerEndpoint { NSMutableSet * _accessGrants; NSMutableArray * _serverClusters; MTRDeviceController * __weak _deviceController; + std::unique_ptr _matterClusterMetadata; + EmberAfEndpointType _matterEndpointMetadata; + std::unique_ptr _matterDeviceTypes; + std::unique_ptr _matterDataVersions; + + // _endpointIndex has a value only when we have the endpoint configured. + std::optional _endpointIndex; } - (nullable instancetype)initWithEndpointID:(NSNumber *)endpointID deviceTypes:(NSArray *)deviceTypes @@ -67,6 +85,11 @@ - (nullable instancetype)initWithEndpointID:(NSNumber *)endpointID deviceTypes:( return [self initInternalWithEndpointID:endpointID deviceTypes:deviceTypes accessGrants:[NSSet set] clusters:@[]]; } ++ (MTRServerEndpoint *)rootNodeEndpoint +{ + return [[MTRServerEndpoint alloc] initInternalWithEndpointID:@(kRootEndpointId) deviceTypes:@[] accessGrants:[NSSet set] clusters:@[]]; +} + - (instancetype)initInternalWithEndpointID:(NSNumber *)endpointID deviceTypes:(NSArray *)deviceTypes accessGrants:(NSSet *)accessGrants clusters:(NSArray *)clusters { if (!(self = [super init])) { @@ -148,7 +171,21 @@ - (BOOL)addServerCluster:(MTRServerCluster *)serverCluster return YES; } -- (BOOL)associateWithController:(MTRDeviceController *)controller +#define MTR_DECLARE_LIST_ATTRIBUTE(attrID) \ + DECLARE_DYNAMIC_ATTRIBUTE(attrID, ARRAY, 0, 0) + +static constexpr EmberAfAttributeMetadata sDescriptorAttributesMetadata[] = { + DECLARE_DYNAMIC_ATTRIBUTE(MTRAttributeIDTypeClusterDescriptorAttributeDeviceTypeListID, ARRAY, 0, 0), + DECLARE_DYNAMIC_ATTRIBUTE(MTRAttributeIDTypeClusterDescriptorAttributeServerListID, ARRAY, 0, 0), + DECLARE_DYNAMIC_ATTRIBUTE(MTRAttributeIDTypeClusterDescriptorAttributeClientListID, ARRAY, 0, 0), + DECLARE_DYNAMIC_ATTRIBUTE(MTRAttributeIDTypeClusterDescriptorAttributePartsListID, ARRAY, 0, 0), + DECLARE_DYNAMIC_ATTRIBUTE(MTRAttributeIDTypeGlobalAttributeFeatureMapID, BITMAP32, 4, 0), + DECLARE_DYNAMIC_ATTRIBUTE(MTRAttributeIDTypeGlobalAttributeClusterRevisionID, INT16U, 2, 0), +}; + +#undef MTR_DECLARE_LIST_ATTRIBUTE + +- (BOOL)associateWithController:(nullable MTRDeviceController *)controller { MTRDeviceController * existingController = _deviceController; if (existingController != nil) { @@ -161,6 +198,17 @@ - (BOOL)associateWithController:(MTRDeviceController *)controller return NO; } + // After this point we have to make sure we clean up on any failures. + if (![self finishAssociationWithController:controller]) { + [self invalidate]; + return NO; + } + + return YES; +} + +- (BOOL)finishAssociationWithController:(nullable MTRDeviceController *)controller +{ for (MTRServerCluster * cluster in _serverClusters) { if (![cluster associateWithController:controller]) { return NO; @@ -170,20 +218,193 @@ - (BOOL)associateWithController:(MTRDeviceController *)controller // Snapshot _matterAccessGrants now; after this point it will only be // updated on the Matter queue. _matterAccessGrants = [_accessGrants copy]; + + // _serverClusters shouldn't be able to change anymore, so we can now + // construct our EmberAfCluster array. + size_t clusterCount = _serverClusters.count; + + // Figure out whether we need to synthesize a Descriptor cluster. + bool needsDescriptor = true; + for (MTRServerCluster * cluster in _serverClusters) { + if ([cluster.clusterID isEqual:@(MTRClusterIDTypeDescriptorID)]) { + needsDescriptor = false; + break; + } + } + + if (needsDescriptor) { + ++clusterCount; + } + + if (clusterCount >= 0xFF) { + // The ember bits don't allow this many clusters (they use 0xFF to mean + // "no such cluster" in various places. + MTR_LOG_ERROR("Unable to create endpoint with %llu clusters; it's too many", + static_cast(clusterCount)); + return NO; + } + + _matterClusterMetadata = std::make_unique(clusterCount); + // std::make_unique never returns null; it will try to throw an exception + // and likely crash on OOM. + + size_t clusterIndex = 0; + for (; clusterIndex < _serverClusters.count; ++clusterIndex) { + auto * cluster = _serverClusters[clusterIndex]; + auto & metadata = _matterClusterMetadata[clusterIndex]; + + metadata.clusterId = static_cast(cluster.clusterID.unsignedLongLongValue); + + auto attrMetadata = cluster.matterAttributeMetadata; + metadata.attributes = attrMetadata.data(); + // This cast is safe because clusters check for this constraint on + // number of attributes. + metadata.attributeCount = static_cast(attrMetadata.size()); + + metadata.clusterSize = 0; // All our attributes are external. + + metadata.mask = CLUSTER_MASK_SERVER; + + metadata.functions = nullptr; // None of our clusters, including Descriptor, uses these. + + metadata.acceptedCommandList = cluster.matterAcceptedCommands; + metadata.generatedCommandList = cluster.matterGeneratedCommands; + + metadata.eventList = nullptr; + metadata.eventCount = 0; + } + + if (needsDescriptor) { + auto & metadata = _matterClusterMetadata[clusterIndex]; + + metadata.clusterId = MTRClusterIDTypeDescriptorID; + + metadata.attributes = sDescriptorAttributesMetadata; + metadata.attributeCount = ArraySize(sDescriptorAttributesMetadata); + + metadata.clusterSize = 0; // All our attributes are external. + + metadata.mask = CLUSTER_MASK_SERVER; + + metadata.functions = nullptr; // Descriptor does not use these. + + metadata.acceptedCommandList = nullptr; + metadata.generatedCommandList = nullptr; + + metadata.eventList = nullptr; + metadata.eventCount = 0; + + ++clusterIndex; + } + + _matterEndpointMetadata.cluster = _matterClusterMetadata.get(); + // Cast is safe, because we did a range check above. + _matterEndpointMetadata.clusterCount = static_cast(clusterCount); + _matterEndpointMetadata.endpointSize = 0; // All our attributes are external. + + _matterDeviceTypes = std::make_unique(_deviceTypes.count); + for (size_t index = 0; index < _deviceTypes.count; ++index) { + auto * deviceType = _deviceTypes[index]; + auto & matterType = _matterDeviceTypes[index]; + + matterType.deviceId = static_cast(deviceType.deviceTypeID.unsignedLongLongValue); + // TODO: The spec allows 16-bit revisions, but the Ember bits only + // support 8-bit.... + matterType.deviceVersion = static_cast(deviceType.deviceTypeRevision.unsignedLongLongValue); + } + + _matterDataVersions = std::make_unique(clusterCount); + _deviceController = controller; return YES; } +- (void)registerMatterEndpoint +{ + assertChipStackLockedByCurrentThread(); + + static_assert(FIXED_ENDPOINT_COUNT == 0, "Indexing will be off"); + + // We can't use emberAfEndpointCount here, because that returns just the + // count of fixed endpoints up until the first call to + // emberAfSetDynamicEndpoint(). + uint16_t possibleEndpointCount = MAX_ENDPOINT_COUNT; + uint16_t index = 0; + for (; index < possibleEndpointCount; ++index) { + if (emberAfEndpointFromIndex(index) == kInvalidEndpointId) { + break; + } + } + + if (index == possibleEndpointCount) { + // Something is very broken. We shouldn't have this many endpoints! + MTR_LOG_ERROR("We somehow ran out of endpoint slots."); + return; + } + + auto status = emberAfSetDynamicEndpoint(index, static_cast(_endpointID.unsignedLongLongValue), + &_matterEndpointMetadata, + Span(_matterDataVersions.get(), _matterEndpointMetadata.clusterCount), + Span(_matterDeviceTypes.get(), _deviceTypes.count)); + if (status != EMBER_ZCL_STATUS_SUCCESS) { + MTR_LOG_ERROR("Unexpected failure to define our Matter endpoint"); + } + + _endpointIndex.emplace(index); + + for (MTRServerCluster * cluster in _serverClusters) { + [cluster registerMatterCluster]; + } +} + +- (void)unregisterMatterEndpoint +{ + assertChipStackLockedByCurrentThread(); + + if (_endpointIndex.has_value()) { + emberAfClearDynamicEndpoint(_endpointIndex.value()); + _endpointIndex.reset(); + } + + for (MTRServerCluster * cluster in _serverClusters) { + [cluster unregisterMatterCluster]; + } +} + - (void)invalidate { + // Undo any work associateWithController did. for (MTRServerCluster * cluster in _serverClusters) { [cluster invalidate]; } + // We generally promise to only touch _matterAccessGrants on the Matter + // queue after associateWithController succeeds, but we are no longer being + // looked at from that queue, so it's safe to reset it here. + _matterAccessGrants = [NSSet set]; + _matterEndpointMetadata.cluster = nullptr; + _matterEndpointMetadata.clusterCount = 0; + _matterClusterMetadata.reset(); + _matterDeviceTypes.reset(); + _matterDataVersions.reset(); _deviceController = nil; } +- (NSArray *)matterAccessGrantsForCluster:(NSNumber *)clusterID +{ + assertChipStackLockedByCurrentThread(); + + NSMutableArray * grants = [[_matterAccessGrants allObjects] mutableCopy]; + for (MTRServerCluster * cluster in _serverClusters) { + if ([cluster.clusterID isEqual:clusterID]) { + [grants addObjectsFromArray:[cluster.matterAccessGrants allObjects]]; + } + } + + return [grants copy]; +} + - (NSArray *)accessGrants { return [_accessGrants allObjects]; diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint_Internal.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint_Internal.h index 97725c2b1afad5..1ca4d4da7533a5 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint_Internal.h +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint_Internal.h @@ -18,18 +18,49 @@ #import #import +NS_ASSUME_NONNULL_BEGIN + @interface MTRServerEndpoint () /** - * Mark this endpoint as associated with a particular controller. + * Mark this endpoint as associated with a particular controller. The + * controller can be nil to indicate that the endpoint is not associated with a + * specific controller but rather with the controller factory. + * + * On failure, this method ensures that it undoes any state changes it made. + */ +- (BOOL)associateWithController:(nullable MTRDeviceController *)controller; + +/** + * Register this endpoint. Always called on the Matter queue. + */ +- (void)registerMatterEndpoint; + +/** + * Unregister this endpoint. Always called on the Matter queue. */ -- (BOOL)associateWithController:(MTRDeviceController *)controller; +- (void)unregisterMatterEndpoint; /** - * Mark this endpoint as being in a Defunct state. + * Mark this endpoint as no longer being in use. Can run on any thread, but + * will either be called before registerMatterEndpoint or after + * unregisterMatterEndpoint. This undoes anything associateWithController did. */ - (void)invalidate; +/** + * Get an MTRServerEndpoint for the root node endpoint. This can't be done via + * the public initializer, since we don't allow that to create an + * MTRServerEndpoint for endpoint 0. + */ ++ (MTRServerEndpoint *)rootNodeEndpoint; + +/** + * Returns the list of access grants applicable to the given cluster ID on this + * endpoint. Only called on the Matter queue. + */ +- (NSArray *)matterAccessGrantsForCluster:(NSNumber *)clusterID; + /** * The access grants the Matter stack can observe. Only modified while in * Initializing state or on the Matter queue. @@ -37,3 +68,5 @@ @property (nonatomic, strong, readonly) NSSet * matterAccessGrants; @end + +NS_ASSUME_NONNULL_END diff --git a/src/inet/tests/TestInetLayer.h b/src/darwin/Framework/CHIP/app/PluginApplicationCallbacks.h similarity index 58% rename from src/inet/tests/TestInetLayer.h rename to src/darwin/Framework/CHIP/app/PluginApplicationCallbacks.h index 1c13b7dec78a83..f21f1e15302186 100644 --- a/src/inet/tests/TestInetLayer.h +++ b/src/darwin/Framework/CHIP/app/PluginApplicationCallbacks.h @@ -1,6 +1,5 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2024 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. @@ -16,24 +15,13 @@ */ /** - * @file - * This file declares test entry points for CHIP Internet (inet) - * layer library unit tests. + * This file is only here to satisfy includes in core files that expect an + * app/PluginApplicationCallbacks.h. This file is NOT generated by ZAP, and + * provides the bare minimum information needed to allow things to compile. * + * TODO: This needs a better setup. */ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif +void MatterDescriptorPluginServerInitCallback(); -int TestInetAddress(void); -int TestInetBuffer(void); -int TestInetErrorStr(void); -int TestInetTimer(void); -int TestInetEndPoint(void); -int TestInetLayerDNS(void); -#ifdef __cplusplus -} -#endif +#define MATTER_PLUGINS_INIT MatterDescriptorPluginServerInitCallback(); diff --git a/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt b/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt index de92791826c666..9d6e786ce03149 100644 --- a/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/darwin/Framework/CHIP/templates/MTRClusterNames-src.zapt b/src/darwin/Framework/CHIP/templates/MTRClusterNames-src.zapt new file mode 100644 index 00000000000000..b495d79b1b4c72 --- /dev/null +++ b/src/darwin/Framework/CHIP/templates/MTRClusterNames-src.zapt @@ -0,0 +1,89 @@ +{{> header excludeZapComment=true}} + + +#import + +// @implementation MTRClusterAttributeIDType + +#pragma mark - Clusters IDs + +NSString * MTRClusterNameForID(MTRClusterIDType clusterID) +{ + NSString * result = nil; + + switch (clusterID) { + +{{#zcl_clusters}} +{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}} +{{~#*inline "cluster"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}} + case MTRClusterIDType{{>cluster}}ID: + result = @"{{>cluster}}"; + break; +{{/if}} +{{/zcl_clusters}} + + default: + result = [NSString stringWithFormat:@"", clusterID]; + break; + } + + return result; +} + + +#pragma mark - Attributes IDs + +NSString * MTRAttributeNameForID(MTRClusterIDType clusterID, MTRAttributeIDType attributeID) +{ + NSString * result = nil; + + switch (clusterID) { + +{{#zcl_clusters}} +{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}} +{{~#*inline "cluster"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}} + case MTRClusterIDType{{>cluster}}ID: + + switch (attributeID) { + +{{/if}} + +{{#*inline "attributeIDs"}} +{{#zcl_attributes_server}} +{{~#*inline "cluster"}}{{asUpperCamelCase ../clusterName preserveAcronyms=true}}{{/inline~}} +{{~#*inline "attribute"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}} +{{#first}} +{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) isForIds=true)}} +// Cluster {{> cluster}} attributes +{{/if}} +{{/first}} +{{#if (and (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true) + (or clusterRef + (isSupported "" globalAttribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true)))}} + case MTRAttributeIDTypeCluster{{>cluster}}Attribute{{>attribute}}ID: + result = @"{{>attribute}}"; + break; + +{{/if}} +{{/zcl_attributes_server}} +{{/inline}} + +{{> attributeIDs clusterName=label}} + +{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}} + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } +{{/if}} + +{{/zcl_clusters}} + default: + result = [NSString stringWithFormat:@"", clusterID]; + break; + } + + return result; +} + +// @end diff --git a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt index c58c75f77d9d38..783fe2aff9555f 100644 --- a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include diff --git a/src/darwin/Framework/CHIP/templates/templates.json b/src/darwin/Framework/CHIP/templates/templates.json index 59a06b83c2fd99..83df8bdab40e63 100644 --- a/src/darwin/Framework/CHIP/templates/templates.json +++ b/src/darwin/Framework/CHIP/templates/templates.json @@ -120,6 +120,11 @@ "name": "Constants for cluster IDs", "output": "src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h" }, + { + "path": "MTRClusterNames-src.zapt", + "name": "Objc Cluster Names API", + "output": "src/darwin/Framework/CHIP/zap-generated/MTRClusterNames.mm" + }, { "path": "MTRAttributeSpecifiedCheck-src.zapt", "name": "Function to check if attribute is specified", diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm index 61aeca639079b2..cb98d807f3495d 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm @@ -2924,6 +2924,90 @@ static BOOL AttributeIsSpecifiedInValveConfigurationAndControlCluster(AttributeI } } } +static BOOL AttributeIsSpecifiedInElectricalPowerMeasurementCluster(AttributeId aAttributeId) +{ + using namespace Clusters::ElectricalPowerMeasurement; + switch (aAttributeId) { + case Attributes::PowerMode::Id: { + return YES; + } + case Attributes::NumberOfMeasurementTypes::Id: { + return YES; + } + case Attributes::Accuracy::Id: { + return YES; + } + case Attributes::Ranges::Id: { + return YES; + } + case Attributes::Voltage::Id: { + return YES; + } + case Attributes::ActiveCurrent::Id: { + return YES; + } + case Attributes::ReactiveCurrent::Id: { + return YES; + } + case Attributes::ApparentCurrent::Id: { + return YES; + } + case Attributes::ActivePower::Id: { + return YES; + } + case Attributes::ReactivePower::Id: { + return YES; + } + case Attributes::ApparentPower::Id: { + return YES; + } + case Attributes::RMSVoltage::Id: { + return YES; + } + case Attributes::RMSCurrent::Id: { + return YES; + } + case Attributes::RMSPower::Id: { + return YES; + } + case Attributes::Frequency::Id: { + return YES; + } + case Attributes::HarmonicCurrents::Id: { + return YES; + } + case Attributes::HarmonicPhases::Id: { + return YES; + } + case Attributes::PowerFactor::Id: { + return YES; + } + case Attributes::NeutralCurrent::Id: { + return YES; + } + case Attributes::GeneratedCommandList::Id: { + return YES; + } + case Attributes::AcceptedCommandList::Id: { + return YES; + } + case Attributes::EventList::Id: { + return YES; + } + case Attributes::AttributeList::Id: { + return YES; + } + case Attributes::FeatureMap::Id: { + return YES; + } + case Attributes::ClusterRevision::Id: { + return YES; + } + default: { + return NO; + } + } +} static BOOL AttributeIsSpecifiedInElectricalEnergyMeasurementCluster(AttributeId aAttributeId) { using namespace Clusters::ElectricalEnergyMeasurement; @@ -2943,6 +3027,9 @@ static BOOL AttributeIsSpecifiedInElectricalEnergyMeasurementCluster(AttributeId case Attributes::PeriodicEnergyExported::Id: { return YES; } + case Attributes::CumulativeEnergyReset::Id: { + return YES; + } case Attributes::GeneratedCommandList::Id: { return YES; } @@ -3239,6 +3326,39 @@ static BOOL AttributeIsSpecifiedInEnergyPreferenceCluster(AttributeId aAttribute } } } +static BOOL AttributeIsSpecifiedInPowerTopologyCluster(AttributeId aAttributeId) +{ + using namespace Clusters::PowerTopology; + switch (aAttributeId) { + case Attributes::AvailableEndpoints::Id: { + return YES; + } + case Attributes::ActiveEndpoints::Id: { + return YES; + } + case Attributes::GeneratedCommandList::Id: { + return YES; + } + case Attributes::AcceptedCommandList::Id: { + return YES; + } + case Attributes::EventList::Id: { + return YES; + } + case Attributes::AttributeList::Id: { + return YES; + } + case Attributes::FeatureMap::Id: { + return YES; + } + case Attributes::ClusterRevision::Id: { + return YES; + } + default: { + return NO; + } + } +} static BOOL AttributeIsSpecifiedInEnergyEVSEModeCluster(AttributeId aAttributeId) { using namespace Clusters::EnergyEvseMode; @@ -6579,6 +6699,9 @@ BOOL MTRAttributeIsSpecified(ClusterId aClusterId, AttributeId aAttributeId) case Clusters::ValveConfigurationAndControl::Id: { return AttributeIsSpecifiedInValveConfigurationAndControlCluster(aAttributeId); } + case Clusters::ElectricalPowerMeasurement::Id: { + return AttributeIsSpecifiedInElectricalPowerMeasurementCluster(aAttributeId); + } case Clusters::ElectricalEnergyMeasurement::Id: { return AttributeIsSpecifiedInElectricalEnergyMeasurementCluster(aAttributeId); } @@ -6597,6 +6720,9 @@ BOOL MTRAttributeIsSpecified(ClusterId aClusterId, AttributeId aAttributeId) case Clusters::EnergyPreference::Id: { return AttributeIsSpecifiedInEnergyPreferenceCluster(aAttributeId); } + case Clusters::PowerTopology::Id: { + return AttributeIsSpecifiedInPowerTopologyCluster(aAttributeId); + } case Clusters::EnergyEvseMode::Id: { return AttributeIsSpecifiedInEnergyEVSEModeCluster(aAttributeId); } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm index f11d395889afaa..298c127feeb02d 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm @@ -7631,6 +7631,454 @@ static id _Nullable DecodeAttributeValueForValveConfigurationAndControlCluster(A *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB; return nil; } +static id _Nullable DecodeAttributeValueForElectricalPowerMeasurementCluster(AttributeId aAttributeId, TLV::TLVReader & aReader, CHIP_ERROR * aError) +{ + using namespace Clusters::ElectricalPowerMeasurement; + switch (aAttributeId) { + case Attributes::PowerMode::Id: { + using TypeInfo = Attributes::PowerMode::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue)]; + return value; + } + case Attributes::NumberOfMeasurementTypes::Id: { + using TypeInfo = Attributes::NumberOfMeasurementTypes::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithUnsignedChar:cppValue]; + return value; + } + case Attributes::Accuracy::Id: { + using TypeInfo = Attributes::Accuracy::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSArray * _Nonnull value; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + MTRElectricalPowerMeasurementClusterMeasurementAccuracyStruct * newElement_0; + newElement_0 = [MTRElectricalPowerMeasurementClusterMeasurementAccuracyStruct new]; + newElement_0.measurementType = [NSNumber numberWithUnsignedShort:chip::to_underlying(entry_0.measurementType)]; + newElement_0.measured = [NSNumber numberWithBool:entry_0.measured]; + newElement_0.minMeasuredValue = [NSNumber numberWithLongLong:entry_0.minMeasuredValue]; + newElement_0.maxMeasuredValue = [NSNumber numberWithLongLong:entry_0.maxMeasuredValue]; + { // Scope for our temporary variables + auto * array_2 = [NSMutableArray new]; + auto iter_2 = entry_0.accuracyRanges.begin(); + while (iter_2.Next()) { + auto & entry_2 = iter_2.GetValue(); + MTRElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct * newElement_2; + newElement_2 = [MTRElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct new]; + newElement_2.rangeMin = [NSNumber numberWithLongLong:entry_2.rangeMin]; + newElement_2.rangeMax = [NSNumber numberWithLongLong:entry_2.rangeMax]; + if (entry_2.percentMax.HasValue()) { + newElement_2.percentMax = [NSNumber numberWithUnsignedShort:entry_2.percentMax.Value()]; + } else { + newElement_2.percentMax = nil; + } + if (entry_2.percentMin.HasValue()) { + newElement_2.percentMin = [NSNumber numberWithUnsignedShort:entry_2.percentMin.Value()]; + } else { + newElement_2.percentMin = nil; + } + if (entry_2.percentTypical.HasValue()) { + newElement_2.percentTypical = [NSNumber numberWithUnsignedShort:entry_2.percentTypical.Value()]; + } else { + newElement_2.percentTypical = nil; + } + if (entry_2.fixedMax.HasValue()) { + newElement_2.fixedMax = [NSNumber numberWithUnsignedLongLong:entry_2.fixedMax.Value()]; + } else { + newElement_2.fixedMax = nil; + } + if (entry_2.fixedMin.HasValue()) { + newElement_2.fixedMin = [NSNumber numberWithUnsignedLongLong:entry_2.fixedMin.Value()]; + } else { + newElement_2.fixedMin = nil; + } + if (entry_2.fixedTypical.HasValue()) { + newElement_2.fixedTypical = [NSNumber numberWithUnsignedLongLong:entry_2.fixedTypical.Value()]; + } else { + newElement_2.fixedTypical = nil; + } + [array_2 addObject:newElement_2]; + } + CHIP_ERROR err = iter_2.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + newElement_0.accuracyRanges = array_2; + } + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + value = array_0; + } + return value; + } + case Attributes::Ranges::Id: { + using TypeInfo = Attributes::Ranges::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSArray * _Nonnull value; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + MTRElectricalPowerMeasurementClusterMeasurementRangeStruct * newElement_0; + newElement_0 = [MTRElectricalPowerMeasurementClusterMeasurementRangeStruct new]; + newElement_0.measurementType = [NSNumber numberWithUnsignedShort:chip::to_underlying(entry_0.measurementType)]; + newElement_0.min = [NSNumber numberWithLongLong:entry_0.min]; + newElement_0.max = [NSNumber numberWithLongLong:entry_0.max]; + if (entry_0.startTimestamp.HasValue()) { + newElement_0.startTimestamp = [NSNumber numberWithUnsignedInt:entry_0.startTimestamp.Value()]; + } else { + newElement_0.startTimestamp = nil; + } + if (entry_0.endTimestamp.HasValue()) { + newElement_0.endTimestamp = [NSNumber numberWithUnsignedInt:entry_0.endTimestamp.Value()]; + } else { + newElement_0.endTimestamp = nil; + } + if (entry_0.minTimestamp.HasValue()) { + newElement_0.minTimestamp = [NSNumber numberWithUnsignedInt:entry_0.minTimestamp.Value()]; + } else { + newElement_0.minTimestamp = nil; + } + if (entry_0.maxTimestamp.HasValue()) { + newElement_0.maxTimestamp = [NSNumber numberWithUnsignedInt:entry_0.maxTimestamp.Value()]; + } else { + newElement_0.maxTimestamp = nil; + } + if (entry_0.startSystime.HasValue()) { + newElement_0.startSystime = [NSNumber numberWithUnsignedLongLong:entry_0.startSystime.Value()]; + } else { + newElement_0.startSystime = nil; + } + if (entry_0.endSystime.HasValue()) { + newElement_0.endSystime = [NSNumber numberWithUnsignedLongLong:entry_0.endSystime.Value()]; + } else { + newElement_0.endSystime = nil; + } + if (entry_0.minSystime.HasValue()) { + newElement_0.minSystime = [NSNumber numberWithUnsignedLongLong:entry_0.minSystime.Value()]; + } else { + newElement_0.minSystime = nil; + } + if (entry_0.maxSystime.HasValue()) { + newElement_0.maxSystime = [NSNumber numberWithUnsignedLongLong:entry_0.maxSystime.Value()]; + } else { + newElement_0.maxSystime = nil; + } + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + value = array_0; + } + return value; + } + case Attributes::Voltage::Id: { + using TypeInfo = Attributes::Voltage::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } + return value; + } + case Attributes::ActiveCurrent::Id: { + using TypeInfo = Attributes::ActiveCurrent::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } + return value; + } + case Attributes::ReactiveCurrent::Id: { + using TypeInfo = Attributes::ReactiveCurrent::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } + return value; + } + case Attributes::ApparentCurrent::Id: { + using TypeInfo = Attributes::ApparentCurrent::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } + return value; + } + case Attributes::ActivePower::Id: { + using TypeInfo = Attributes::ActivePower::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } + return value; + } + case Attributes::ReactivePower::Id: { + using TypeInfo = Attributes::ReactivePower::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } + return value; + } + case Attributes::ApparentPower::Id: { + using TypeInfo = Attributes::ApparentPower::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } + return value; + } + case Attributes::RMSVoltage::Id: { + using TypeInfo = Attributes::RMSVoltage::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } + return value; + } + case Attributes::RMSCurrent::Id: { + using TypeInfo = Attributes::RMSCurrent::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } + return value; + } + case Attributes::RMSPower::Id: { + using TypeInfo = Attributes::RMSPower::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } + return value; + } + case Attributes::Frequency::Id: { + using TypeInfo = Attributes::Frequency::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } + return value; + } + case Attributes::HarmonicCurrents::Id: { + using TypeInfo = Attributes::HarmonicCurrents::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSArray * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + auto iter_1 = cppValue.Value().begin(); + while (iter_1.Next()) { + auto & entry_1 = iter_1.GetValue(); + MTRElectricalPowerMeasurementClusterHarmonicMeasurementStruct * newElement_1; + newElement_1 = [MTRElectricalPowerMeasurementClusterHarmonicMeasurementStruct new]; + newElement_1.order = [NSNumber numberWithUnsignedChar:entry_1.order]; + if (entry_1.measurement.IsNull()) { + newElement_1.measurement = nil; + } else { + newElement_1.measurement = [NSNumber numberWithLongLong:entry_1.measurement.Value()]; + } + [array_1 addObject:newElement_1]; + } + CHIP_ERROR err = iter_1.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + value = array_1; + } + } + return value; + } + case Attributes::HarmonicPhases::Id: { + using TypeInfo = Attributes::HarmonicPhases::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSArray * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + auto iter_1 = cppValue.Value().begin(); + while (iter_1.Next()) { + auto & entry_1 = iter_1.GetValue(); + MTRElectricalPowerMeasurementClusterHarmonicMeasurementStruct * newElement_1; + newElement_1 = [MTRElectricalPowerMeasurementClusterHarmonicMeasurementStruct new]; + newElement_1.order = [NSNumber numberWithUnsignedChar:entry_1.order]; + if (entry_1.measurement.IsNull()) { + newElement_1.measurement = nil; + } else { + newElement_1.measurement = [NSNumber numberWithLongLong:entry_1.measurement.Value()]; + } + [array_1 addObject:newElement_1]; + } + CHIP_ERROR err = iter_1.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + value = array_1; + } + } + return value; + } + case Attributes::PowerFactor::Id: { + using TypeInfo = Attributes::PowerFactor::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } + return value; + } + case Attributes::NeutralCurrent::Id: { + using TypeInfo = Attributes::NeutralCurrent::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } + return value; + } + default: { + break; + } + } + + *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB; + return nil; +} static id _Nullable DecodeAttributeValueForElectricalEnergyMeasurementCluster(AttributeId aAttributeId, TLV::TLVReader & aReader, CHIP_ERROR * aError) { using namespace Clusters::ElectricalEnergyMeasurement; @@ -7842,6 +8290,57 @@ static id _Nullable DecodeAttributeValueForElectricalEnergyMeasurementCluster(At } return value; } + case Attributes::CumulativeEnergyReset::Id: { + using TypeInfo = Attributes::CumulativeEnergyReset::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + MTRElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [MTRElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct new]; + if (cppValue.Value().importedResetTimestamp.HasValue()) { + if (cppValue.Value().importedResetTimestamp.Value().IsNull()) { + value.importedResetTimestamp = nil; + } else { + value.importedResetTimestamp = [NSNumber numberWithUnsignedInt:cppValue.Value().importedResetTimestamp.Value().Value()]; + } + } else { + value.importedResetTimestamp = nil; + } + if (cppValue.Value().exportedResetTimestamp.HasValue()) { + if (cppValue.Value().exportedResetTimestamp.Value().IsNull()) { + value.exportedResetTimestamp = nil; + } else { + value.exportedResetTimestamp = [NSNumber numberWithUnsignedInt:cppValue.Value().exportedResetTimestamp.Value().Value()]; + } + } else { + value.exportedResetTimestamp = nil; + } + if (cppValue.Value().importedResetSystime.HasValue()) { + if (cppValue.Value().importedResetSystime.Value().IsNull()) { + value.importedResetSystime = nil; + } else { + value.importedResetSystime = [NSNumber numberWithUnsignedLongLong:cppValue.Value().importedResetSystime.Value().Value()]; + } + } else { + value.importedResetSystime = nil; + } + if (cppValue.Value().exportedResetSystime.HasValue()) { + if (cppValue.Value().exportedResetSystime.Value().IsNull()) { + value.exportedResetSystime = nil; + } else { + value.exportedResetSystime = [NSNumber numberWithUnsignedLongLong:cppValue.Value().exportedResetSystime.Value().Value()]; + } + } else { + value.exportedResetSystime = nil; + } + } + return value; + } default: { break; } @@ -9063,6 +9562,70 @@ static id _Nullable DecodeAttributeValueForEnergyPreferenceCluster(AttributeId a *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB; return nil; } +static id _Nullable DecodeAttributeValueForPowerTopologyCluster(AttributeId aAttributeId, TLV::TLVReader & aReader, CHIP_ERROR * aError) +{ + using namespace Clusters::PowerTopology; + switch (aAttributeId) { + case Attributes::AvailableEndpoints::Id: { + using TypeInfo = Attributes::AvailableEndpoints::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSArray * _Nonnull value; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedShort:entry_0]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + value = array_0; + } + return value; + } + case Attributes::ActiveEndpoints::Id: { + using TypeInfo = Attributes::ActiveEndpoints::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSArray * _Nonnull value; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedShort:entry_0]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + value = array_0; + } + return value; + } + default: { + break; + } + } + + *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB; + return nil; +} static id _Nullable DecodeAttributeValueForEnergyEVSEModeCluster(AttributeId aAttributeId, TLV::TLVReader & aReader, CHIP_ERROR * aError) { using namespace Clusters::EnergyEvseMode; @@ -18925,6 +19488,9 @@ id _Nullable MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::T case Clusters::ValveConfigurationAndControl::Id: { return DecodeAttributeValueForValveConfigurationAndControlCluster(aPath.mAttributeId, aReader, aError); } + case Clusters::ElectricalPowerMeasurement::Id: { + return DecodeAttributeValueForElectricalPowerMeasurementCluster(aPath.mAttributeId, aReader, aError); + } case Clusters::ElectricalEnergyMeasurement::Id: { return DecodeAttributeValueForElectricalEnergyMeasurementCluster(aPath.mAttributeId, aReader, aError); } @@ -18943,6 +19509,9 @@ id _Nullable MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::T case Clusters::EnergyPreference::Id: { return DecodeAttributeValueForEnergyPreferenceCluster(aPath.mAttributeId, aReader, aError); } + case Clusters::PowerTopology::Id: { + return DecodeAttributeValueForPowerTopologyCluster(aPath.mAttributeId, aReader, aError); + } case Clusters::EnergyEvseMode::Id: { return DecodeAttributeValueForEnergyEVSEModeCluster(aPath.mAttributeId, aReader, aError); } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index 61b8a750b3540a..63830792a8b83c 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -2561,6 +2561,12 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) - (void)timeSnapshotWithParams:(MTRGeneralDiagnosticsClusterTimeSnapshotParams * _Nullable)params completion:(void (^)(MTRGeneralDiagnosticsClusterTimeSnapshotResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; - (void)timeSnapshotWithCompletion:(void (^)(MTRGeneralDiagnosticsClusterTimeSnapshotResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +/** + * Command PayloadTestRequest + * + * Request a variable length payload response. + */ +- (void)payloadTestRequestWithParams:(MTRGeneralDiagnosticsClusterPayloadTestRequestParams *)params completion:(void (^)(MTRGeneralDiagnosticsClusterPayloadTestResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; - (void)readAttributeNetworkInterfacesWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (void)subscribeAttributeNetworkInterfacesWithParams:(MTRSubscribeParams *)params @@ -7226,6 +7232,181 @@ MTR_PROVISIONALLY_AVAILABLE @end +/** + * Cluster Electrical Power Measurement + * + * This cluster provides a mechanism for querying data about electrical power as measured by the server. + */ +MTR_PROVISIONALLY_AVAILABLE +@interface MTRBaseClusterElectricalPowerMeasurement : MTRGenericBaseCluster + +- (void)readAttributePowerModeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributePowerModeWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributePowerModeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeNumberOfMeasurementTypesWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeNumberOfMeasurementTypesWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeNumberOfMeasurementTypesWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeAccuracyWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeAccuracyWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeAccuracyWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeRangesWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeRangesWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeRangesWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeVoltageWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeVoltageWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeVoltageWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeActiveCurrentWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeActiveCurrentWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeActiveCurrentWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeReactiveCurrentWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeReactiveCurrentWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeReactiveCurrentWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeApparentCurrentWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeApparentCurrentWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeApparentCurrentWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeActivePowerWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeActivePowerWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeActivePowerWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeReactivePowerWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeReactivePowerWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeReactivePowerWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeApparentPowerWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeApparentPowerWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeApparentPowerWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeRMSVoltageWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeRMSVoltageWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeRMSVoltageWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeRMSCurrentWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeRMSCurrentWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeRMSCurrentWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeRMSPowerWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeRMSPowerWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeRMSPowerWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeFrequencyWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeFrequencyWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeFrequencyWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeHarmonicCurrentsWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeHarmonicCurrentsWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeHarmonicCurrentsWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeHarmonicPhasesWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeHarmonicPhasesWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeHarmonicPhasesWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributePowerFactorWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributePowerFactorWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributePowerFactorWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeNeutralCurrentWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeNeutralCurrentWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeNeutralCurrentWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeGeneratedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeAcceptedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeAcceptedCommandListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeAcceptedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeEventListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeEventListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeEventListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeAttributeListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeAttributeListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeAttributeListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeFeatureMapWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeFeatureMapWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeFeatureMapWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeClusterRevisionWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeClusterRevisionWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeClusterRevisionWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +@interface MTRBaseClusterElectricalPowerMeasurement (Availability) + +/** + * For all instance methods (reads, writes, commands) that take a completion, + * the completion will be called on the provided queue. + */ +- (instancetype _Nullable)initWithDevice:(MTRBaseDevice *)device + endpointID:(NSNumber *)endpointID + queue:(dispatch_queue_t)queue MTR_PROVISIONALLY_AVAILABLE; + +@end + /** * Cluster Electrical Energy Measurement * @@ -7264,6 +7445,12 @@ MTR_PROVISIONALLY_AVAILABLE reportHandler:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; + (void)readAttributePeriodicEnergyExportedWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)readAttributeCumulativeEnergyResetWithCompletion:(void (^)(MTRElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeCumulativeEnergyResetWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeCumulativeEnergyResetWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + - (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; - (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams *)params subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished @@ -8064,6 +8251,79 @@ MTR_PROVISIONALLY_AVAILABLE @end +/** + * Cluster Power Topology + * + * The Power Topology Cluster provides a mechanism for expressing how power is flowing between endpoints. + */ +MTR_PROVISIONALLY_AVAILABLE +@interface MTRBaseClusterPowerTopology : MTRGenericBaseCluster + +- (void)readAttributeAvailableEndpointsWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeAvailableEndpointsWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeAvailableEndpointsWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeActiveEndpointsWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeActiveEndpointsWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeActiveEndpointsWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeGeneratedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeAcceptedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeAcceptedCommandListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeAcceptedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeEventListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeEventListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeEventListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeAttributeListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeAttributeListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeAttributeListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeFeatureMapWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeFeatureMapWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeFeatureMapWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeClusterRevisionWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeClusterRevisionWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeClusterRevisionWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +@interface MTRBaseClusterPowerTopology (Availability) + +/** + * For all instance methods (reads, writes, commands) that take a completion, + * the completion will be called on the provided queue. + */ +- (instancetype _Nullable)initWithDevice:(MTRBaseDevice *)device + endpointID:(NSNumber *)endpointID + queue:(dispatch_queue_t)queue MTR_PROVISIONALLY_AVAILABLE; + +@end + /** * Cluster Energy EVSE Mode * @@ -16805,6 +17065,10 @@ typedef NS_ENUM(uint8_t, MTRGeneralDiagnosticsRadioFaultType) { MTRGeneralDiagnosticsRadioFaultTypeEthernetFault MTR_DEPRECATED("Please use MTRGeneralDiagnosticsRadioFaultEthernetFault", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)) = 0x06, } MTR_DEPRECATED("Please use MTRGeneralDiagnosticsRadioFault", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); +typedef NS_OPTIONS(uint32_t, MTRGeneralDiagnosticsFeature) { + MTRGeneralDiagnosticsFeatureDataModelTest MTR_PROVISIONALLY_AVAILABLE = 0x1, +} MTR_PROVISIONALLY_AVAILABLE; + typedef NS_OPTIONS(uint32_t, MTRSoftwareDiagnosticsFeature) { MTRSoftwareDiagnosticsFeatureWatermarks MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) = 0x1, MTRSoftwareDiagnosticsFeatureWaterMarks MTR_DEPRECATED("Please use MTRSoftwareDiagnosticsFeatureWatermarks", ios(16.1, 17.4), macos(13.0, 14.4), watchos(9.1, 10.4), tvos(16.1, 17.4)) = 0x1, @@ -17476,6 +17740,38 @@ typedef NS_OPTIONS(uint16_t, MTRValveConfigurationAndControlValveFaultBitmap) { MTRValveConfigurationAndControlValveFaultBitmapCurrentExceeded MTR_PROVISIONALLY_AVAILABLE = 0x20, } MTR_PROVISIONALLY_AVAILABLE; +typedef NS_ENUM(uint16_t, MTRElectricalPowerMeasurementMeasurementType) { + MTRElectricalPowerMeasurementMeasurementTypeUnspecified MTR_PROVISIONALLY_AVAILABLE = 0x00, + MTRElectricalPowerMeasurementMeasurementTypeVoltage MTR_PROVISIONALLY_AVAILABLE = 0x01, + MTRElectricalPowerMeasurementMeasurementTypeActiveCurrent MTR_PROVISIONALLY_AVAILABLE = 0x02, + MTRElectricalPowerMeasurementMeasurementTypeReactiveCurrent MTR_PROVISIONALLY_AVAILABLE = 0x03, + MTRElectricalPowerMeasurementMeasurementTypeApparentCurrent MTR_PROVISIONALLY_AVAILABLE = 0x04, + MTRElectricalPowerMeasurementMeasurementTypeActivePower MTR_PROVISIONALLY_AVAILABLE = 0x05, + MTRElectricalPowerMeasurementMeasurementTypeReactivePower MTR_PROVISIONALLY_AVAILABLE = 0x06, + MTRElectricalPowerMeasurementMeasurementTypeApparentPower MTR_PROVISIONALLY_AVAILABLE = 0x07, + MTRElectricalPowerMeasurementMeasurementTypeRMSVoltage MTR_PROVISIONALLY_AVAILABLE = 0x08, + MTRElectricalPowerMeasurementMeasurementTypeRMSCurrent MTR_PROVISIONALLY_AVAILABLE = 0x09, + MTRElectricalPowerMeasurementMeasurementTypeRMSPower MTR_PROVISIONALLY_AVAILABLE = 0x0A, + MTRElectricalPowerMeasurementMeasurementTypeFrequency MTR_PROVISIONALLY_AVAILABLE = 0x0B, + MTRElectricalPowerMeasurementMeasurementTypePowerFactor MTR_PROVISIONALLY_AVAILABLE = 0x0C, + MTRElectricalPowerMeasurementMeasurementTypeNeutralCurrent MTR_PROVISIONALLY_AVAILABLE = 0x0D, + MTRElectricalPowerMeasurementMeasurementTypeElectricalEnergy MTR_PROVISIONALLY_AVAILABLE = 0x0E, +} MTR_PROVISIONALLY_AVAILABLE; + +typedef NS_ENUM(uint8_t, MTRElectricalPowerMeasurementPowerMode) { + MTRElectricalPowerMeasurementPowerModeUnknown MTR_PROVISIONALLY_AVAILABLE = 0x00, + MTRElectricalPowerMeasurementPowerModeDC MTR_PROVISIONALLY_AVAILABLE = 0x01, + MTRElectricalPowerMeasurementPowerModeAC MTR_PROVISIONALLY_AVAILABLE = 0x02, +} MTR_PROVISIONALLY_AVAILABLE; + +typedef NS_OPTIONS(uint32_t, MTRElectricalPowerMeasurementFeature) { + MTRElectricalPowerMeasurementFeatureDirectCurrent MTR_PROVISIONALLY_AVAILABLE = 0x1, + MTRElectricalPowerMeasurementFeatureAlternatingCurrent MTR_PROVISIONALLY_AVAILABLE = 0x2, + MTRElectricalPowerMeasurementFeaturePolyphasePower MTR_PROVISIONALLY_AVAILABLE = 0x4, + MTRElectricalPowerMeasurementFeatureHarmonics MTR_PROVISIONALLY_AVAILABLE = 0x8, + MTRElectricalPowerMeasurementFeaturePowerQuality MTR_PROVISIONALLY_AVAILABLE = 0x10, +} MTR_PROVISIONALLY_AVAILABLE; + typedef NS_ENUM(uint16_t, MTRElectricalEnergyMeasurementMeasurementType) { MTRElectricalEnergyMeasurementMeasurementTypeUnspecified MTR_PROVISIONALLY_AVAILABLE = 0x00, MTRElectricalEnergyMeasurementMeasurementTypeVoltage MTR_PROVISIONALLY_AVAILABLE = 0x01, @@ -17757,6 +18053,13 @@ typedef NS_OPTIONS(uint32_t, MTREnergyPreferenceFeature) { MTREnergyPreferenceFeatureLowPowerModeSensitivity MTR_PROVISIONALLY_AVAILABLE = 0x2, } MTR_PROVISIONALLY_AVAILABLE; +typedef NS_OPTIONS(uint32_t, MTRPowerTopologyFeature) { + MTRPowerTopologyFeatureNodeTopology MTR_PROVISIONALLY_AVAILABLE = 0x1, + MTRPowerTopologyFeatureTreeTopology MTR_PROVISIONALLY_AVAILABLE = 0x2, + MTRPowerTopologyFeatureSetTopology MTR_PROVISIONALLY_AVAILABLE = 0x4, + MTRPowerTopologyFeatureDynamicPowerFlow MTR_PROVISIONALLY_AVAILABLE = 0x8, +} MTR_PROVISIONALLY_AVAILABLE; + typedef NS_ENUM(uint16_t, MTREnergyEVSEModeModeTag) { MTREnergyEVSEModeModeTagManual MTR_PROVISIONALLY_AVAILABLE = 0x4000, MTREnergyEVSEModeModeTagTimeOfUse MTR_PROVISIONALLY_AVAILABLE = 0x4001, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm index 50e411dad70331..8cca4c8ed5a7d5 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm @@ -30,9 +30,9 @@ #import "NSStringSpanConversion.h" #include +#include #include #include -#include #include #include @@ -20674,6 +20674,30 @@ - (void)timeSnapshotWithParams:(MTRGeneralDiagnosticsClusterTimeSnapshotParams * queue:self.callbackQueue completion:responseHandler]; } +- (void)payloadTestRequestWithParams:(MTRGeneralDiagnosticsClusterPayloadTestRequestParams *)params completion:(void (^)(MTRGeneralDiagnosticsClusterPayloadTestResponseParams * _Nullable data, NSError * _Nullable error))completion +{ + if (params == nil) { + params = [[MTRGeneralDiagnosticsClusterPayloadTestRequestParams + alloc] init]; + } + + auto responseHandler = ^(id _Nullable response, NSError * _Nullable error) { + completion(response, error); + }; + + auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs; + + using RequestType = GeneralDiagnostics::Commands::PayloadTestRequest::Type; + [self.device _invokeKnownCommandWithEndpointID:self.endpointID + clusterID:@(RequestType::GetClusterId()) + commandID:@(RequestType::GetCommandId()) + commandPayload:params + timedInvokeTimeout:timedInvokeTimeoutMs + serverSideProcessingTimeout:params.serverSideProcessingTimeout + responseClass:MTRGeneralDiagnosticsClusterPayloadTestResponseParams.class + queue:self.callbackQueue + completion:responseHandler]; +} - (void)readAttributeNetworkInterfacesWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion { @@ -49725,6 +49749,910 @@ + (void)readAttributeClusterRevisionWithClusterStateCache:(MTRClusterStateCacheC @end +@implementation MTRBaseClusterElectricalPowerMeasurement + +- (void)readAttributePowerModeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::PowerMode::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributePowerModeWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::PowerMode::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributePowerModeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::PowerMode::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeNumberOfMeasurementTypesWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::NumberOfMeasurementTypes::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeNumberOfMeasurementTypesWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::NumberOfMeasurementTypes::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeNumberOfMeasurementTypesWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::NumberOfMeasurementTypes::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeAccuracyWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::Accuracy::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeAccuracyWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::Accuracy::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeAccuracyWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::Accuracy::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeRangesWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::Ranges::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeRangesWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::Ranges::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeRangesWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::Ranges::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeVoltageWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::Voltage::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeVoltageWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::Voltage::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeVoltageWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::Voltage::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeActiveCurrentWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ActiveCurrent::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeActiveCurrentWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ActiveCurrent::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeActiveCurrentWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ActiveCurrent::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeReactiveCurrentWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ReactiveCurrent::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeReactiveCurrentWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ReactiveCurrent::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeReactiveCurrentWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ReactiveCurrent::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeApparentCurrentWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ApparentCurrent::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeApparentCurrentWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ApparentCurrent::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeApparentCurrentWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ApparentCurrent::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeActivePowerWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ActivePower::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeActivePowerWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ActivePower::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeActivePowerWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ActivePower::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeReactivePowerWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ReactivePower::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeReactivePowerWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ReactivePower::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeReactivePowerWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ReactivePower::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeApparentPowerWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ApparentPower::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeApparentPowerWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ApparentPower::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeApparentPowerWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ApparentPower::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeRMSVoltageWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::RMSVoltage::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeRMSVoltageWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::RMSVoltage::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeRMSVoltageWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::RMSVoltage::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeRMSCurrentWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::RMSCurrent::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeRMSCurrentWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::RMSCurrent::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeRMSCurrentWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::RMSCurrent::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeRMSPowerWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::RMSPower::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeRMSPowerWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::RMSPower::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeRMSPowerWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::RMSPower::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeFrequencyWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::Frequency::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeFrequencyWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::Frequency::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeFrequencyWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::Frequency::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeHarmonicCurrentsWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::HarmonicCurrents::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeHarmonicCurrentsWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::HarmonicCurrents::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeHarmonicCurrentsWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::HarmonicCurrents::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeHarmonicPhasesWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::HarmonicPhases::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeHarmonicPhasesWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::HarmonicPhases::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeHarmonicPhasesWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::HarmonicPhases::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributePowerFactorWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::PowerFactor::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributePowerFactorWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::PowerFactor::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributePowerFactorWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::PowerFactor::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeNeutralCurrentWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::NeutralCurrent::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeNeutralCurrentWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::NeutralCurrent::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeNeutralCurrentWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::NeutralCurrent::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::GeneratedCommandList::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::GeneratedCommandList::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeGeneratedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::GeneratedCommandList::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeAcceptedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::AcceptedCommandList::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeAcceptedCommandListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::AcceptedCommandList::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeAcceptedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::AcceptedCommandList::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeEventListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::EventList::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeEventListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::EventList::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeEventListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::EventList::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeAttributeListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::AttributeList::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeAttributeListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::AttributeList::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeAttributeListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::AttributeList::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeFeatureMapWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::FeatureMap::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeFeatureMapWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::FeatureMap::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeFeatureMapWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::FeatureMap::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeClusterRevisionWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ClusterRevision::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeClusterRevisionWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ClusterRevision::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeClusterRevisionWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalPowerMeasurement::Attributes::ClusterRevision::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +@end + @implementation MTRBaseClusterElectricalEnergyMeasurement - (void)readAttributeAccuracyWithCompletion:(void (^)(MTRElectricalEnergyMeasurementClusterMeasurementAccuracyStruct * _Nullable value, NSError * _Nullable error))completion @@ -49907,6 +50835,42 @@ + (void)readAttributePeriodicEnergyExportedWithClusterStateCache:(MTRClusterStat completion:completion]; } +- (void)readAttributeCumulativeEnergyResetWithCompletion:(void (^)(MTRElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::CumulativeEnergyReset::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeCumulativeEnergyResetWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::CumulativeEnergyReset::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeCumulativeEnergyResetWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::CumulativeEnergyReset::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + - (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion { using TypeInfo = ElectricalEnergyMeasurement::Attributes::GeneratedCommandList::TypeInfo; @@ -53667,6 +54631,298 @@ + (void)readAttributeClusterRevisionWithClusterStateCache:(MTRClusterStateCacheC @end +@implementation MTRBaseClusterPowerTopology + +- (void)readAttributeAvailableEndpointsWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::AvailableEndpoints::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeAvailableEndpointsWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = PowerTopology::Attributes::AvailableEndpoints::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeAvailableEndpointsWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::AvailableEndpoints::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeActiveEndpointsWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::ActiveEndpoints::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeActiveEndpointsWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = PowerTopology::Attributes::ActiveEndpoints::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeActiveEndpointsWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::ActiveEndpoints::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::GeneratedCommandList::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = PowerTopology::Attributes::GeneratedCommandList::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeGeneratedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::GeneratedCommandList::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeAcceptedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::AcceptedCommandList::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeAcceptedCommandListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = PowerTopology::Attributes::AcceptedCommandList::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeAcceptedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::AcceptedCommandList::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeEventListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::EventList::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeEventListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = PowerTopology::Attributes::EventList::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeEventListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::EventList::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeAttributeListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::AttributeList::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeAttributeListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = PowerTopology::Attributes::AttributeList::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeAttributeListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::AttributeList::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeFeatureMapWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::FeatureMap::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeFeatureMapWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = PowerTopology::Attributes::FeatureMap::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeFeatureMapWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::FeatureMap::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeClusterRevisionWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::ClusterRevision::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeClusterRevisionWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = PowerTopology::Attributes::ClusterRevision::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeClusterRevisionWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = PowerTopology::Attributes::ClusterRevision::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +@end + @implementation MTRBaseClusterEnergyEVSEMode - (void)changeToModeWithParams:(MTREnergyEVSEModeClusterChangeToModeParams *)params completion:(void (^)(MTREnergyEVSEModeClusterChangeToModeResponseParams * _Nullable data, NSError * _Nullable error))completion diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h index 75aabe383e68c4..a3351bc74d12d1 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -149,12 +149,14 @@ typedef NS_ENUM(uint32_t, MTRClusterIDType) { MTRClusterIDTypeActivatedCarbonFilterMonitoringID MTR_PROVISIONALLY_AVAILABLE = 0x00000072, MTRClusterIDTypeBooleanStateConfigurationID MTR_PROVISIONALLY_AVAILABLE = 0x00000080, MTRClusterIDTypeValveConfigurationAndControlID MTR_PROVISIONALLY_AVAILABLE = 0x00000081, + MTRClusterIDTypeElectricalPowerMeasurementID MTR_PROVISIONALLY_AVAILABLE = 0x00000090, MTRClusterIDTypeElectricalEnergyMeasurementID MTR_PROVISIONALLY_AVAILABLE = 0x00000091, MTRClusterIDTypeDemandResponseLoadControlID MTR_PROVISIONALLY_AVAILABLE = 0x00000096, MTRClusterIDTypeMessagesID MTR_PROVISIONALLY_AVAILABLE = 0x00000097, MTRClusterIDTypeDeviceEnergyManagementID MTR_PROVISIONALLY_AVAILABLE = 0x00000098, MTRClusterIDTypeEnergyEVSEID MTR_PROVISIONALLY_AVAILABLE = 0x00000099, MTRClusterIDTypeEnergyPreferenceID MTR_PROVISIONALLY_AVAILABLE = 0x0000009B, + MTRClusterIDTypePowerTopologyID MTR_PROVISIONALLY_AVAILABLE = 0x0000009C, MTRClusterIDTypeEnergyEVSEModeID MTR_PROVISIONALLY_AVAILABLE = 0x0000009D, MTRClusterIDTypeDeviceEnergyManagementModeID MTR_PROVISIONALLY_AVAILABLE = 0x0000009F, MTRClusterIDTypeDoorLockID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000101, @@ -2577,12 +2579,40 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeFeatureMapID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeFeatureMapID, MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeClusterRevisionID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeClusterRevisionID, + // Cluster ElectricalPowerMeasurement attributes + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributePowerModeID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeNumberOfMeasurementTypesID MTR_PROVISIONALLY_AVAILABLE = 0x00000001, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeAccuracyID MTR_PROVISIONALLY_AVAILABLE = 0x00000002, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRangesID MTR_PROVISIONALLY_AVAILABLE = 0x00000003, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeVoltageID MTR_PROVISIONALLY_AVAILABLE = 0x00000004, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeActiveCurrentID MTR_PROVISIONALLY_AVAILABLE = 0x00000005, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeReactiveCurrentID MTR_PROVISIONALLY_AVAILABLE = 0x00000006, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeApparentCurrentID MTR_PROVISIONALLY_AVAILABLE = 0x00000007, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeActivePowerID MTR_PROVISIONALLY_AVAILABLE = 0x00000008, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeReactivePowerID MTR_PROVISIONALLY_AVAILABLE = 0x00000009, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeApparentPowerID MTR_PROVISIONALLY_AVAILABLE = 0x0000000A, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRMSVoltageID MTR_PROVISIONALLY_AVAILABLE = 0x0000000B, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRMSCurrentID MTR_PROVISIONALLY_AVAILABLE = 0x0000000C, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRMSPowerID MTR_PROVISIONALLY_AVAILABLE = 0x0000000D, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeFrequencyID MTR_PROVISIONALLY_AVAILABLE = 0x0000000E, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeHarmonicCurrentsID MTR_PROVISIONALLY_AVAILABLE = 0x0000000F, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeHarmonicPhasesID MTR_PROVISIONALLY_AVAILABLE = 0x00000010, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributePowerFactorID MTR_PROVISIONALLY_AVAILABLE = 0x00000011, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeNeutralCurrentID MTR_PROVISIONALLY_AVAILABLE = 0x00000012, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeGeneratedCommandListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeAcceptedCommandListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeEventListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeEventListID, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeAttributeListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeAttributeListID, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeFeatureMapID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeFeatureMapID, + MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeClusterRevisionID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeClusterRevisionID, + // Cluster ElectricalEnergyMeasurement attributes MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeAccuracyID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeCumulativeEnergyImportedID MTR_PROVISIONALLY_AVAILABLE = 0x00000001, MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeCumulativeEnergyExportedID MTR_PROVISIONALLY_AVAILABLE = 0x00000002, MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributePeriodicEnergyImportedID MTR_PROVISIONALLY_AVAILABLE = 0x00000003, MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributePeriodicEnergyExportedID MTR_PROVISIONALLY_AVAILABLE = 0x00000004, + MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeCumulativeEnergyResetID MTR_PROVISIONALLY_AVAILABLE = 0x00000005, MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeGeneratedCommandListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID, MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeAcceptedCommandListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID, MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeEventListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeEventListID, @@ -2676,6 +2706,16 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { MTRAttributeIDTypeClusterEnergyPreferenceAttributeFeatureMapID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeFeatureMapID, MTRAttributeIDTypeClusterEnergyPreferenceAttributeClusterRevisionID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeClusterRevisionID, + // Cluster PowerTopology attributes + MTRAttributeIDTypeClusterPowerTopologyAttributeAvailableEndpointsID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, + MTRAttributeIDTypeClusterPowerTopologyAttributeActiveEndpointsID MTR_PROVISIONALLY_AVAILABLE = 0x00000001, + MTRAttributeIDTypeClusterPowerTopologyAttributeGeneratedCommandListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID, + MTRAttributeIDTypeClusterPowerTopologyAttributeAcceptedCommandListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID, + MTRAttributeIDTypeClusterPowerTopologyAttributeEventListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeEventListID, + MTRAttributeIDTypeClusterPowerTopologyAttributeAttributeListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeAttributeListID, + MTRAttributeIDTypeClusterPowerTopologyAttributeFeatureMapID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeFeatureMapID, + MTRAttributeIDTypeClusterPowerTopologyAttributeClusterRevisionID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeClusterRevisionID, + // Cluster EnergyEVSEMode attributes MTRAttributeIDTypeClusterEnergyEVSEModeAttributeSupportedModesID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, MTRAttributeIDTypeClusterEnergyEVSEModeAttributeCurrentModeID MTR_PROVISIONALLY_AVAILABLE = 0x00000001, @@ -5978,6 +6018,8 @@ typedef NS_ENUM(uint32_t, MTRCommandIDType) { MTRCommandIDTypeClusterGeneralDiagnosticsCommandTestEventTriggerID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000000, MTRCommandIDTypeClusterGeneralDiagnosticsCommandTimeSnapshotID MTR_PROVISIONALLY_AVAILABLE = 0x00000001, MTRCommandIDTypeClusterGeneralDiagnosticsCommandTimeSnapshotResponseID MTR_PROVISIONALLY_AVAILABLE = 0x00000002, + MTRCommandIDTypeClusterGeneralDiagnosticsCommandPayloadTestRequestID MTR_PROVISIONALLY_AVAILABLE = 0x00000003, + MTRCommandIDTypeClusterGeneralDiagnosticsCommandPayloadTestResponseID MTR_PROVISIONALLY_AVAILABLE = 0x00000004, // Cluster SoftwareDiagnostics deprecated command id names MTRClusterSoftwareDiagnosticsCommandResetWatermarksID @@ -7156,6 +7198,9 @@ typedef NS_ENUM(uint32_t, MTREventIDType) { MTREventIDTypeClusterValveConfigurationAndControlEventValveStateChangedID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, MTREventIDTypeClusterValveConfigurationAndControlEventValveFaultID MTR_PROVISIONALLY_AVAILABLE = 0x00000001, + // Cluster ElectricalPowerMeasurement events + MTREventIDTypeClusterElectricalPowerMeasurementEventMeasurementPeriodRangesID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, + // Cluster ElectricalEnergyMeasurement events MTREventIDTypeClusterElectricalEnergyMeasurementEventCumulativeEnergyMeasuredID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, MTREventIDTypeClusterElectricalEnergyMeasurementEventPeriodicEnergyMeasuredID MTR_PROVISIONALLY_AVAILABLE = 0x00000001, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterNames.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusterNames.mm new file mode 100644 index 00000000000000..474c5cacf47679 --- /dev/null +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterNames.mm @@ -0,0 +1,8817 @@ +/* + * + * 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. + */ + +#import + +// @implementation MTRClusterAttributeIDType + +#pragma mark - Clusters IDs + +NSString * MTRClusterNameForID(MTRClusterIDType clusterID) +{ + NSString * result = nil; + + switch (clusterID) { + + case MTRClusterIDTypeIdentifyID: + result = @"Identify"; + break; + case MTRClusterIDTypeGroupsID: + result = @"Groups"; + break; + case MTRClusterIDTypeOnOffID: + result = @"OnOff"; + break; + case MTRClusterIDTypeOnOffSwitchConfigurationID: + result = @"OnOffSwitchConfiguration"; + break; + case MTRClusterIDTypeLevelControlID: + result = @"LevelControl"; + break; + case MTRClusterIDTypeBinaryInputBasicID: + result = @"BinaryInputBasic"; + break; + case MTRClusterIDTypePulseWidthModulationID: + result = @"PulseWidthModulation"; + break; + case MTRClusterIDTypeDescriptorID: + result = @"Descriptor"; + break; + case MTRClusterIDTypeBindingID: + result = @"Binding"; + break; + case MTRClusterIDTypeAccessControlID: + result = @"AccessControl"; + break; + case MTRClusterIDTypeActionsID: + result = @"Actions"; + break; + case MTRClusterIDTypeBasicInformationID: + result = @"BasicInformation"; + break; + case MTRClusterIDTypeOTASoftwareUpdateProviderID: + result = @"OTASoftwareUpdateProvider"; + break; + case MTRClusterIDTypeOTASoftwareUpdateRequestorID: + result = @"OTASoftwareUpdateRequestor"; + break; + case MTRClusterIDTypeLocalizationConfigurationID: + result = @"LocalizationConfiguration"; + break; + case MTRClusterIDTypeTimeFormatLocalizationID: + result = @"TimeFormatLocalization"; + break; + case MTRClusterIDTypeUnitLocalizationID: + result = @"UnitLocalization"; + break; + case MTRClusterIDTypePowerSourceConfigurationID: + result = @"PowerSourceConfiguration"; + break; + case MTRClusterIDTypePowerSourceID: + result = @"PowerSource"; + break; + case MTRClusterIDTypeGeneralCommissioningID: + result = @"GeneralCommissioning"; + break; + case MTRClusterIDTypeNetworkCommissioningID: + result = @"NetworkCommissioning"; + break; + case MTRClusterIDTypeDiagnosticLogsID: + result = @"DiagnosticLogs"; + break; + case MTRClusterIDTypeGeneralDiagnosticsID: + result = @"GeneralDiagnostics"; + break; + case MTRClusterIDTypeSoftwareDiagnosticsID: + result = @"SoftwareDiagnostics"; + break; + case MTRClusterIDTypeThreadNetworkDiagnosticsID: + result = @"ThreadNetworkDiagnostics"; + break; + case MTRClusterIDTypeWiFiNetworkDiagnosticsID: + result = @"WiFiNetworkDiagnostics"; + break; + case MTRClusterIDTypeEthernetNetworkDiagnosticsID: + result = @"EthernetNetworkDiagnostics"; + break; + case MTRClusterIDTypeTimeSynchronizationID: + result = @"TimeSynchronization"; + break; + case MTRClusterIDTypeBridgedDeviceBasicInformationID: + result = @"BridgedDeviceBasicInformation"; + break; + case MTRClusterIDTypeSwitchID: + result = @"Switch"; + break; + case MTRClusterIDTypeAdministratorCommissioningID: + result = @"AdministratorCommissioning"; + break; + case MTRClusterIDTypeOperationalCredentialsID: + result = @"OperationalCredentials"; + break; + case MTRClusterIDTypeGroupKeyManagementID: + result = @"GroupKeyManagement"; + break; + case MTRClusterIDTypeFixedLabelID: + result = @"FixedLabel"; + break; + case MTRClusterIDTypeUserLabelID: + result = @"UserLabel"; + break; + case MTRClusterIDTypeBooleanStateID: + result = @"BooleanState"; + break; + case MTRClusterIDTypeICDManagementID: + result = @"ICDManagement"; + break; + case MTRClusterIDTypeTimerID: + result = @"Timer"; + break; + case MTRClusterIDTypeOvenCavityOperationalStateID: + result = @"OvenCavityOperationalState"; + break; + case MTRClusterIDTypeOvenModeID: + result = @"OvenMode"; + break; + case MTRClusterIDTypeLaundryDryerControlsID: + result = @"LaundryDryerControls"; + break; + case MTRClusterIDTypeModeSelectID: + result = @"ModeSelect"; + break; + case MTRClusterIDTypeLaundryWasherModeID: + result = @"LaundryWasherMode"; + break; + case MTRClusterIDTypeRefrigeratorAndTemperatureControlledCabinetModeID: + result = @"RefrigeratorAndTemperatureControlledCabinetMode"; + break; + case MTRClusterIDTypeLaundryWasherControlsID: + result = @"LaundryWasherControls"; + break; + case MTRClusterIDTypeRVCRunModeID: + result = @"RVCRunMode"; + break; + case MTRClusterIDTypeRVCCleanModeID: + result = @"RVCCleanMode"; + break; + case MTRClusterIDTypeTemperatureControlID: + result = @"TemperatureControl"; + break; + case MTRClusterIDTypeRefrigeratorAlarmID: + result = @"RefrigeratorAlarm"; + break; + case MTRClusterIDTypeDishwasherModeID: + result = @"DishwasherMode"; + break; + case MTRClusterIDTypeAirQualityID: + result = @"AirQuality"; + break; + case MTRClusterIDTypeSmokeCOAlarmID: + result = @"SmokeCOAlarm"; + break; + case MTRClusterIDTypeDishwasherAlarmID: + result = @"DishwasherAlarm"; + break; + case MTRClusterIDTypeMicrowaveOvenModeID: + result = @"MicrowaveOvenMode"; + break; + case MTRClusterIDTypeMicrowaveOvenControlID: + result = @"MicrowaveOvenControl"; + break; + case MTRClusterIDTypeOperationalStateID: + result = @"OperationalState"; + break; + case MTRClusterIDTypeRVCOperationalStateID: + result = @"RVCOperationalState"; + break; + case MTRClusterIDTypeScenesManagementID: + result = @"ScenesManagement"; + break; + case MTRClusterIDTypeHEPAFilterMonitoringID: + result = @"HEPAFilterMonitoring"; + break; + case MTRClusterIDTypeActivatedCarbonFilterMonitoringID: + result = @"ActivatedCarbonFilterMonitoring"; + break; + case MTRClusterIDTypeBooleanStateConfigurationID: + result = @"BooleanStateConfiguration"; + break; + case MTRClusterIDTypeValveConfigurationAndControlID: + result = @"ValveConfigurationAndControl"; + break; + case MTRClusterIDTypeElectricalPowerMeasurementID: + result = @"ElectricalPowerMeasurement"; + break; + case MTRClusterIDTypeElectricalEnergyMeasurementID: + result = @"ElectricalEnergyMeasurement"; + break; + case MTRClusterIDTypeDemandResponseLoadControlID: + result = @"DemandResponseLoadControl"; + break; + case MTRClusterIDTypeMessagesID: + result = @"Messages"; + break; + case MTRClusterIDTypeDeviceEnergyManagementID: + result = @"DeviceEnergyManagement"; + break; + case MTRClusterIDTypeEnergyEVSEID: + result = @"EnergyEVSE"; + break; + case MTRClusterIDTypeEnergyPreferenceID: + result = @"EnergyPreference"; + break; + case MTRClusterIDTypePowerTopologyID: + result = @"PowerTopology"; + break; + case MTRClusterIDTypeEnergyEVSEModeID: + result = @"EnergyEVSEMode"; + break; + case MTRClusterIDTypeDeviceEnergyManagementModeID: + result = @"DeviceEnergyManagementMode"; + break; + case MTRClusterIDTypeDoorLockID: + result = @"DoorLock"; + break; + case MTRClusterIDTypeWindowCoveringID: + result = @"WindowCovering"; + break; + case MTRClusterIDTypeBarrierControlID: + result = @"BarrierControl"; + break; + case MTRClusterIDTypePumpConfigurationAndControlID: + result = @"PumpConfigurationAndControl"; + break; + case MTRClusterIDTypeThermostatID: + result = @"Thermostat"; + break; + case MTRClusterIDTypeFanControlID: + result = @"FanControl"; + break; + case MTRClusterIDTypeThermostatUserInterfaceConfigurationID: + result = @"ThermostatUserInterfaceConfiguration"; + break; + case MTRClusterIDTypeColorControlID: + result = @"ColorControl"; + break; + case MTRClusterIDTypeBallastConfigurationID: + result = @"BallastConfiguration"; + break; + case MTRClusterIDTypeIlluminanceMeasurementID: + result = @"IlluminanceMeasurement"; + break; + case MTRClusterIDTypeTemperatureMeasurementID: + result = @"TemperatureMeasurement"; + break; + case MTRClusterIDTypePressureMeasurementID: + result = @"PressureMeasurement"; + break; + case MTRClusterIDTypeFlowMeasurementID: + result = @"FlowMeasurement"; + break; + case MTRClusterIDTypeRelativeHumidityMeasurementID: + result = @"RelativeHumidityMeasurement"; + break; + case MTRClusterIDTypeOccupancySensingID: + result = @"OccupancySensing"; + break; + case MTRClusterIDTypeCarbonMonoxideConcentrationMeasurementID: + result = @"CarbonMonoxideConcentrationMeasurement"; + break; + case MTRClusterIDTypeCarbonDioxideConcentrationMeasurementID: + result = @"CarbonDioxideConcentrationMeasurement"; + break; + case MTRClusterIDTypeNitrogenDioxideConcentrationMeasurementID: + result = @"NitrogenDioxideConcentrationMeasurement"; + break; + case MTRClusterIDTypeOzoneConcentrationMeasurementID: + result = @"OzoneConcentrationMeasurement"; + break; + case MTRClusterIDTypePM25ConcentrationMeasurementID: + result = @"PM25ConcentrationMeasurement"; + break; + case MTRClusterIDTypeFormaldehydeConcentrationMeasurementID: + result = @"FormaldehydeConcentrationMeasurement"; + break; + case MTRClusterIDTypePM1ConcentrationMeasurementID: + result = @"PM1ConcentrationMeasurement"; + break; + case MTRClusterIDTypePM10ConcentrationMeasurementID: + result = @"PM10ConcentrationMeasurement"; + break; + case MTRClusterIDTypeTotalVolatileOrganicCompoundsConcentrationMeasurementID: + result = @"TotalVolatileOrganicCompoundsConcentrationMeasurement"; + break; + case MTRClusterIDTypeRadonConcentrationMeasurementID: + result = @"RadonConcentrationMeasurement"; + break; + case MTRClusterIDTypeWakeOnLANID: + result = @"WakeOnLAN"; + break; + case MTRClusterIDTypeChannelID: + result = @"Channel"; + break; + case MTRClusterIDTypeTargetNavigatorID: + result = @"TargetNavigator"; + break; + case MTRClusterIDTypeMediaPlaybackID: + result = @"MediaPlayback"; + break; + case MTRClusterIDTypeMediaInputID: + result = @"MediaInput"; + break; + case MTRClusterIDTypeLowPowerID: + result = @"LowPower"; + break; + case MTRClusterIDTypeKeypadInputID: + result = @"KeypadInput"; + break; + case MTRClusterIDTypeContentLauncherID: + result = @"ContentLauncher"; + break; + case MTRClusterIDTypeAudioOutputID: + result = @"AudioOutput"; + break; + case MTRClusterIDTypeApplicationLauncherID: + result = @"ApplicationLauncher"; + break; + case MTRClusterIDTypeApplicationBasicID: + result = @"ApplicationBasic"; + break; + case MTRClusterIDTypeAccountLoginID: + result = @"AccountLogin"; + break; + case MTRClusterIDTypeContentControlID: + result = @"ContentControl"; + break; + case MTRClusterIDTypeContentAppObserverID: + result = @"ContentAppObserver"; + break; + case MTRClusterIDTypeElectricalMeasurementID: + result = @"ElectricalMeasurement"; + break; + case MTRClusterIDTypeUnitTestingID: + result = @"UnitTesting"; + break; + case MTRClusterIDTypeSampleMEIID: + result = @"SampleMEI"; + break; + + default: + result = [NSString stringWithFormat:@"", clusterID]; + break; + } + + return result; +} + +#pragma mark - Attributes IDs + +NSString * MTRAttributeNameForID(MTRClusterIDType clusterID, MTRAttributeIDType attributeID) +{ + NSString * result = nil; + + switch (clusterID) { + + case MTRClusterIDTypeIdentifyID: + + switch (attributeID) { + + // Cluster Identify attributes + case MTRAttributeIDTypeClusterIdentifyAttributeIdentifyTimeID: + result = @"IdentifyTime"; + break; + + case MTRAttributeIDTypeClusterIdentifyAttributeIdentifyTypeID: + result = @"IdentifyType"; + break; + + case MTRAttributeIDTypeClusterIdentifyAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterIdentifyAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterIdentifyAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterIdentifyAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterIdentifyAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterIdentifyAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeGroupsID: + + switch (attributeID) { + + // Cluster Groups attributes + case MTRAttributeIDTypeClusterGroupsAttributeNameSupportID: + result = @"NameSupport"; + break; + + case MTRAttributeIDTypeClusterGroupsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterGroupsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterGroupsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterGroupsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterGroupsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterGroupsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOnOffID: + + switch (attributeID) { + + // Cluster OnOff attributes + case MTRAttributeIDTypeClusterOnOffAttributeOnOffID: + result = @"OnOff"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeGlobalSceneControlID: + result = @"GlobalSceneControl"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeOnTimeID: + result = @"OnTime"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeOffWaitTimeID: + result = @"OffWaitTime"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeStartUpOnOffID: + result = @"StartUpOnOff"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOnOffSwitchConfigurationID: + + switch (attributeID) { + + // Cluster OnOffSwitchConfiguration attributes + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeSwitchTypeID: + result = @"SwitchType"; + break; + + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeSwitchActionsID: + result = @"SwitchActions"; + break; + + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeLevelControlID: + + switch (attributeID) { + + // Cluster LevelControl attributes + case MTRAttributeIDTypeClusterLevelControlAttributeCurrentLevelID: + result = @"CurrentLevel"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeRemainingTimeID: + result = @"RemainingTime"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeMinLevelID: + result = @"MinLevel"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeMaxLevelID: + result = @"MaxLevel"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeCurrentFrequencyID: + result = @"CurrentFrequency"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeMinFrequencyID: + result = @"MinFrequency"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeMaxFrequencyID: + result = @"MaxFrequency"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeOptionsID: + result = @"Options"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeOnOffTransitionTimeID: + result = @"OnOffTransitionTime"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeOnLevelID: + result = @"OnLevel"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeOnTransitionTimeID: + result = @"OnTransitionTime"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeOffTransitionTimeID: + result = @"OffTransitionTime"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeDefaultMoveRateID: + result = @"DefaultMoveRate"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeStartUpCurrentLevelID: + result = @"StartUpCurrentLevel"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBinaryInputBasicID: + + switch (attributeID) { + + // Cluster BinaryInputBasic attributes + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeActiveTextID: + result = @"ActiveText"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeDescriptionID: + result = @"Description"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeInactiveTextID: + result = @"InactiveText"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeOutOfServiceID: + result = @"OutOfService"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributePolarityID: + result = @"Polarity"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributePresentValueID: + result = @"PresentValue"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeReliabilityID: + result = @"Reliability"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeStatusFlagsID: + result = @"StatusFlags"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeApplicationTypeID: + result = @"ApplicationType"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePulseWidthModulationID: + + switch (attributeID) { + + // Cluster PulseWidthModulation attributes + case MTRAttributeIDTypeClusterPulseWidthModulationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPulseWidthModulationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPulseWidthModulationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPulseWidthModulationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPulseWidthModulationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPulseWidthModulationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDescriptorID: + + switch (attributeID) { + + // Cluster Descriptor attributes + case MTRAttributeIDTypeClusterDescriptorAttributeDeviceTypeListID: + result = @"DeviceTypeList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeServerListID: + result = @"ServerList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeClientListID: + result = @"ClientList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributePartsListID: + result = @"PartsList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeTagListID: + result = @"TagList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBindingID: + + switch (attributeID) { + + // Cluster Binding attributes + case MTRAttributeIDTypeClusterBindingAttributeBindingID: + result = @"Binding"; + break; + + case MTRAttributeIDTypeClusterBindingAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBindingAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBindingAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBindingAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBindingAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBindingAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeAccessControlID: + + switch (attributeID) { + + // Cluster AccessControl attributes + case MTRAttributeIDTypeClusterAccessControlAttributeACLID: + result = @"ACL"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeExtensionID: + result = @"Extension"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeSubjectsPerAccessControlEntryID: + result = @"SubjectsPerAccessControlEntry"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeTargetsPerAccessControlEntryID: + result = @"TargetsPerAccessControlEntry"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeAccessControlEntriesPerFabricID: + result = @"AccessControlEntriesPerFabric"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeActionsID: + + switch (attributeID) { + + // Cluster Actions attributes + case MTRAttributeIDTypeClusterActionsAttributeActionListID: + result = @"ActionList"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeEndpointListsID: + result = @"EndpointLists"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeSetupURLID: + result = @"SetupURL"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBasicInformationID: + + switch (attributeID) { + + // Cluster BasicInformation attributes + case MTRAttributeIDTypeClusterBasicInformationAttributeDataModelRevisionID: + result = @"DataModelRevision"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeVendorNameID: + result = @"VendorName"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeVendorIDID: + result = @"VendorID"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeProductNameID: + result = @"ProductName"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeProductIDID: + result = @"ProductID"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeNodeLabelID: + result = @"NodeLabel"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeLocationID: + result = @"Location"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeHardwareVersionID: + result = @"HardwareVersion"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeHardwareVersionStringID: + result = @"HardwareVersionString"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeSoftwareVersionID: + result = @"SoftwareVersion"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeSoftwareVersionStringID: + result = @"SoftwareVersionString"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeManufacturingDateID: + result = @"ManufacturingDate"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributePartNumberID: + result = @"PartNumber"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeProductURLID: + result = @"ProductURL"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeProductLabelID: + result = @"ProductLabel"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeSerialNumberID: + result = @"SerialNumber"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeLocalConfigDisabledID: + result = @"LocalConfigDisabled"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeReachableID: + result = @"Reachable"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeUniqueIDID: + result = @"UniqueID"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeCapabilityMinimaID: + result = @"CapabilityMinima"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeProductAppearanceID: + result = @"ProductAppearance"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeSpecificationVersionID: + result = @"SpecificationVersion"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeMaxPathsPerInvokeID: + result = @"MaxPathsPerInvoke"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOTASoftwareUpdateProviderID: + + switch (attributeID) { + + // Cluster OTASoftwareUpdateProvider attributes + case MTRAttributeIDTypeClusterOTASoftwareUpdateProviderAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateProviderAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateProviderAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateProviderAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateProviderAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateProviderAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOTASoftwareUpdateRequestorID: + + switch (attributeID) { + + // Cluster OTASoftwareUpdateRequestor attributes + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeDefaultOTAProvidersID: + result = @"DefaultOTAProviders"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeUpdatePossibleID: + result = @"UpdatePossible"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeUpdateStateID: + result = @"UpdateState"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeUpdateStateProgressID: + result = @"UpdateStateProgress"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeLocalizationConfigurationID: + + switch (attributeID) { + + // Cluster LocalizationConfiguration attributes + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeActiveLocaleID: + result = @"ActiveLocale"; + break; + + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeSupportedLocalesID: + result = @"SupportedLocales"; + break; + + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeTimeFormatLocalizationID: + + switch (attributeID) { + + // Cluster TimeFormatLocalization attributes + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeHourFormatID: + result = @"HourFormat"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeActiveCalendarTypeID: + result = @"ActiveCalendarType"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeSupportedCalendarTypesID: + result = @"SupportedCalendarTypes"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeUnitLocalizationID: + + switch (attributeID) { + + // Cluster UnitLocalization attributes + case MTRAttributeIDTypeClusterUnitLocalizationAttributeTemperatureUnitID: + result = @"TemperatureUnit"; + break; + + case MTRAttributeIDTypeClusterUnitLocalizationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterUnitLocalizationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterUnitLocalizationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterUnitLocalizationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterUnitLocalizationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterUnitLocalizationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePowerSourceConfigurationID: + + switch (attributeID) { + + // Cluster PowerSourceConfiguration attributes + case MTRAttributeIDTypeClusterPowerSourceConfigurationAttributeSourcesID: + result = @"Sources"; + break; + + case MTRAttributeIDTypeClusterPowerSourceConfigurationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceConfigurationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceConfigurationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceConfigurationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceConfigurationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPowerSourceConfigurationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePowerSourceID: + + switch (attributeID) { + + // Cluster PowerSource attributes + case MTRAttributeIDTypeClusterPowerSourceAttributeStatusID: + result = @"Status"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeOrderID: + result = @"Order"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeDescriptionID: + result = @"Description"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeWiredAssessedInputVoltageID: + result = @"WiredAssessedInputVoltage"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeWiredAssessedInputFrequencyID: + result = @"WiredAssessedInputFrequency"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeWiredCurrentTypeID: + result = @"WiredCurrentType"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeWiredAssessedCurrentID: + result = @"WiredAssessedCurrent"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeWiredNominalVoltageID: + result = @"WiredNominalVoltage"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeWiredMaximumCurrentID: + result = @"WiredMaximumCurrent"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeWiredPresentID: + result = @"WiredPresent"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeActiveWiredFaultsID: + result = @"ActiveWiredFaults"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatVoltageID: + result = @"BatVoltage"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatPercentRemainingID: + result = @"BatPercentRemaining"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatTimeRemainingID: + result = @"BatTimeRemaining"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatChargeLevelID: + result = @"BatChargeLevel"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatReplacementNeededID: + result = @"BatReplacementNeeded"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatReplaceabilityID: + result = @"BatReplaceability"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatPresentID: + result = @"BatPresent"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeActiveBatFaultsID: + result = @"ActiveBatFaults"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatReplacementDescriptionID: + result = @"BatReplacementDescription"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatCommonDesignationID: + result = @"BatCommonDesignation"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatANSIDesignationID: + result = @"BatANSIDesignation"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatIECDesignationID: + result = @"BatIECDesignation"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatApprovedChemistryID: + result = @"BatApprovedChemistry"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatCapacityID: + result = @"BatCapacity"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatQuantityID: + result = @"BatQuantity"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatChargeStateID: + result = @"BatChargeState"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatTimeToFullChargeID: + result = @"BatTimeToFullCharge"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatFunctionalWhileChargingID: + result = @"BatFunctionalWhileCharging"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatChargingCurrentID: + result = @"BatChargingCurrent"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeActiveBatChargeFaultsID: + result = @"ActiveBatChargeFaults"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeEndpointListID: + result = @"EndpointList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeGeneralCommissioningID: + + switch (attributeID) { + + // Cluster GeneralCommissioning attributes + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeBreadcrumbID: + result = @"Breadcrumb"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeBasicCommissioningInfoID: + result = @"BasicCommissioningInfo"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeRegulatoryConfigID: + result = @"RegulatoryConfig"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeLocationCapabilityID: + result = @"LocationCapability"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeSupportsConcurrentConnectionID: + result = @"SupportsConcurrentConnection"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeNetworkCommissioningID: + + switch (attributeID) { + + // Cluster NetworkCommissioning attributes + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeMaxNetworksID: + result = @"MaxNetworks"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeNetworksID: + result = @"Networks"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeScanMaxTimeSecondsID: + result = @"ScanMaxTimeSeconds"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeConnectMaxTimeSecondsID: + result = @"ConnectMaxTimeSeconds"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeInterfaceEnabledID: + result = @"InterfaceEnabled"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeLastNetworkingStatusID: + result = @"LastNetworkingStatus"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeLastNetworkIDID: + result = @"LastNetworkID"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeLastConnectErrorValueID: + result = @"LastConnectErrorValue"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeSupportedWiFiBandsID: + result = @"SupportedWiFiBands"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeSupportedThreadFeaturesID: + result = @"SupportedThreadFeatures"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeThreadVersionID: + result = @"ThreadVersion"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDiagnosticLogsID: + + switch (attributeID) { + + // Cluster DiagnosticLogs attributes + case MTRAttributeIDTypeClusterDiagnosticLogsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDiagnosticLogsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDiagnosticLogsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDiagnosticLogsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDiagnosticLogsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDiagnosticLogsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeGeneralDiagnosticsID: + + switch (attributeID) { + + // Cluster GeneralDiagnostics attributes + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeNetworkInterfacesID: + result = @"NetworkInterfaces"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeRebootCountID: + result = @"RebootCount"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeUpTimeID: + result = @"UpTime"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeTotalOperationalHoursID: + result = @"TotalOperationalHours"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeBootReasonID: + result = @"BootReason"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeActiveHardwareFaultsID: + result = @"ActiveHardwareFaults"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeActiveRadioFaultsID: + result = @"ActiveRadioFaults"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeActiveNetworkFaultsID: + result = @"ActiveNetworkFaults"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeTestEventTriggersEnabledID: + result = @"TestEventTriggersEnabled"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeSoftwareDiagnosticsID: + + switch (attributeID) { + + // Cluster SoftwareDiagnostics attributes + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeThreadMetricsID: + result = @"ThreadMetrics"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeCurrentHeapFreeID: + result = @"CurrentHeapFree"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeCurrentHeapUsedID: + result = @"CurrentHeapUsed"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeCurrentHeapHighWatermarkID: + result = @"CurrentHeapHighWatermark"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeThreadNetworkDiagnosticsID: + + switch (attributeID) { + + // Cluster ThreadNetworkDiagnostics attributes + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeChannelID: + result = @"Channel"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRoutingRoleID: + result = @"RoutingRole"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeNetworkNameID: + result = @"NetworkName"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributePanIdID: + result = @"PanId"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeExtendedPanIdID: + result = @"ExtendedPanId"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeMeshLocalPrefixID: + result = @"MeshLocalPrefix"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeOverrunCountID: + result = @"OverrunCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeNeighborTableID: + result = @"NeighborTable"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRouteTableID: + result = @"RouteTable"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributePartitionIdID: + result = @"PartitionId"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeWeightingID: + result = @"Weighting"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeDataVersionID: + result = @"DataVersion"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeStableDataVersionID: + result = @"StableDataVersion"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeLeaderRouterIdID: + result = @"LeaderRouterId"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeDetachedRoleCountID: + result = @"DetachedRoleCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeChildRoleCountID: + result = @"ChildRoleCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRouterRoleCountID: + result = @"RouterRoleCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeLeaderRoleCountID: + result = @"LeaderRoleCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeAttachAttemptCountID: + result = @"AttachAttemptCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributePartitionIdChangeCountID: + result = @"PartitionIdChangeCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeBetterPartitionAttachAttemptCountID: + result = @"BetterPartitionAttachAttemptCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeParentChangeCountID: + result = @"ParentChangeCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxTotalCountID: + result = @"TxTotalCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxUnicastCountID: + result = @"TxUnicastCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxBroadcastCountID: + result = @"TxBroadcastCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxAckRequestedCountID: + result = @"TxAckRequestedCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxAckedCountID: + result = @"TxAckedCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxNoAckRequestedCountID: + result = @"TxNoAckRequestedCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxDataCountID: + result = @"TxDataCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxDataPollCountID: + result = @"TxDataPollCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxBeaconCountID: + result = @"TxBeaconCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxBeaconRequestCountID: + result = @"TxBeaconRequestCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxOtherCountID: + result = @"TxOtherCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxRetryCountID: + result = @"TxRetryCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxDirectMaxRetryExpiryCountID: + result = @"TxDirectMaxRetryExpiryCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxIndirectMaxRetryExpiryCountID: + result = @"TxIndirectMaxRetryExpiryCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxErrCcaCountID: + result = @"TxErrCcaCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxErrAbortCountID: + result = @"TxErrAbortCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxErrBusyChannelCountID: + result = @"TxErrBusyChannelCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxTotalCountID: + result = @"RxTotalCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxUnicastCountID: + result = @"RxUnicastCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxBroadcastCountID: + result = @"RxBroadcastCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxDataCountID: + result = @"RxDataCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxDataPollCountID: + result = @"RxDataPollCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxBeaconCountID: + result = @"RxBeaconCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxBeaconRequestCountID: + result = @"RxBeaconRequestCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxOtherCountID: + result = @"RxOtherCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxAddressFilteredCountID: + result = @"RxAddressFilteredCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxDestAddrFilteredCountID: + result = @"RxDestAddrFilteredCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxDuplicatedCountID: + result = @"RxDuplicatedCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxErrNoFrameCountID: + result = @"RxErrNoFrameCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxErrUnknownNeighborCountID: + result = @"RxErrUnknownNeighborCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxErrInvalidSrcAddrCountID: + result = @"RxErrInvalidSrcAddrCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxErrSecCountID: + result = @"RxErrSecCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxErrFcsCountID: + result = @"RxErrFcsCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxErrOtherCountID: + result = @"RxErrOtherCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeActiveTimestampID: + result = @"ActiveTimestamp"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributePendingTimestampID: + result = @"PendingTimestamp"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeDelayID: + result = @"Delay"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeSecurityPolicyID: + result = @"SecurityPolicy"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeChannelPage0MaskID: + result = @"ChannelPage0Mask"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeOperationalDatasetComponentsID: + result = @"OperationalDatasetComponents"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeActiveNetworkFaultsListID: + result = @"ActiveNetworkFaultsList"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeWiFiNetworkDiagnosticsID: + + switch (attributeID) { + + // Cluster WiFiNetworkDiagnostics attributes + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeBSSIDID: + result = @"BSSID"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeSecurityTypeID: + result = @"SecurityType"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeWiFiVersionID: + result = @"WiFiVersion"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeChannelNumberID: + result = @"ChannelNumber"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeRSSIID: + result = @"RSSI"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeBeaconLostCountID: + result = @"BeaconLostCount"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeBeaconRxCountID: + result = @"BeaconRxCount"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributePacketMulticastRxCountID: + result = @"PacketMulticastRxCount"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributePacketMulticastTxCountID: + result = @"PacketMulticastTxCount"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributePacketUnicastRxCountID: + result = @"PacketUnicastRxCount"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributePacketUnicastTxCountID: + result = @"PacketUnicastTxCount"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeCurrentMaxRateID: + result = @"CurrentMaxRate"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeOverrunCountID: + result = @"OverrunCount"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeEthernetNetworkDiagnosticsID: + + switch (attributeID) { + + // Cluster EthernetNetworkDiagnostics attributes + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributePHYRateID: + result = @"PHYRate"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeFullDuplexID: + result = @"FullDuplex"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributePacketRxCountID: + result = @"PacketRxCount"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributePacketTxCountID: + result = @"PacketTxCount"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeTxErrCountID: + result = @"TxErrCount"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeCollisionCountID: + result = @"CollisionCount"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeOverrunCountID: + result = @"OverrunCount"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeCarrierDetectID: + result = @"CarrierDetect"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeTimeSinceResetID: + result = @"TimeSinceReset"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeTimeSynchronizationID: + + switch (attributeID) { + + // Cluster TimeSynchronization attributes + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeUTCTimeID: + result = @"UTCTime"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeGranularityID: + result = @"Granularity"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeSourceID: + result = @"TimeSource"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeTrustedTimeSourceID: + result = @"TrustedTimeSource"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeDefaultNTPID: + result = @"DefaultNTP"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneID: + result = @"TimeZone"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeDSTOffsetID: + result = @"DSTOffset"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeLocalTimeID: + result = @"LocalTime"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneDatabaseID: + result = @"TimeZoneDatabase"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeNTPServerAvailableID: + result = @"NTPServerAvailable"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneListMaxSizeID: + result = @"TimeZoneListMaxSize"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeDSTOffsetListMaxSizeID: + result = @"DSTOffsetListMaxSize"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeSupportsDNSResolveID: + result = @"SupportsDNSResolve"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBridgedDeviceBasicInformationID: + + switch (attributeID) { + + // Cluster BridgedDeviceBasicInformation attributes + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeVendorNameID: + result = @"VendorName"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeVendorIDID: + result = @"VendorID"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeProductNameID: + result = @"ProductName"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeNodeLabelID: + result = @"NodeLabel"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeHardwareVersionID: + result = @"HardwareVersion"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeHardwareVersionStringID: + result = @"HardwareVersionString"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeSoftwareVersionID: + result = @"SoftwareVersion"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeSoftwareVersionStringID: + result = @"SoftwareVersionString"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeManufacturingDateID: + result = @"ManufacturingDate"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributePartNumberID: + result = @"PartNumber"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeProductURLID: + result = @"ProductURL"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeProductLabelID: + result = @"ProductLabel"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeSerialNumberID: + result = @"SerialNumber"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeReachableID: + result = @"Reachable"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeUniqueIDID: + result = @"UniqueID"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeProductAppearanceID: + result = @"ProductAppearance"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeSwitchID: + + switch (attributeID) { + + // Cluster Switch attributes + case MTRAttributeIDTypeClusterSwitchAttributeNumberOfPositionsID: + result = @"NumberOfPositions"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeCurrentPositionID: + result = @"CurrentPosition"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeMultiPressMaxID: + result = @"MultiPressMax"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeAdministratorCommissioningID: + + switch (attributeID) { + + // Cluster AdministratorCommissioning attributes + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeWindowStatusID: + result = @"WindowStatus"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeAdminFabricIndexID: + result = @"AdminFabricIndex"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeAdminVendorIdID: + result = @"AdminVendorId"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOperationalCredentialsID: + + switch (attributeID) { + + // Cluster OperationalCredentials attributes + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeNOCsID: + result = @"NOCs"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeFabricsID: + result = @"Fabrics"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeSupportedFabricsID: + result = @"SupportedFabrics"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeCommissionedFabricsID: + result = @"CommissionedFabrics"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeTrustedRootCertificatesID: + result = @"TrustedRootCertificates"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeCurrentFabricIndexID: + result = @"CurrentFabricIndex"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeGroupKeyManagementID: + + switch (attributeID) { + + // Cluster GroupKeyManagement attributes + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeGroupKeyMapID: + result = @"GroupKeyMap"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeGroupTableID: + result = @"GroupTable"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeMaxGroupsPerFabricID: + result = @"MaxGroupsPerFabric"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeMaxGroupKeysPerFabricID: + result = @"MaxGroupKeysPerFabric"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeFixedLabelID: + + switch (attributeID) { + + // Cluster FixedLabel attributes + case MTRAttributeIDTypeClusterFixedLabelAttributeLabelListID: + result = @"LabelList"; + break; + + case MTRAttributeIDTypeClusterFixedLabelAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterFixedLabelAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterFixedLabelAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterFixedLabelAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterFixedLabelAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterFixedLabelAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeUserLabelID: + + switch (attributeID) { + + // Cluster UserLabel attributes + case MTRAttributeIDTypeClusterUserLabelAttributeLabelListID: + result = @"LabelList"; + break; + + case MTRAttributeIDTypeClusterUserLabelAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterUserLabelAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterUserLabelAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterUserLabelAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterUserLabelAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterUserLabelAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBooleanStateID: + + switch (attributeID) { + + // Cluster BooleanState attributes + case MTRAttributeIDTypeClusterBooleanStateAttributeStateValueID: + result = @"StateValue"; + break; + + case MTRAttributeIDTypeClusterBooleanStateAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBooleanStateAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeICDManagementID: + + switch (attributeID) { + + // Cluster ICDManagement attributes + case MTRAttributeIDTypeClusterICDManagementAttributeIdleModeDurationID: + result = @"IdleModeDuration"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeActiveModeDurationID: + result = @"ActiveModeDuration"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeActiveModeThresholdID: + result = @"ActiveModeThreshold"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeRegisteredClientsID: + result = @"RegisteredClients"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeICDCounterID: + result = @"ICDCounter"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeClientsSupportedPerFabricID: + result = @"ClientsSupportedPerFabric"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeUserActiveModeTriggerHintID: + result = @"UserActiveModeTriggerHint"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeUserActiveModeTriggerInstructionID: + result = @"UserActiveModeTriggerInstruction"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeOperatingModeID: + result = @"OperatingMode"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeTimerID: + + switch (attributeID) { + + // Cluster Timer attributes + case MTRAttributeIDTypeClusterTimerAttributeSetTimeID: + result = @"SetTime"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeTimeRemainingID: + result = @"TimeRemaining"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeTimerStateID: + result = @"TimerState"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOvenCavityOperationalStateID: + + switch (attributeID) { + + // Cluster OvenCavityOperationalState attributes + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributePhaseListID: + result = @"PhaseList"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeCurrentPhaseID: + result = @"CurrentPhase"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeCountdownTimeID: + result = @"CountdownTime"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeOperationalStateListID: + result = @"OperationalStateList"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeOperationalStateID: + result = @"OperationalState"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeOperationalErrorID: + result = @"OperationalError"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOvenModeID: + + switch (attributeID) { + + // Cluster OvenMode attributes + case MTRAttributeIDTypeClusterOvenModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeStartUpModeID: + result = @"StartUpMode"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeOnModeID: + result = @"OnMode"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeLaundryDryerControlsID: + + switch (attributeID) { + + // Cluster LaundryDryerControls attributes + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeSupportedDrynessLevelsID: + result = @"SupportedDrynessLevels"; + break; + + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeSelectedDrynessLevelID: + result = @"SelectedDrynessLevel"; + break; + + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeModeSelectID: + + switch (attributeID) { + + // Cluster ModeSelect attributes + case MTRAttributeIDTypeClusterModeSelectAttributeDescriptionID: + result = @"Description"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeStandardNamespaceID: + result = @"StandardNamespace"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeStartUpModeID: + result = @"StartUpMode"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeOnModeID: + result = @"OnMode"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeLaundryWasherModeID: + + switch (attributeID) { + + // Cluster LaundryWasherMode attributes + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeStartUpModeID: + result = @"StartUpMode"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeOnModeID: + result = @"OnMode"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeRefrigeratorAndTemperatureControlledCabinetModeID: + + switch (attributeID) { + + // Cluster RefrigeratorAndTemperatureControlledCabinetMode attributes + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeStartUpModeID: + result = @"StartUpMode"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeOnModeID: + result = @"OnMode"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeLaundryWasherControlsID: + + switch (attributeID) { + + // Cluster LaundryWasherControls attributes + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeSpinSpeedsID: + result = @"SpinSpeeds"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeSpinSpeedCurrentID: + result = @"SpinSpeedCurrent"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeNumberOfRinsesID: + result = @"NumberOfRinses"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeSupportedRinsesID: + result = @"SupportedRinses"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeRVCRunModeID: + + switch (attributeID) { + + // Cluster RVCRunMode attributes + case MTRAttributeIDTypeClusterRVCRunModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterRVCRunModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterRVCRunModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterRVCRunModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterRVCRunModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterRVCRunModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterRVCRunModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterRVCRunModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeRVCCleanModeID: + + switch (attributeID) { + + // Cluster RVCCleanMode attributes + case MTRAttributeIDTypeClusterRVCCleanModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterRVCCleanModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterRVCCleanModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterRVCCleanModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterRVCCleanModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterRVCCleanModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterRVCCleanModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterRVCCleanModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeTemperatureControlID: + + switch (attributeID) { + + // Cluster TemperatureControl attributes + case MTRAttributeIDTypeClusterTemperatureControlAttributeTemperatureSetpointID: + result = @"TemperatureSetpoint"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeMinTemperatureID: + result = @"MinTemperature"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeMaxTemperatureID: + result = @"MaxTemperature"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeStepID: + result = @"Step"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeSelectedTemperatureLevelID: + result = @"SelectedTemperatureLevel"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeSupportedTemperatureLevelsID: + result = @"SupportedTemperatureLevels"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeRefrigeratorAlarmID: + + switch (attributeID) { + + // Cluster RefrigeratorAlarm attributes + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeMaskID: + result = @"Mask"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeStateID: + result = @"State"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeSupportedID: + result = @"Supported"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDishwasherModeID: + + switch (attributeID) { + + // Cluster DishwasherMode attributes + case MTRAttributeIDTypeClusterDishwasherModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeStartUpModeID: + result = @"StartUpMode"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeOnModeID: + result = @"OnMode"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeAirQualityID: + + switch (attributeID) { + + // Cluster AirQuality attributes + case MTRAttributeIDTypeClusterAirQualityAttributeAirQualityID: + result = @"AirQuality"; + break; + + case MTRAttributeIDTypeClusterAirQualityAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterAirQualityAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterAirQualityAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterAirQualityAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterAirQualityAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterAirQualityAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeSmokeCOAlarmID: + + switch (attributeID) { + + // Cluster SmokeCOAlarm attributes + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeExpressedStateID: + result = @"ExpressedState"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeSmokeStateID: + result = @"SmokeState"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeCOStateID: + result = @"COState"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeBatteryAlertID: + result = @"BatteryAlert"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeDeviceMutedID: + result = @"DeviceMuted"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeTestInProgressID: + result = @"TestInProgress"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeHardwareFaultAlertID: + result = @"HardwareFaultAlert"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeEndOfServiceAlertID: + result = @"EndOfServiceAlert"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeInterconnectSmokeAlarmID: + result = @"InterconnectSmokeAlarm"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeInterconnectCOAlarmID: + result = @"InterconnectCOAlarm"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeContaminationStateID: + result = @"ContaminationState"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeSmokeSensitivityLevelID: + result = @"SmokeSensitivityLevel"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeExpiryDateID: + result = @"ExpiryDate"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDishwasherAlarmID: + + switch (attributeID) { + + // Cluster DishwasherAlarm attributes + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeMaskID: + result = @"Mask"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeLatchID: + result = @"Latch"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeStateID: + result = @"State"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeSupportedID: + result = @"Supported"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeMicrowaveOvenModeID: + + switch (attributeID) { + + // Cluster MicrowaveOvenMode attributes + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeMicrowaveOvenControlID: + + switch (attributeID) { + + // Cluster MicrowaveOvenControl attributes + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeCookTimeID: + result = @"CookTime"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeMaxCookTimeID: + result = @"MaxCookTime"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributePowerSettingID: + result = @"PowerSetting"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeMinPowerID: + result = @"MinPower"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeMaxPowerID: + result = @"MaxPower"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributePowerStepID: + result = @"PowerStep"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeSupportedWattsID: + result = @"SupportedWatts"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeSelectedWattIndexID: + result = @"SelectedWattIndex"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeWattRatingID: + result = @"WattRating"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOperationalStateID: + + switch (attributeID) { + + // Cluster OperationalState attributes + case MTRAttributeIDTypeClusterOperationalStateAttributePhaseListID: + result = @"PhaseList"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeCurrentPhaseID: + result = @"CurrentPhase"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeCountdownTimeID: + result = @"CountdownTime"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeOperationalStateListID: + result = @"OperationalStateList"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeOperationalStateID: + result = @"OperationalState"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeOperationalErrorID: + result = @"OperationalError"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeRVCOperationalStateID: + + switch (attributeID) { + + // Cluster RVCOperationalState attributes + case MTRAttributeIDTypeClusterRVCOperationalStateAttributePhaseListID: + result = @"PhaseList"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeCurrentPhaseID: + result = @"CurrentPhase"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeCountdownTimeID: + result = @"CountdownTime"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeOperationalStateListID: + result = @"OperationalStateList"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeOperationalStateID: + result = @"OperationalState"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeOperationalErrorID: + result = @"OperationalError"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeScenesManagementID: + + switch (attributeID) { + + // Cluster ScenesManagement attributes + case MTRAttributeIDTypeClusterScenesManagementAttributeLastConfiguredByID: + result = @"LastConfiguredBy"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeSceneTableSizeID: + result = @"SceneTableSize"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeFabricSceneInfoID: + result = @"FabricSceneInfo"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeHEPAFilterMonitoringID: + + switch (attributeID) { + + // Cluster HEPAFilterMonitoring attributes + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeConditionID: + result = @"Condition"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeDegradationDirectionID: + result = @"DegradationDirection"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeChangeIndicationID: + result = @"ChangeIndication"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeInPlaceIndicatorID: + result = @"InPlaceIndicator"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeLastChangedTimeID: + result = @"LastChangedTime"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeReplacementProductListID: + result = @"ReplacementProductList"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeActivatedCarbonFilterMonitoringID: + + switch (attributeID) { + + // Cluster ActivatedCarbonFilterMonitoring attributes + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeConditionID: + result = @"Condition"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeDegradationDirectionID: + result = @"DegradationDirection"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeChangeIndicationID: + result = @"ChangeIndication"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeInPlaceIndicatorID: + result = @"InPlaceIndicator"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeLastChangedTimeID: + result = @"LastChangedTime"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeReplacementProductListID: + result = @"ReplacementProductList"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBooleanStateConfigurationID: + + switch (attributeID) { + + // Cluster BooleanStateConfiguration attributes + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeCurrentSensitivityLevelID: + result = @"CurrentSensitivityLevel"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeSupportedSensitivityLevelsID: + result = @"SupportedSensitivityLevels"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeDefaultSensitivityLevelID: + result = @"DefaultSensitivityLevel"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeAlarmsActiveID: + result = @"AlarmsActive"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeAlarmsSuppressedID: + result = @"AlarmsSuppressed"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeAlarmsEnabledID: + result = @"AlarmsEnabled"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeAlarmsSupportedID: + result = @"AlarmsSupported"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeSensorFaultID: + result = @"SensorFault"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeValveConfigurationAndControlID: + + switch (attributeID) { + + // Cluster ValveConfigurationAndControl attributes + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeOpenDurationID: + result = @"OpenDuration"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeDefaultOpenDurationID: + result = @"DefaultOpenDuration"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeAutoCloseTimeID: + result = @"AutoCloseTime"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeRemainingDurationID: + result = @"RemainingDuration"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeCurrentStateID: + result = @"CurrentState"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeTargetStateID: + result = @"TargetState"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeCurrentLevelID: + result = @"CurrentLevel"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeTargetLevelID: + result = @"TargetLevel"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeDefaultOpenLevelID: + result = @"DefaultOpenLevel"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeValveFaultID: + result = @"ValveFault"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeLevelStepID: + result = @"LevelStep"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeElectricalPowerMeasurementID: + + switch (attributeID) { + + // Cluster ElectricalPowerMeasurement attributes + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributePowerModeID: + result = @"PowerMode"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeNumberOfMeasurementTypesID: + result = @"NumberOfMeasurementTypes"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeAccuracyID: + result = @"Accuracy"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRangesID: + result = @"Ranges"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeVoltageID: + result = @"Voltage"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeActiveCurrentID: + result = @"ActiveCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeReactiveCurrentID: + result = @"ReactiveCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeApparentCurrentID: + result = @"ApparentCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeActivePowerID: + result = @"ActivePower"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeReactivePowerID: + result = @"ReactivePower"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeApparentPowerID: + result = @"ApparentPower"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRMSVoltageID: + result = @"RMSVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRMSCurrentID: + result = @"RMSCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRMSPowerID: + result = @"RMSPower"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeFrequencyID: + result = @"Frequency"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeHarmonicCurrentsID: + result = @"HarmonicCurrents"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeHarmonicPhasesID: + result = @"HarmonicPhases"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributePowerFactorID: + result = @"PowerFactor"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeNeutralCurrentID: + result = @"NeutralCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeElectricalEnergyMeasurementID: + + switch (attributeID) { + + // Cluster ElectricalEnergyMeasurement attributes + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeAccuracyID: + result = @"Accuracy"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeCumulativeEnergyImportedID: + result = @"CumulativeEnergyImported"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeCumulativeEnergyExportedID: + result = @"CumulativeEnergyExported"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributePeriodicEnergyImportedID: + result = @"PeriodicEnergyImported"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributePeriodicEnergyExportedID: + result = @"PeriodicEnergyExported"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeCumulativeEnergyResetID: + result = @"CumulativeEnergyReset"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDemandResponseLoadControlID: + + switch (attributeID) { + + // Cluster DemandResponseLoadControl attributes + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeLoadControlProgramsID: + result = @"LoadControlPrograms"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeNumberOfLoadControlProgramsID: + result = @"NumberOfLoadControlPrograms"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeEventsID: + result = @"Events"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeActiveEventsID: + result = @"ActiveEvents"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeNumberOfEventsPerProgramID: + result = @"NumberOfEventsPerProgram"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeNumberOfTransitionsID: + result = @"NumberOfTransitions"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeDefaultRandomStartID: + result = @"DefaultRandomStart"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeDefaultRandomDurationID: + result = @"DefaultRandomDuration"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeMessagesID: + + switch (attributeID) { + + // Cluster Messages attributes + case MTRAttributeIDTypeClusterMessagesAttributeMessagesID: + result = @"Messages"; + break; + + case MTRAttributeIDTypeClusterMessagesAttributeActiveMessageIDsID: + result = @"ActiveMessageIDs"; + break; + + case MTRAttributeIDTypeClusterMessagesAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterMessagesAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterMessagesAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterMessagesAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterMessagesAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterMessagesAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDeviceEnergyManagementID: + + switch (attributeID) { + + // Cluster DeviceEnergyManagement attributes + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeESATypeID: + result = @"ESAType"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeESACanGenerateID: + result = @"ESACanGenerate"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeESAStateID: + result = @"ESAState"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeAbsMinPowerID: + result = @"AbsMinPower"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeAbsMaxPowerID: + result = @"AbsMaxPower"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributePowerAdjustmentCapabilityID: + result = @"PowerAdjustmentCapability"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeForecastID: + result = @"Forecast"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeOptOutStateID: + result = @"OptOutState"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeEnergyEVSEID: + + switch (attributeID) { + + // Cluster EnergyEVSE attributes + case MTRAttributeIDTypeClusterEnergyEVSEAttributeStateID: + result = @"State"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeSupplyStateID: + result = @"SupplyState"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeFaultStateID: + result = @"FaultState"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeChargingEnabledUntilID: + result = @"ChargingEnabledUntil"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeDischargingEnabledUntilID: + result = @"DischargingEnabledUntil"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeCircuitCapacityID: + result = @"CircuitCapacity"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeMinimumChargeCurrentID: + result = @"MinimumChargeCurrent"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeMaximumChargeCurrentID: + result = @"MaximumChargeCurrent"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeMaximumDischargeCurrentID: + result = @"MaximumDischargeCurrent"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeUserMaximumChargeCurrentID: + result = @"UserMaximumChargeCurrent"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeRandomizationDelayWindowID: + result = @"RandomizationDelayWindow"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeNextChargeStartTimeID: + result = @"NextChargeStartTime"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeNextChargeTargetTimeID: + result = @"NextChargeTargetTime"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeNextChargeRequiredEnergyID: + result = @"NextChargeRequiredEnergy"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeNextChargeTargetSoCID: + result = @"NextChargeTargetSoC"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeApproximateEVEfficiencyID: + result = @"ApproximateEVEfficiency"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeStateOfChargeID: + result = @"StateOfCharge"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeBatteryCapacityID: + result = @"BatteryCapacity"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeVehicleIDID: + result = @"VehicleID"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeSessionIDID: + result = @"SessionID"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeSessionDurationID: + result = @"SessionDuration"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeSessionEnergyChargedID: + result = @"SessionEnergyCharged"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeSessionEnergyDischargedID: + result = @"SessionEnergyDischarged"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeEnergyPreferenceID: + + switch (attributeID) { + + // Cluster EnergyPreference attributes + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeEnergyBalancesID: + result = @"EnergyBalances"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeCurrentEnergyBalanceID: + result = @"CurrentEnergyBalance"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeEnergyPrioritiesID: + result = @"EnergyPriorities"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeLowPowerModeSensitivitiesID: + result = @"LowPowerModeSensitivities"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeCurrentLowPowerModeSensitivityID: + result = @"CurrentLowPowerModeSensitivity"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePowerTopologyID: + + switch (attributeID) { + + // Cluster PowerTopology attributes + case MTRAttributeIDTypeClusterPowerTopologyAttributeAvailableEndpointsID: + result = @"AvailableEndpoints"; + break; + + case MTRAttributeIDTypeClusterPowerTopologyAttributeActiveEndpointsID: + result = @"ActiveEndpoints"; + break; + + case MTRAttributeIDTypeClusterPowerTopologyAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPowerTopologyAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPowerTopologyAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPowerTopologyAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPowerTopologyAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPowerTopologyAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeEnergyEVSEModeID: + + switch (attributeID) { + + // Cluster EnergyEVSEMode attributes + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeStartUpModeID: + result = @"StartUpMode"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeOnModeID: + result = @"OnMode"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDeviceEnergyManagementModeID: + + switch (attributeID) { + + // Cluster DeviceEnergyManagementMode attributes + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeStartUpModeID: + result = @"StartUpMode"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeOnModeID: + result = @"OnMode"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDoorLockID: + + switch (attributeID) { + + // Cluster DoorLock attributes + case MTRAttributeIDTypeClusterDoorLockAttributeLockStateID: + result = @"LockState"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeLockTypeID: + result = @"LockType"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeActuatorEnabledID: + result = @"ActuatorEnabled"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeDoorStateID: + result = @"DoorState"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeDoorOpenEventsID: + result = @"DoorOpenEvents"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeDoorClosedEventsID: + result = @"DoorClosedEvents"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeOpenPeriodID: + result = @"OpenPeriod"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfTotalUsersSupportedID: + result = @"NumberOfTotalUsersSupported"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfPINUsersSupportedID: + result = @"NumberOfPINUsersSupported"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfRFIDUsersSupportedID: + result = @"NumberOfRFIDUsersSupported"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfWeekDaySchedulesSupportedPerUserID: + result = @"NumberOfWeekDaySchedulesSupportedPerUser"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfYearDaySchedulesSupportedPerUserID: + result = @"NumberOfYearDaySchedulesSupportedPerUser"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfHolidaySchedulesSupportedID: + result = @"NumberOfHolidaySchedulesSupported"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeMaxPINCodeLengthID: + result = @"MaxPINCodeLength"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeMinPINCodeLengthID: + result = @"MinPINCodeLength"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeMaxRFIDCodeLengthID: + result = @"MaxRFIDCodeLength"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeMinRFIDCodeLengthID: + result = @"MinRFIDCodeLength"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeCredentialRulesSupportID: + result = @"CredentialRulesSupport"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfCredentialsSupportedPerUserID: + result = @"NumberOfCredentialsSupportedPerUser"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeLanguageID: + result = @"Language"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeLEDSettingsID: + result = @"LEDSettings"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAutoRelockTimeID: + result = @"AutoRelockTime"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeSoundVolumeID: + result = @"SoundVolume"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeOperatingModeID: + result = @"OperatingMode"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeSupportedOperatingModesID: + result = @"SupportedOperatingModes"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeDefaultConfigurationRegisterID: + result = @"DefaultConfigurationRegister"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeEnableLocalProgrammingID: + result = @"EnableLocalProgramming"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeEnableOneTouchLockingID: + result = @"EnableOneTouchLocking"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeEnableInsideStatusLEDID: + result = @"EnableInsideStatusLED"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeEnablePrivacyModeButtonID: + result = @"EnablePrivacyModeButton"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeLocalProgrammingFeaturesID: + result = @"LocalProgrammingFeatures"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeWrongCodeEntryLimitID: + result = @"WrongCodeEntryLimit"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeUserCodeTemporaryDisableTimeID: + result = @"UserCodeTemporaryDisableTime"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeSendPINOverTheAirID: + result = @"SendPINOverTheAir"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeRequirePINforRemoteOperationID: + result = @"RequirePINforRemoteOperation"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeExpiringUserTimeoutID: + result = @"ExpiringUserTimeout"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAliroReaderVerificationKeyID: + result = @"AliroReaderVerificationKey"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAliroReaderGroupIdentifierID: + result = @"AliroReaderGroupIdentifier"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAliroReaderGroupSubIdentifierID: + result = @"AliroReaderGroupSubIdentifier"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAliroExpeditedTransactionSupportedProtocolVersionsID: + result = @"AliroExpeditedTransactionSupportedProtocolVersions"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAliroGroupResolvingKeyID: + result = @"AliroGroupResolvingKey"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAliroSupportedBLEUWBProtocolVersionsID: + result = @"AliroSupportedBLEUWBProtocolVersions"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAliroBLEAdvertisingVersionID: + result = @"AliroBLEAdvertisingVersion"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfAliroCredentialIssuerKeysSupportedID: + result = @"NumberOfAliroCredentialIssuerKeysSupported"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfAliroEndpointKeysSupportedID: + result = @"NumberOfAliroEndpointKeysSupported"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeWindowCoveringID: + + switch (attributeID) { + + // Cluster WindowCovering attributes + case MTRAttributeIDTypeClusterWindowCoveringAttributeTypeID: + result = @"Type"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributePhysicalClosedLimitLiftID: + result = @"PhysicalClosedLimitLift"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributePhysicalClosedLimitTiltID: + result = @"PhysicalClosedLimitTilt"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeCurrentPositionLiftID: + result = @"CurrentPositionLift"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeCurrentPositionTiltID: + result = @"CurrentPositionTilt"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeNumberOfActuationsLiftID: + result = @"NumberOfActuationsLift"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeNumberOfActuationsTiltID: + result = @"NumberOfActuationsTilt"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeConfigStatusID: + result = @"ConfigStatus"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeCurrentPositionLiftPercentageID: + result = @"CurrentPositionLiftPercentage"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeCurrentPositionTiltPercentageID: + result = @"CurrentPositionTiltPercentage"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeOperationalStatusID: + result = @"OperationalStatus"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeTargetPositionLiftPercent100thsID: + result = @"TargetPositionLiftPercent100ths"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeTargetPositionTiltPercent100thsID: + result = @"TargetPositionTiltPercent100ths"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeEndProductTypeID: + result = @"EndProductType"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeCurrentPositionLiftPercent100thsID: + result = @"CurrentPositionLiftPercent100ths"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeCurrentPositionTiltPercent100thsID: + result = @"CurrentPositionTiltPercent100ths"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeInstalledOpenLimitLiftID: + result = @"InstalledOpenLimitLift"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeInstalledClosedLimitLiftID: + result = @"InstalledClosedLimitLift"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeInstalledOpenLimitTiltID: + result = @"InstalledOpenLimitTilt"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeInstalledClosedLimitTiltID: + result = @"InstalledClosedLimitTilt"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeModeID: + result = @"Mode"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeSafetyStatusID: + result = @"SafetyStatus"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBarrierControlID: + + switch (attributeID) { + + // Cluster BarrierControl attributes + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierMovingStateID: + result = @"BarrierMovingState"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierSafetyStatusID: + result = @"BarrierSafetyStatus"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierCapabilitiesID: + result = @"BarrierCapabilities"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierOpenEventsID: + result = @"BarrierOpenEvents"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierCloseEventsID: + result = @"BarrierCloseEvents"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierCommandOpenEventsID: + result = @"BarrierCommandOpenEvents"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierCommandCloseEventsID: + result = @"BarrierCommandCloseEvents"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierOpenPeriodID: + result = @"BarrierOpenPeriod"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierClosePeriodID: + result = @"BarrierClosePeriod"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierPositionID: + result = @"BarrierPosition"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePumpConfigurationAndControlID: + + switch (attributeID) { + + // Cluster PumpConfigurationAndControl attributes + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxPressureID: + result = @"MaxPressure"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxSpeedID: + result = @"MaxSpeed"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxFlowID: + result = @"MaxFlow"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMinConstPressureID: + result = @"MinConstPressure"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxConstPressureID: + result = @"MaxConstPressure"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMinCompPressureID: + result = @"MinCompPressure"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxCompPressureID: + result = @"MaxCompPressure"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMinConstSpeedID: + result = @"MinConstSpeed"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxConstSpeedID: + result = @"MaxConstSpeed"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMinConstFlowID: + result = @"MinConstFlow"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxConstFlowID: + result = @"MaxConstFlow"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMinConstTempID: + result = @"MinConstTemp"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxConstTempID: + result = @"MaxConstTemp"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributePumpStatusID: + result = @"PumpStatus"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeEffectiveOperationModeID: + result = @"EffectiveOperationMode"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeEffectiveControlModeID: + result = @"EffectiveControlMode"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeCapacityID: + result = @"Capacity"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeSpeedID: + result = @"Speed"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeLifetimeRunningHoursID: + result = @"LifetimeRunningHours"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributePowerID: + result = @"Power"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeLifetimeEnergyConsumedID: + result = @"LifetimeEnergyConsumed"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeOperationModeID: + result = @"OperationMode"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeControlModeID: + result = @"ControlMode"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeThermostatID: + + switch (attributeID) { + + // Cluster Thermostat attributes + case MTRAttributeIDTypeClusterThermostatAttributeLocalTemperatureID: + result = @"LocalTemperature"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeOutdoorTemperatureID: + result = @"OutdoorTemperature"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeOccupancyID: + result = @"Occupancy"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeAbsMinHeatSetpointLimitID: + result = @"AbsMinHeatSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeAbsMaxHeatSetpointLimitID: + result = @"AbsMaxHeatSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeAbsMinCoolSetpointLimitID: + result = @"AbsMinCoolSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeAbsMaxCoolSetpointLimitID: + result = @"AbsMaxCoolSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributePICoolingDemandID: + result = @"PICoolingDemand"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributePIHeatingDemandID: + result = @"PIHeatingDemand"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeHVACSystemTypeConfigurationID: + result = @"HVACSystemTypeConfiguration"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeLocalTemperatureCalibrationID: + result = @"LocalTemperatureCalibration"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeOccupiedCoolingSetpointID: + result = @"OccupiedCoolingSetpoint"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeOccupiedHeatingSetpointID: + result = @"OccupiedHeatingSetpoint"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeUnoccupiedCoolingSetpointID: + result = @"UnoccupiedCoolingSetpoint"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeUnoccupiedHeatingSetpointID: + result = @"UnoccupiedHeatingSetpoint"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeMinHeatSetpointLimitID: + result = @"MinHeatSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeMaxHeatSetpointLimitID: + result = @"MaxHeatSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeMinCoolSetpointLimitID: + result = @"MinCoolSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeMaxCoolSetpointLimitID: + result = @"MaxCoolSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeMinSetpointDeadBandID: + result = @"MinSetpointDeadBand"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeRemoteSensingID: + result = @"RemoteSensing"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeControlSequenceOfOperationID: + result = @"ControlSequenceOfOperation"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeSystemModeID: + result = @"SystemMode"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeThermostatRunningModeID: + result = @"ThermostatRunningMode"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeStartOfWeekID: + result = @"StartOfWeek"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeNumberOfWeeklyTransitionsID: + result = @"NumberOfWeeklyTransitions"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeNumberOfDailyTransitionsID: + result = @"NumberOfDailyTransitions"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeTemperatureSetpointHoldID: + result = @"TemperatureSetpointHold"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeTemperatureSetpointHoldDurationID: + result = @"TemperatureSetpointHoldDuration"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeThermostatProgrammingOperationModeID: + result = @"ThermostatProgrammingOperationMode"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeThermostatRunningStateID: + result = @"ThermostatRunningState"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeSetpointChangeSourceID: + result = @"SetpointChangeSource"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeSetpointChangeAmountID: + result = @"SetpointChangeAmount"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeSetpointChangeSourceTimestampID: + result = @"SetpointChangeSourceTimestamp"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeOccupiedSetbackID: + result = @"OccupiedSetback"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeOccupiedSetbackMinID: + result = @"OccupiedSetbackMin"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeOccupiedSetbackMaxID: + result = @"OccupiedSetbackMax"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeUnoccupiedSetbackID: + result = @"UnoccupiedSetback"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeUnoccupiedSetbackMinID: + result = @"UnoccupiedSetbackMin"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeUnoccupiedSetbackMaxID: + result = @"UnoccupiedSetbackMax"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeEmergencyHeatDeltaID: + result = @"EmergencyHeatDelta"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACTypeID: + result = @"ACType"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACCapacityID: + result = @"ACCapacity"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACRefrigerantTypeID: + result = @"ACRefrigerantType"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACCompressorTypeID: + result = @"ACCompressorType"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACErrorCodeID: + result = @"ACErrorCode"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACLouverPositionID: + result = @"ACLouverPosition"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACCoilTemperatureID: + result = @"ACCoilTemperature"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACCapacityformatID: + result = @"ACCapacityformat"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributePresetTypesID: + result = @"PresetTypes"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeScheduleTypesID: + result = @"ScheduleTypes"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeNumberOfPresetsID: + result = @"NumberOfPresets"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeNumberOfSchedulesID: + result = @"NumberOfSchedules"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeNumberOfScheduleTransitionsID: + result = @"NumberOfScheduleTransitions"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeNumberOfScheduleTransitionPerDayID: + result = @"NumberOfScheduleTransitionPerDay"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeActivePresetHandleID: + result = @"ActivePresetHandle"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeActiveScheduleHandleID: + result = @"ActiveScheduleHandle"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributePresetsID: + result = @"Presets"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeSchedulesID: + result = @"Schedules"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributePresetsSchedulesEditableID: + result = @"PresetsSchedulesEditable"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeTemperatureSetpointHoldPolicyID: + result = @"TemperatureSetpointHoldPolicy"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeSetpointHoldExpiryTimestampID: + result = @"SetpointHoldExpiryTimestamp"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeQueuedPresetID: + result = @"QueuedPreset"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeFanControlID: + + switch (attributeID) { + + // Cluster FanControl attributes + case MTRAttributeIDTypeClusterFanControlAttributeFanModeID: + result = @"FanMode"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeFanModeSequenceID: + result = @"FanModeSequence"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributePercentSettingID: + result = @"PercentSetting"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributePercentCurrentID: + result = @"PercentCurrent"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeSpeedMaxID: + result = @"SpeedMax"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeSpeedSettingID: + result = @"SpeedSetting"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeSpeedCurrentID: + result = @"SpeedCurrent"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeRockSupportID: + result = @"RockSupport"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeRockSettingID: + result = @"RockSetting"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeWindSupportID: + result = @"WindSupport"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeWindSettingID: + result = @"WindSetting"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeAirflowDirectionID: + result = @"AirflowDirection"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeThermostatUserInterfaceConfigurationID: + + switch (attributeID) { + + // Cluster ThermostatUserInterfaceConfiguration attributes + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeTemperatureDisplayModeID: + result = @"TemperatureDisplayMode"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeKeypadLockoutID: + result = @"KeypadLockout"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeScheduleProgrammingVisibilityID: + result = @"ScheduleProgrammingVisibility"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeColorControlID: + + switch (attributeID) { + + // Cluster ColorControl attributes + case MTRAttributeIDTypeClusterColorControlAttributeCurrentHueID: + result = @"CurrentHue"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeCurrentSaturationID: + result = @"CurrentSaturation"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeRemainingTimeID: + result = @"RemainingTime"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeCurrentXID: + result = @"CurrentX"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeCurrentYID: + result = @"CurrentY"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeDriftCompensationID: + result = @"DriftCompensation"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeCompensationTextID: + result = @"CompensationText"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorTemperatureMiredsID: + result = @"ColorTemperatureMireds"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorModeID: + result = @"ColorMode"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeOptionsID: + result = @"Options"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeNumberOfPrimariesID: + result = @"NumberOfPrimaries"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary1XID: + result = @"Primary1X"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary1YID: + result = @"Primary1Y"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary1IntensityID: + result = @"Primary1Intensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary2XID: + result = @"Primary2X"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary2YID: + result = @"Primary2Y"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary2IntensityID: + result = @"Primary2Intensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary3XID: + result = @"Primary3X"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary3YID: + result = @"Primary3Y"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary3IntensityID: + result = @"Primary3Intensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary4XID: + result = @"Primary4X"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary4YID: + result = @"Primary4Y"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary4IntensityID: + result = @"Primary4Intensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary5XID: + result = @"Primary5X"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary5YID: + result = @"Primary5Y"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary5IntensityID: + result = @"Primary5Intensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary6XID: + result = @"Primary6X"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary6YID: + result = @"Primary6Y"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary6IntensityID: + result = @"Primary6Intensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeWhitePointXID: + result = @"WhitePointX"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeWhitePointYID: + result = @"WhitePointY"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointRXID: + result = @"ColorPointRX"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointRYID: + result = @"ColorPointRY"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointRIntensityID: + result = @"ColorPointRIntensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointGXID: + result = @"ColorPointGX"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointGYID: + result = @"ColorPointGY"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointGIntensityID: + result = @"ColorPointGIntensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointBXID: + result = @"ColorPointBX"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointBYID: + result = @"ColorPointBY"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointBIntensityID: + result = @"ColorPointBIntensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeEnhancedCurrentHueID: + result = @"EnhancedCurrentHue"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeEnhancedColorModeID: + result = @"EnhancedColorMode"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorLoopActiveID: + result = @"ColorLoopActive"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorLoopDirectionID: + result = @"ColorLoopDirection"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorLoopTimeID: + result = @"ColorLoopTime"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorLoopStartEnhancedHueID: + result = @"ColorLoopStartEnhancedHue"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorLoopStoredEnhancedHueID: + result = @"ColorLoopStoredEnhancedHue"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorCapabilitiesID: + result = @"ColorCapabilities"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorTempPhysicalMinMiredsID: + result = @"ColorTempPhysicalMinMireds"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorTempPhysicalMaxMiredsID: + result = @"ColorTempPhysicalMaxMireds"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeCoupleColorTempToLevelMinMiredsID: + result = @"CoupleColorTempToLevelMinMireds"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeStartUpColorTemperatureMiredsID: + result = @"StartUpColorTemperatureMireds"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBallastConfigurationID: + + switch (attributeID) { + + // Cluster BallastConfiguration attributes + case MTRAttributeIDTypeClusterBallastConfigurationAttributePhysicalMinLevelID: + result = @"PhysicalMinLevel"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributePhysicalMaxLevelID: + result = @"PhysicalMaxLevel"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeBallastStatusID: + result = @"BallastStatus"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeMinLevelID: + result = @"MinLevel"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeMaxLevelID: + result = @"MaxLevel"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeIntrinsicBallastFactorID: + result = @"IntrinsicBallastFactor"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeBallastFactorAdjustmentID: + result = @"BallastFactorAdjustment"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeLampQuantityID: + result = @"LampQuantity"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeLampTypeID: + result = @"LampType"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeLampManufacturerID: + result = @"LampManufacturer"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeLampRatedHoursID: + result = @"LampRatedHours"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeLampBurnHoursID: + result = @"LampBurnHours"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeLampAlarmModeID: + result = @"LampAlarmMode"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeLampBurnHoursTripPointID: + result = @"LampBurnHoursTripPoint"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeIlluminanceMeasurementID: + + switch (attributeID) { + + // Cluster IlluminanceMeasurement attributes + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeToleranceID: + result = @"Tolerance"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeLightSensorTypeID: + result = @"LightSensorType"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeTemperatureMeasurementID: + + switch (attributeID) { + + // Cluster TemperatureMeasurement attributes + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeToleranceID: + result = @"Tolerance"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePressureMeasurementID: + + switch (attributeID) { + + // Cluster PressureMeasurement attributes + case MTRAttributeIDTypeClusterPressureMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeToleranceID: + result = @"Tolerance"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeScaledValueID: + result = @"ScaledValue"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeMinScaledValueID: + result = @"MinScaledValue"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeMaxScaledValueID: + result = @"MaxScaledValue"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeScaledToleranceID: + result = @"ScaledTolerance"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeScaleID: + result = @"Scale"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeFlowMeasurementID: + + switch (attributeID) { + + // Cluster FlowMeasurement attributes + case MTRAttributeIDTypeClusterFlowMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeToleranceID: + result = @"Tolerance"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeRelativeHumidityMeasurementID: + + switch (attributeID) { + + // Cluster RelativeHumidityMeasurement attributes + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeToleranceID: + result = @"Tolerance"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOccupancySensingID: + + switch (attributeID) { + + // Cluster OccupancySensing attributes + case MTRAttributeIDTypeClusterOccupancySensingAttributeOccupancyID: + result = @"Occupancy"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeOccupancySensorTypeID: + result = @"OccupancySensorType"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeOccupancySensorTypeBitmapID: + result = @"OccupancySensorTypeBitmap"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributePIROccupiedToUnoccupiedDelayID: + result = @"PIROccupiedToUnoccupiedDelay"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributePIRUnoccupiedToOccupiedDelayID: + result = @"PIRUnoccupiedToOccupiedDelay"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributePIRUnoccupiedToOccupiedThresholdID: + result = @"PIRUnoccupiedToOccupiedThreshold"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeUltrasonicOccupiedToUnoccupiedDelayID: + result = @"UltrasonicOccupiedToUnoccupiedDelay"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeUltrasonicUnoccupiedToOccupiedDelayID: + result = @"UltrasonicUnoccupiedToOccupiedDelay"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeUltrasonicUnoccupiedToOccupiedThresholdID: + result = @"UltrasonicUnoccupiedToOccupiedThreshold"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributePhysicalContactOccupiedToUnoccupiedDelayID: + result = @"PhysicalContactOccupiedToUnoccupiedDelay"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributePhysicalContactUnoccupiedToOccupiedDelayID: + result = @"PhysicalContactUnoccupiedToOccupiedDelay"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributePhysicalContactUnoccupiedToOccupiedThresholdID: + result = @"PhysicalContactUnoccupiedToOccupiedThreshold"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeCarbonMonoxideConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster CarbonMonoxideConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeCarbonDioxideConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster CarbonDioxideConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeNitrogenDioxideConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster NitrogenDioxideConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOzoneConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster OzoneConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePM25ConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster PM25ConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeFormaldehydeConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster FormaldehydeConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePM1ConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster PM1ConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePM10ConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster PM10ConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeTotalVolatileOrganicCompoundsConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster TotalVolatileOrganicCompoundsConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeRadonConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster RadonConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeWakeOnLANID: + + switch (attributeID) { + + // Cluster WakeOnLAN attributes + case MTRAttributeIDTypeClusterWakeOnLANAttributeMACAddressID: + result = @"MACAddress"; + break; + + case MTRAttributeIDTypeClusterWakeOnLANAttributeLinkLocalAddressID: + result = @"LinkLocalAddress"; + break; + + case MTRAttributeIDTypeClusterWakeOnLANAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterWakeOnLANAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterWakeOnLANAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterWakeOnLANAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterWakeOnLANAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterWakeOnLANAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeChannelID: + + switch (attributeID) { + + // Cluster Channel attributes + case MTRAttributeIDTypeClusterChannelAttributeChannelListID: + result = @"ChannelList"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeLineupID: + result = @"Lineup"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeCurrentChannelID: + result = @"CurrentChannel"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeTargetNavigatorID: + + switch (attributeID) { + + // Cluster TargetNavigator attributes + case MTRAttributeIDTypeClusterTargetNavigatorAttributeTargetListID: + result = @"TargetList"; + break; + + case MTRAttributeIDTypeClusterTargetNavigatorAttributeCurrentTargetID: + result = @"CurrentTarget"; + break; + + case MTRAttributeIDTypeClusterTargetNavigatorAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterTargetNavigatorAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterTargetNavigatorAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterTargetNavigatorAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterTargetNavigatorAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterTargetNavigatorAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeMediaPlaybackID: + + switch (attributeID) { + + // Cluster MediaPlayback attributes + case MTRAttributeIDTypeClusterMediaPlaybackAttributeCurrentStateID: + result = @"CurrentState"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeStartTimeID: + result = @"StartTime"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeDurationID: + result = @"Duration"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeSampledPositionID: + result = @"SampledPosition"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributePlaybackSpeedID: + result = @"PlaybackSpeed"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeSeekRangeEndID: + result = @"SeekRangeEnd"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeSeekRangeStartID: + result = @"SeekRangeStart"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeActiveAudioTrackID: + result = @"ActiveAudioTrack"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeAvailableAudioTracksID: + result = @"AvailableAudioTracks"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeActiveTextTrackID: + result = @"ActiveTextTrack"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeAvailableTextTracksID: + result = @"AvailableTextTracks"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeMediaInputID: + + switch (attributeID) { + + // Cluster MediaInput attributes + case MTRAttributeIDTypeClusterMediaInputAttributeInputListID: + result = @"InputList"; + break; + + case MTRAttributeIDTypeClusterMediaInputAttributeCurrentInputID: + result = @"CurrentInput"; + break; + + case MTRAttributeIDTypeClusterMediaInputAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterMediaInputAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterMediaInputAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterMediaInputAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterMediaInputAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterMediaInputAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeLowPowerID: + + switch (attributeID) { + + // Cluster LowPower attributes + case MTRAttributeIDTypeClusterLowPowerAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterLowPowerAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterLowPowerAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterLowPowerAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterLowPowerAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterLowPowerAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeKeypadInputID: + + switch (attributeID) { + + // Cluster KeypadInput attributes + case MTRAttributeIDTypeClusterKeypadInputAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterKeypadInputAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterKeypadInputAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterKeypadInputAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterKeypadInputAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterKeypadInputAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeContentLauncherID: + + switch (attributeID) { + + // Cluster ContentLauncher attributes + case MTRAttributeIDTypeClusterContentLauncherAttributeAcceptHeaderID: + result = @"AcceptHeader"; + break; + + case MTRAttributeIDTypeClusterContentLauncherAttributeSupportedStreamingProtocolsID: + result = @"SupportedStreamingProtocols"; + break; + + case MTRAttributeIDTypeClusterContentLauncherAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterContentLauncherAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterContentLauncherAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterContentLauncherAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterContentLauncherAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterContentLauncherAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeAudioOutputID: + + switch (attributeID) { + + // Cluster AudioOutput attributes + case MTRAttributeIDTypeClusterAudioOutputAttributeOutputListID: + result = @"OutputList"; + break; + + case MTRAttributeIDTypeClusterAudioOutputAttributeCurrentOutputID: + result = @"CurrentOutput"; + break; + + case MTRAttributeIDTypeClusterAudioOutputAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterAudioOutputAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterAudioOutputAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterAudioOutputAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterAudioOutputAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterAudioOutputAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeApplicationLauncherID: + + switch (attributeID) { + + // Cluster ApplicationLauncher attributes + case MTRAttributeIDTypeClusterApplicationLauncherAttributeCatalogListID: + result = @"CatalogList"; + break; + + case MTRAttributeIDTypeClusterApplicationLauncherAttributeCurrentAppID: + result = @"CurrentApp"; + break; + + case MTRAttributeIDTypeClusterApplicationLauncherAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterApplicationLauncherAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterApplicationLauncherAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterApplicationLauncherAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterApplicationLauncherAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterApplicationLauncherAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeApplicationBasicID: + + switch (attributeID) { + + // Cluster ApplicationBasic attributes + case MTRAttributeIDTypeClusterApplicationBasicAttributeVendorNameID: + result = @"VendorName"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeVendorIDID: + result = @"VendorID"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeApplicationNameID: + result = @"ApplicationName"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeProductIDID: + result = @"ProductID"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeApplicationID: + result = @"Application"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeStatusID: + result = @"Status"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeApplicationVersionID: + result = @"ApplicationVersion"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeAllowedVendorListID: + result = @"AllowedVendorList"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeAccountLoginID: + + switch (attributeID) { + + // Cluster AccountLogin attributes + case MTRAttributeIDTypeClusterAccountLoginAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterAccountLoginAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterAccountLoginAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterAccountLoginAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterAccountLoginAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterAccountLoginAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeContentControlID: + + switch (attributeID) { + + // Cluster ContentControl attributes + case MTRAttributeIDTypeClusterContentControlAttributeEnabledID: + result = @"Enabled"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeOnDemandRatingsID: + result = @"OnDemandRatings"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeOnDemandRatingThresholdID: + result = @"OnDemandRatingThreshold"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeScheduledContentRatingsID: + result = @"ScheduledContentRatings"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeScheduledContentRatingThresholdID: + result = @"ScheduledContentRatingThreshold"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeScreenDailyTimeID: + result = @"ScreenDailyTime"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeRemainingScreenTimeID: + result = @"RemainingScreenTime"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeBlockUnratedID: + result = @"BlockUnrated"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeContentAppObserverID: + + switch (attributeID) { + + // Cluster ContentAppObserver attributes + case MTRAttributeIDTypeClusterContentAppObserverAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterContentAppObserverAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterContentAppObserverAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterContentAppObserverAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterContentAppObserverAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterContentAppObserverAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeElectricalMeasurementID: + + switch (attributeID) { + + // Cluster ElectricalMeasurement attributes + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasurementTypeID: + result = @"MeasurementType"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcVoltageID: + result = @"DcVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcVoltageMinID: + result = @"DcVoltageMin"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcVoltageMaxID: + result = @"DcVoltageMax"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcCurrentID: + result = @"DcCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcCurrentMinID: + result = @"DcCurrentMin"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcCurrentMaxID: + result = @"DcCurrentMax"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcPowerID: + result = @"DcPower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcPowerMinID: + result = @"DcPowerMin"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcPowerMaxID: + result = @"DcPowerMax"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcVoltageMultiplierID: + result = @"DcVoltageMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcVoltageDivisorID: + result = @"DcVoltageDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcCurrentMultiplierID: + result = @"DcCurrentMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcCurrentDivisorID: + result = @"DcCurrentDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcPowerMultiplierID: + result = @"DcPowerMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcPowerDivisorID: + result = @"DcPowerDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcFrequencyID: + result = @"AcFrequency"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcFrequencyMinID: + result = @"AcFrequencyMin"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcFrequencyMaxID: + result = @"AcFrequencyMax"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeNeutralCurrentID: + result = @"NeutralCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeTotalActivePowerID: + result = @"TotalActivePower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeTotalReactivePowerID: + result = @"TotalReactivePower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeTotalApparentPowerID: + result = @"TotalApparentPower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasured1stHarmonicCurrentID: + result = @"Measured1stHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasured3rdHarmonicCurrentID: + result = @"Measured3rdHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasured5thHarmonicCurrentID: + result = @"Measured5thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasured7thHarmonicCurrentID: + result = @"Measured7thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasured9thHarmonicCurrentID: + result = @"Measured9thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasured11thHarmonicCurrentID: + result = @"Measured11thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasuredPhase1stHarmonicCurrentID: + result = @"MeasuredPhase1stHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasuredPhase3rdHarmonicCurrentID: + result = @"MeasuredPhase3rdHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasuredPhase5thHarmonicCurrentID: + result = @"MeasuredPhase5thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasuredPhase7thHarmonicCurrentID: + result = @"MeasuredPhase7thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasuredPhase9thHarmonicCurrentID: + result = @"MeasuredPhase9thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasuredPhase11thHarmonicCurrentID: + result = @"MeasuredPhase11thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcFrequencyMultiplierID: + result = @"AcFrequencyMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcFrequencyDivisorID: + result = @"AcFrequencyDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributePowerMultiplierID: + result = @"PowerMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributePowerDivisorID: + result = @"PowerDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeHarmonicCurrentMultiplierID: + result = @"HarmonicCurrentMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributePhaseHarmonicCurrentMultiplierID: + result = @"PhaseHarmonicCurrentMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeInstantaneousVoltageID: + result = @"InstantaneousVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeInstantaneousLineCurrentID: + result = @"InstantaneousLineCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeInstantaneousActiveCurrentID: + result = @"InstantaneousActiveCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeInstantaneousReactiveCurrentID: + result = @"InstantaneousReactiveCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeInstantaneousPowerID: + result = @"InstantaneousPower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageID: + result = @"RmsVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageMinID: + result = @"RmsVoltageMin"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageMaxID: + result = @"RmsVoltageMax"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentID: + result = @"RmsCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentMinID: + result = @"RmsCurrentMin"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentMaxID: + result = @"RmsCurrentMax"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerID: + result = @"ActivePower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerMinID: + result = @"ActivePowerMin"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerMaxID: + result = @"ActivePowerMax"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeReactivePowerID: + result = @"ReactivePower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeApparentPowerID: + result = @"ApparentPower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributePowerFactorID: + result = @"PowerFactor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsVoltageMeasurementPeriodID: + result = @"AverageRmsVoltageMeasurementPeriod"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsUnderVoltageCounterID: + result = @"AverageRmsUnderVoltageCounter"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeOverVoltagePeriodID: + result = @"RmsExtremeOverVoltagePeriod"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeUnderVoltagePeriodID: + result = @"RmsExtremeUnderVoltagePeriod"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSagPeriodID: + result = @"RmsVoltageSagPeriod"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSwellPeriodID: + result = @"RmsVoltageSwellPeriod"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcVoltageMultiplierID: + result = @"AcVoltageMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcVoltageDivisorID: + result = @"AcVoltageDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcCurrentMultiplierID: + result = @"AcCurrentMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcCurrentDivisorID: + result = @"AcCurrentDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcPowerMultiplierID: + result = @"AcPowerMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcPowerDivisorID: + result = @"AcPowerDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeOverloadAlarmsMaskID: + result = @"OverloadAlarmsMask"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeVoltageOverloadID: + result = @"VoltageOverload"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeCurrentOverloadID: + result = @"CurrentOverload"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcOverloadAlarmsMaskID: + result = @"AcOverloadAlarmsMask"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcVoltageOverloadID: + result = @"AcVoltageOverload"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcCurrentOverloadID: + result = @"AcCurrentOverload"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcActivePowerOverloadID: + result = @"AcActivePowerOverload"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcReactivePowerOverloadID: + result = @"AcReactivePowerOverload"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsOverVoltageID: + result = @"AverageRmsOverVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsUnderVoltageID: + result = @"AverageRmsUnderVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeOverVoltageID: + result = @"RmsExtremeOverVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeUnderVoltageID: + result = @"RmsExtremeUnderVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSagID: + result = @"RmsVoltageSag"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSwellID: + result = @"RmsVoltageSwell"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeLineCurrentPhaseBID: + result = @"LineCurrentPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActiveCurrentPhaseBID: + result = @"ActiveCurrentPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeReactiveCurrentPhaseBID: + result = @"ReactiveCurrentPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltagePhaseBID: + result = @"RmsVoltagePhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageMinPhaseBID: + result = @"RmsVoltageMinPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageMaxPhaseBID: + result = @"RmsVoltageMaxPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentPhaseBID: + result = @"RmsCurrentPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentMinPhaseBID: + result = @"RmsCurrentMinPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentMaxPhaseBID: + result = @"RmsCurrentMaxPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerPhaseBID: + result = @"ActivePowerPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerMinPhaseBID: + result = @"ActivePowerMinPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerMaxPhaseBID: + result = @"ActivePowerMaxPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeReactivePowerPhaseBID: + result = @"ReactivePowerPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeApparentPowerPhaseBID: + result = @"ApparentPowerPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributePowerFactorPhaseBID: + result = @"PowerFactorPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsVoltageMeasurementPeriodPhaseBID: + result = @"AverageRmsVoltageMeasurementPeriodPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsOverVoltageCounterPhaseBID: + result = @"AverageRmsOverVoltageCounterPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsUnderVoltageCounterPhaseBID: + result = @"AverageRmsUnderVoltageCounterPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeOverVoltagePeriodPhaseBID: + result = @"RmsExtremeOverVoltagePeriodPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeUnderVoltagePeriodPhaseBID: + result = @"RmsExtremeUnderVoltagePeriodPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSagPeriodPhaseBID: + result = @"RmsVoltageSagPeriodPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSwellPeriodPhaseBID: + result = @"RmsVoltageSwellPeriodPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeLineCurrentPhaseCID: + result = @"LineCurrentPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActiveCurrentPhaseCID: + result = @"ActiveCurrentPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeReactiveCurrentPhaseCID: + result = @"ReactiveCurrentPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltagePhaseCID: + result = @"RmsVoltagePhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageMinPhaseCID: + result = @"RmsVoltageMinPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageMaxPhaseCID: + result = @"RmsVoltageMaxPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentPhaseCID: + result = @"RmsCurrentPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentMinPhaseCID: + result = @"RmsCurrentMinPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentMaxPhaseCID: + result = @"RmsCurrentMaxPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerPhaseCID: + result = @"ActivePowerPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerMinPhaseCID: + result = @"ActivePowerMinPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerMaxPhaseCID: + result = @"ActivePowerMaxPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeReactivePowerPhaseCID: + result = @"ReactivePowerPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeApparentPowerPhaseCID: + result = @"ApparentPowerPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributePowerFactorPhaseCID: + result = @"PowerFactorPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsVoltageMeasurementPeriodPhaseCID: + result = @"AverageRmsVoltageMeasurementPeriodPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsOverVoltageCounterPhaseCID: + result = @"AverageRmsOverVoltageCounterPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsUnderVoltageCounterPhaseCID: + result = @"AverageRmsUnderVoltageCounterPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeOverVoltagePeriodPhaseCID: + result = @"RmsExtremeOverVoltagePeriodPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeUnderVoltagePeriodPhaseCID: + result = @"RmsExtremeUnderVoltagePeriodPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSagPeriodPhaseCID: + result = @"RmsVoltageSagPeriodPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSwellPeriodPhaseCID: + result = @"RmsVoltageSwellPeriodPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeUnitTestingID: + + switch (attributeID) { + + // Cluster UnitTesting attributes + case MTRAttributeIDTypeClusterUnitTestingAttributeBooleanID: + result = @"Boolean"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeBitmap8ID: + result = @"Bitmap8"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeBitmap16ID: + result = @"Bitmap16"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeBitmap32ID: + result = @"Bitmap32"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeBitmap64ID: + result = @"Bitmap64"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt8uID: + result = @"Int8u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt16uID: + result = @"Int16u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt24uID: + result = @"Int24u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt32uID: + result = @"Int32u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt40uID: + result = @"Int40u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt48uID: + result = @"Int48u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt56uID: + result = @"Int56u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt64uID: + result = @"Int64u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt8sID: + result = @"Int8s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt16sID: + result = @"Int16s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt24sID: + result = @"Int24s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt32sID: + result = @"Int32s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt40sID: + result = @"Int40s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt48sID: + result = @"Int48s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt56sID: + result = @"Int56s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt64sID: + result = @"Int64s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeEnum8ID: + result = @"Enum8"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeEnum16ID: + result = @"Enum16"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeFloatSingleID: + result = @"FloatSingle"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeFloatDoubleID: + result = @"FloatDouble"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeOctetStringID: + result = @"OctetString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeListInt8uID: + result = @"ListInt8u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeListOctetStringID: + result = @"ListOctetString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeListStructOctetStringID: + result = @"ListStructOctetString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeLongOctetStringID: + result = @"LongOctetString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeCharStringID: + result = @"CharString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeLongCharStringID: + result = @"LongCharString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeEpochUsID: + result = @"EpochUs"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeEpochSID: + result = @"EpochS"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeVendorIdID: + result = @"VendorId"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeListNullablesAndOptionalsStructID: + result = @"ListNullablesAndOptionalsStruct"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeEnumAttrID: + result = @"EnumAttr"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeStructAttrID: + result = @"StructAttr"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeRangeRestrictedInt8uID: + result = @"RangeRestrictedInt8u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeRangeRestrictedInt8sID: + result = @"RangeRestrictedInt8s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeRangeRestrictedInt16uID: + result = @"RangeRestrictedInt16u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeRangeRestrictedInt16sID: + result = @"RangeRestrictedInt16s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeListLongOctetStringID: + result = @"ListLongOctetString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeListFabricScopedID: + result = @"ListFabricScoped"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeTimedWriteBooleanID: + result = @"TimedWriteBoolean"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeGeneralErrorBooleanID: + result = @"GeneralErrorBoolean"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeClusterErrorBooleanID: + result = @"ClusterErrorBoolean"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeUnsupportedID: + result = @"Unsupported"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableBooleanID: + result = @"NullableBoolean"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableBitmap8ID: + result = @"NullableBitmap8"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableBitmap16ID: + result = @"NullableBitmap16"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableBitmap32ID: + result = @"NullableBitmap32"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableBitmap64ID: + result = @"NullableBitmap64"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt8uID: + result = @"NullableInt8u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt16uID: + result = @"NullableInt16u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt24uID: + result = @"NullableInt24u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt32uID: + result = @"NullableInt32u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt40uID: + result = @"NullableInt40u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt48uID: + result = @"NullableInt48u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt56uID: + result = @"NullableInt56u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt64uID: + result = @"NullableInt64u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt8sID: + result = @"NullableInt8s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt16sID: + result = @"NullableInt16s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt24sID: + result = @"NullableInt24s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt32sID: + result = @"NullableInt32s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt40sID: + result = @"NullableInt40s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt48sID: + result = @"NullableInt48s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt56sID: + result = @"NullableInt56s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt64sID: + result = @"NullableInt64s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableEnum8ID: + result = @"NullableEnum8"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableEnum16ID: + result = @"NullableEnum16"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableFloatSingleID: + result = @"NullableFloatSingle"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableFloatDoubleID: + result = @"NullableFloatDouble"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableOctetStringID: + result = @"NullableOctetString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableCharStringID: + result = @"NullableCharString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableEnumAttrID: + result = @"NullableEnumAttr"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableStructID: + result = @"NullableStruct"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableRangeRestrictedInt8uID: + result = @"NullableRangeRestrictedInt8u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableRangeRestrictedInt8sID: + result = @"NullableRangeRestrictedInt8s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableRangeRestrictedInt16uID: + result = @"NullableRangeRestrictedInt16u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableRangeRestrictedInt16sID: + result = @"NullableRangeRestrictedInt16s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeWriteOnlyInt8uID: + result = @"WriteOnlyInt8u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeMeiInt8uID: + result = @"MeiInt8u"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeSampleMEIID: + + switch (attributeID) { + + // Cluster SampleMEI attributes + case MTRAttributeIDTypeClusterSampleMEIAttributeFlipFlopID: + result = @"FlipFlop"; + break; + + case MTRAttributeIDTypeClusterSampleMEIAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterSampleMEIAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterSampleMEIAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterSampleMEIAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterSampleMEIAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterSampleMEIAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + default: + result = [NSString stringWithFormat:@"", clusterID]; + break; + } + + return result; +} + +// @end diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h index bea9e4b57f52b4..d8bc6458a2680d 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h @@ -1234,6 +1234,7 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) - (void)timeSnapshotWithParams:(MTRGeneralDiagnosticsClusterTimeSnapshotParams * _Nullable)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRGeneralDiagnosticsClusterTimeSnapshotResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; - (void)timeSnapshotWithExpectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRGeneralDiagnosticsClusterTimeSnapshotResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)payloadTestRequestWithParams:(MTRGeneralDiagnosticsClusterPayloadTestRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRGeneralDiagnosticsClusterPayloadTestResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; - (NSDictionary * _Nullable)readAttributeNetworkInterfacesWithParams:(MTRReadParams * _Nullable)params MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); @@ -3429,6 +3430,80 @@ MTR_PROVISIONALLY_AVAILABLE @end +/** + * Cluster Electrical Power Measurement + * This cluster provides a mechanism for querying data about electrical power as measured by the server. + */ +MTR_PROVISIONALLY_AVAILABLE +@interface MTRClusterElectricalPowerMeasurement : MTRGenericCluster + +- (NSDictionary * _Nullable)readAttributePowerModeWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeNumberOfMeasurementTypesWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeAccuracyWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeRangesWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeVoltageWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeActiveCurrentWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeReactiveCurrentWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeApparentCurrentWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeActivePowerWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeReactivePowerWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeApparentPowerWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeRMSVoltageWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeRMSCurrentWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeRMSPowerWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeFrequencyWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeHarmonicCurrentsWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeHarmonicPhasesWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributePowerFactorWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeNeutralCurrentWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeEventListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +@interface MTRClusterElectricalPowerMeasurement (Availability) + +/** + * The queue is currently unused, but may be used in the future for calling completions + * for command invocations if commands are added to this cluster. + */ +- (instancetype _Nullable)initWithDevice:(MTRDevice *)device + endpointID:(NSNumber *)endpointID + queue:(dispatch_queue_t)queue MTR_PROVISIONALLY_AVAILABLE; + +@end + /** * Cluster Electrical Energy Measurement * This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. @@ -3446,6 +3521,8 @@ MTR_PROVISIONALLY_AVAILABLE - (NSDictionary * _Nullable)readAttributePeriodicEnergyExportedWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; +- (NSDictionary * _Nullable)readAttributeCumulativeEnergyResetWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + - (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; - (NSDictionary * _Nullable)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; @@ -3803,6 +3880,46 @@ MTR_PROVISIONALLY_AVAILABLE @end +/** + * Cluster Power Topology + * The Power Topology Cluster provides a mechanism for expressing how power is flowing between endpoints. + */ +MTR_PROVISIONALLY_AVAILABLE +@interface MTRClusterPowerTopology : MTRGenericCluster + +- (NSDictionary * _Nullable)readAttributeAvailableEndpointsWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeActiveEndpointsWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeEventListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +@interface MTRClusterPowerTopology (Availability) + +/** + * The queue is currently unused, but may be used in the future for calling completions + * for command invocations if commands are added to this cluster. + */ +- (instancetype _Nullable)initWithDevice:(MTRDevice *)device + endpointID:(NSNumber *)endpointID + queue:(dispatch_queue_t)queue MTR_PROVISIONALLY_AVAILABLE; + +@end + /** * Cluster Energy EVSE Mode * Attributes and commands for selecting a mode from a list of supported options. diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm index 5e4b455673849f..2374d7f3cf9531 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm @@ -3793,6 +3793,33 @@ - (void)timeSnapshotWithParams:(MTRGeneralDiagnosticsClusterTimeSnapshotParams * completion:responseHandler]; } +- (void)payloadTestRequestWithParams:(MTRGeneralDiagnosticsClusterPayloadTestRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRGeneralDiagnosticsClusterPayloadTestResponseParams * _Nullable data, NSError * _Nullable error))completion +{ + if (params == nil) { + params = [[MTRGeneralDiagnosticsClusterPayloadTestRequestParams + alloc] init]; + } + + auto responseHandler = ^(id _Nullable response, NSError * _Nullable error) { + completion(response, error); + }; + + auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs; + + using RequestType = GeneralDiagnostics::Commands::PayloadTestRequest::Type; + [self.device _invokeKnownCommandWithEndpointID:self.endpointID + clusterID:@(RequestType::GetClusterId()) + commandID:@(RequestType::GetCommandId()) + commandPayload:params + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + timedInvokeTimeout:timedInvokeTimeoutMs + serverSideProcessingTimeout:params.serverSideProcessingTimeout + responseClass:MTRGeneralDiagnosticsClusterPayloadTestResponseParams.class + queue:self.callbackQueue + completion:responseHandler]; +} + - (NSDictionary * _Nullable)readAttributeNetworkInterfacesWithParams:(MTRReadParams * _Nullable)params { return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeGeneralDiagnosticsID) attributeID:@(MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeNetworkInterfacesID) params:params]; @@ -9069,6 +9096,135 @@ - (void)writeAttributeDefaultOpenLevelWithValue:(NSDictionary *) @end +@implementation MTRClusterElectricalPowerMeasurement + +- (NSDictionary * _Nullable)readAttributePowerModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributePowerModeID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeNumberOfMeasurementTypesWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeNumberOfMeasurementTypesID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeAccuracyWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeAccuracyID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeRangesWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRangesID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeVoltageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeVoltageID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeActiveCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeActiveCurrentID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeReactiveCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeReactiveCurrentID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeApparentCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeApparentCurrentID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeActivePowerWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeActivePowerID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeReactivePowerWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeReactivePowerID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeApparentPowerWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeApparentPowerID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeRMSVoltageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRMSVoltageID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeRMSCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRMSCurrentID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeRMSPowerWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRMSPowerID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeFrequencyWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeFrequencyID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeHarmonicCurrentsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeHarmonicCurrentsID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeHarmonicPhasesWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeHarmonicPhasesID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributePowerFactorWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributePowerFactorID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeNeutralCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeNeutralCurrentID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeGeneratedCommandListID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeAcceptedCommandListID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeEventListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeEventListID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeAttributeListID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeFeatureMapID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalPowerMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeClusterRevisionID) params:params]; +} + +@end + @implementation MTRClusterElectricalEnergyMeasurement - (NSDictionary * _Nullable)readAttributeAccuracyWithParams:(MTRReadParams * _Nullable)params @@ -9096,6 +9252,11 @@ @implementation MTRClusterElectricalEnergyMeasurement return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalEnergyMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributePeriodicEnergyExportedID) params:params]; } +- (NSDictionary * _Nullable)readAttributeCumulativeEnergyResetWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalEnergyMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeCumulativeEnergyResetID) params:params]; +} + - (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params { return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeElectricalEnergyMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeGeneratedCommandListID) params:params]; @@ -10252,6 +10413,50 @@ - (void)writeAttributeCurrentLowPowerModeSensitivityWithValue:(NSDictionary * _Nullable)readAttributeAvailableEndpointsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypePowerTopologyID) attributeID:@(MTRAttributeIDTypeClusterPowerTopologyAttributeAvailableEndpointsID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeActiveEndpointsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypePowerTopologyID) attributeID:@(MTRAttributeIDTypeClusterPowerTopologyAttributeActiveEndpointsID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypePowerTopologyID) attributeID:@(MTRAttributeIDTypeClusterPowerTopologyAttributeGeneratedCommandListID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypePowerTopologyID) attributeID:@(MTRAttributeIDTypeClusterPowerTopologyAttributeAcceptedCommandListID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeEventListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypePowerTopologyID) attributeID:@(MTRAttributeIDTypeClusterPowerTopologyAttributeEventListID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypePowerTopologyID) attributeID:@(MTRAttributeIDTypeClusterPowerTopologyAttributeAttributeListID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypePowerTopologyID) attributeID:@(MTRAttributeIDTypeClusterPowerTopologyAttributeFeatureMapID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypePowerTopologyID) attributeID:@(MTRAttributeIDTypeClusterPowerTopologyAttributeClusterRevisionID) params:params]; +} + +@end + @implementation MTRClusterEnergyEVSEMode - (void)changeToModeWithParams:(MTREnergyEVSEModeClusterChangeToModeParams *)params expectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTREnergyEVSEModeClusterChangeToModeResponseParams * _Nullable data, NSError * _Nullable error))completion diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h index b2159626d29866..8f2b0705fe3283 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h @@ -2543,6 +2543,59 @@ MTR_PROVISIONALLY_AVAILABLE error:(NSError * __autoreleasing *)error MTR_PROVISIONALLY_AVAILABLE; @end +MTR_PROVISIONALLY_AVAILABLE +@interface MTRGeneralDiagnosticsClusterPayloadTestRequestParams : NSObject + +@property (nonatomic, copy) NSData * _Nonnull enableKey MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nonnull value MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy, getter=getCount) NSNumber * _Nonnull count MTR_PROVISIONALLY_AVAILABLE; +/** + * Controls whether the command is a timed command (using Timed Invoke). + * + * If nil (the default value), a regular invoke is done for commands that do + * not require a timed invoke and a timed invoke with some default timed request + * timeout is done for commands that require a timed invoke. + * + * If not nil, a timed invoke is done, with the provided value used as the timed + * request timeout. The value should be chosen small enough to provide the + * desired security properties but large enough that it will allow a round-trip + * from the sever to the client (for the status response and actual invoke + * request) within the timeout window. + * + */ +@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; + +/** + * Controls how much time, in seconds, we will allow for the server to process the command. + * + * The command will then time out if that much time, plus an allowance for retransmits due to network failures, passes. + * + * If nil, the framework will try to select an appropriate timeout value itself. + */ +@property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; +@end + +MTR_PROVISIONALLY_AVAILABLE +@interface MTRGeneralDiagnosticsClusterPayloadTestResponseParams : NSObject + +@property (nonatomic, copy) NSData * _Nonnull payload MTR_PROVISIONALLY_AVAILABLE; + +/** + * Initialize an MTRGeneralDiagnosticsClusterPayloadTestResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_PROVISIONALLY_AVAILABLE; +@end + MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @interface MTRSoftwareDiagnosticsClusterResetWatermarksParams : NSObject /** diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index 6e7f500929877d..b2c13559d07aec 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -26,8 +26,8 @@ #import "NSStringSpanConversion.h" #include +#include #include -#include #include #include @@ -6532,6 +6532,176 @@ - (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::GeneralD @end +@implementation MTRGeneralDiagnosticsClusterPayloadTestRequestParams +- (instancetype)init +{ + if (self = [super init]) { + + _enableKey = [NSData data]; + + _value = @(0); + + _count = @(0); + _timedInvokeTimeoutMs = nil; + _serverSideProcessingTimeout = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone; +{ + auto other = [[MTRGeneralDiagnosticsClusterPayloadTestRequestParams alloc] init]; + + other.enableKey = self.enableKey; + other.value = self.value; + other.count = self.count; + other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; + other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: enableKey:%@; value:%@; count:%@; >", NSStringFromClass([self class]), [_enableKey base64EncodedStringWithOptions:0], _value, _count]; + return descriptionString; +} + +@end + +@implementation MTRGeneralDiagnosticsClusterPayloadTestRequestParams (InternalMethods) + +- (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader +{ + chip::app::Clusters::GeneralDiagnostics::Commands::PayloadTestRequest::Type encodableStruct; + ListFreer listFreer; + { + encodableStruct.enableKey = AsByteSpan(self.enableKey); + } + { + encodableStruct.value = self.value.unsignedCharValue; + } + { + encodableStruct.count = self.count.unsignedShortValue; + } + + auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); + if (buffer.IsNull()) { + return CHIP_ERROR_NO_MEMORY; + } + + chip::System::PacketBufferTLVWriter writer; + // Commands never need chained buffers, since they cannot be chunked. + writer.Init(std::move(buffer), /* useChainedBuffers = */ false); + + ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::AnonymousTag(), encodableStruct)); + + ReturnErrorOnFailure(writer.Finalize(&buffer)); + + reader.Init(std::move(buffer)); + return reader.Next(chip::TLV::kTLVType_Structure, chip::TLV::AnonymousTag()); +} + +- (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error +{ + chip::System::PacketBufferTLVReader reader; + CHIP_ERROR err = [self _encodeToTLVReader:reader]; + if (err != CHIP_NO_ERROR) { + if (error) { + *error = [MTRError errorForCHIPErrorCode:err]; + } + return nil; + } + + auto decodedObj = MTRDecodeDataValueDictionaryFromCHIPTLV(&reader); + if (decodedObj == nil) { + if (error) { + *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE]; + } + } + return decodedObj; +} +@end + +@implementation MTRGeneralDiagnosticsClusterPayloadTestResponseParams +- (instancetype)init +{ + if (self = [super init]) { + + _payload = [NSData data]; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone; +{ + auto other = [[MTRGeneralDiagnosticsClusterPayloadTestResponseParams alloc] init]; + + other.payload = self.payload; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: payload:%@; >", NSStringFromClass([self class]), [_payload base64EncodedStringWithOptions:0]]; + return descriptionString; +} + +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::GeneralDiagnostics::Commands::PayloadTestResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRGeneralDiagnosticsClusterPayloadTestResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::GeneralDiagnostics::Commands::PayloadTestResponse::DecodableType &)decodableStruct +{ + { + self.payload = AsData(decodableStruct.payload); + } + return CHIP_NO_ERROR; +} + +@end + @implementation MTRSoftwareDiagnosticsClusterResetWatermarksParams - (instancetype)init { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h index d72da7c651f191..2579d3bc49a9bd 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h @@ -424,6 +424,18 @@ NS_ASSUME_NONNULL_BEGIN @end +@interface MTRGeneralDiagnosticsClusterPayloadTestRequestParams (InternalMethods) + +- (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error; + +@end + +@interface MTRGeneralDiagnosticsClusterPayloadTestResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::GeneralDiagnostics::Commands::PayloadTestResponse::DecodableType &)decodableStruct; + +@end + @interface MTRSoftwareDiagnosticsClusterResetWatermarksParams (InternalMethods) - (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandTimedCheck.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandTimedCheck.mm index e0269f1690b533..685ca8f4f035a9 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandTimedCheck.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandTimedCheck.mm @@ -590,6 +590,15 @@ static BOOL CommandNeedsTimedInvokeInValveConfigurationAndControlCluster(Attribu } } } +static BOOL CommandNeedsTimedInvokeInElectricalPowerMeasurementCluster(AttributeId aAttributeId) +{ + using namespace Clusters::ElectricalPowerMeasurement; + switch (aAttributeId) { + default: { + return NO; + } + } +} static BOOL CommandNeedsTimedInvokeInElectricalEnergyMeasurementCluster(AttributeId aAttributeId) { using namespace Clusters::ElectricalEnergyMeasurement; @@ -665,6 +674,15 @@ static BOOL CommandNeedsTimedInvokeInEnergyPreferenceCluster(AttributeId aAttrib } } } +static BOOL CommandNeedsTimedInvokeInPowerTopologyCluster(AttributeId aAttributeId) +{ + using namespace Clusters::PowerTopology; + switch (aAttributeId) { + default: { + return NO; + } + } +} static BOOL CommandNeedsTimedInvokeInEnergyEVSEModeCluster(AttributeId aAttributeId) { using namespace Clusters::EnergyEvseMode; @@ -1296,6 +1314,9 @@ BOOL MTRCommandNeedsTimedInvoke(NSNumber * _Nonnull aClusterID, NSNumber * _Nonn case Clusters::ValveConfigurationAndControl::Id: { return CommandNeedsTimedInvokeInValveConfigurationAndControlCluster(commandID); } + case Clusters::ElectricalPowerMeasurement::Id: { + return CommandNeedsTimedInvokeInElectricalPowerMeasurementCluster(commandID); + } case Clusters::ElectricalEnergyMeasurement::Id: { return CommandNeedsTimedInvokeInElectricalEnergyMeasurementCluster(commandID); } @@ -1314,6 +1335,9 @@ BOOL MTRCommandNeedsTimedInvoke(NSNumber * _Nonnull aClusterID, NSNumber * _Nonn case Clusters::EnergyPreference::Id: { return CommandNeedsTimedInvokeInEnergyPreferenceCluster(commandID); } + case Clusters::PowerTopology::Id: { + return CommandNeedsTimedInvokeInPowerTopologyCluster(commandID); + } case Clusters::EnergyEvseMode::Id: { return CommandNeedsTimedInvokeInEnergyEVSEModeCluster(commandID); } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm b/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm index c9a5be796fc548..46427cba7fab3b 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm @@ -92,6 +92,8 @@ { 0x00000305, DeviceTypeClass::Simple, "Matter Pressure Sensor" }, { 0x00000306, DeviceTypeClass::Simple, "Matter Flow Sensor" }, { 0x00000307, DeviceTypeClass::Simple, "Matter Humidity Sensor" }, + { 0x0000050C, DeviceTypeClass::Simple, "Matter EVSE" }, + { 0x00000510, DeviceTypeClass::Utility, "Matter Electrical Sensor" }, { 0x00000840, DeviceTypeClass::Simple, "Matter Control Bridge" }, { 0x00000850, DeviceTypeClass::Simple, "Matter On/Off Sensor" }, { 0xFFF10010, DeviceTypeClass::Simple, "Matter Network Infrastructure Manager" }, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm index 431d29dac94ef3..3e36773ffebd99 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm @@ -2476,6 +2476,93 @@ static id _Nullable DecodeEventPayloadForValveConfigurationAndControlCluster(Eve *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; return nil; } +static id _Nullable DecodeEventPayloadForElectricalPowerMeasurementCluster(EventId aEventId, TLV::TLVReader & aReader, CHIP_ERROR * aError) +{ + using namespace Clusters::ElectricalPowerMeasurement; + switch (aEventId) { + case Events::MeasurementPeriodRanges::Id: { + Events::MeasurementPeriodRanges::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + + __auto_type * value = [MTRElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent new]; + + do { + NSArray * _Nonnull memberValue; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.ranges.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + MTRElectricalPowerMeasurementClusterMeasurementRangeStruct * newElement_0; + newElement_0 = [MTRElectricalPowerMeasurementClusterMeasurementRangeStruct new]; + newElement_0.measurementType = [NSNumber numberWithUnsignedShort:chip::to_underlying(entry_0.measurementType)]; + newElement_0.min = [NSNumber numberWithLongLong:entry_0.min]; + newElement_0.max = [NSNumber numberWithLongLong:entry_0.max]; + if (entry_0.startTimestamp.HasValue()) { + newElement_0.startTimestamp = [NSNumber numberWithUnsignedInt:entry_0.startTimestamp.Value()]; + } else { + newElement_0.startTimestamp = nil; + } + if (entry_0.endTimestamp.HasValue()) { + newElement_0.endTimestamp = [NSNumber numberWithUnsignedInt:entry_0.endTimestamp.Value()]; + } else { + newElement_0.endTimestamp = nil; + } + if (entry_0.minTimestamp.HasValue()) { + newElement_0.minTimestamp = [NSNumber numberWithUnsignedInt:entry_0.minTimestamp.Value()]; + } else { + newElement_0.minTimestamp = nil; + } + if (entry_0.maxTimestamp.HasValue()) { + newElement_0.maxTimestamp = [NSNumber numberWithUnsignedInt:entry_0.maxTimestamp.Value()]; + } else { + newElement_0.maxTimestamp = nil; + } + if (entry_0.startSystime.HasValue()) { + newElement_0.startSystime = [NSNumber numberWithUnsignedLongLong:entry_0.startSystime.Value()]; + } else { + newElement_0.startSystime = nil; + } + if (entry_0.endSystime.HasValue()) { + newElement_0.endSystime = [NSNumber numberWithUnsignedLongLong:entry_0.endSystime.Value()]; + } else { + newElement_0.endSystime = nil; + } + if (entry_0.minSystime.HasValue()) { + newElement_0.minSystime = [NSNumber numberWithUnsignedLongLong:entry_0.minSystime.Value()]; + } else { + newElement_0.minSystime = nil; + } + if (entry_0.maxSystime.HasValue()) { + newElement_0.maxSystime = [NSNumber numberWithUnsignedLongLong:entry_0.maxSystime.Value()]; + } else { + newElement_0.maxSystime = nil; + } + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + memberValue = array_0; + } + value.ranges = memberValue; + } while (0); + + return value; + } + default: { + break; + } + } + + *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; + return nil; +} static id _Nullable DecodeEventPayloadForElectricalEnergyMeasurementCluster(EventId aEventId, TLV::TLVReader & aReader, CHIP_ERROR * aError) { using namespace Clusters::ElectricalEnergyMeasurement; @@ -3165,6 +3252,18 @@ static id _Nullable DecodeEventPayloadForEnergyPreferenceCluster(EventId aEventI *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; return nil; } +static id _Nullable DecodeEventPayloadForPowerTopologyCluster(EventId aEventId, TLV::TLVReader & aReader, CHIP_ERROR * aError) +{ + using namespace Clusters::PowerTopology; + switch (aEventId) { + default: { + break; + } + } + + *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; + return nil; +} static id _Nullable DecodeEventPayloadForEnergyEVSEModeCluster(EventId aEventId, TLV::TLVReader & aReader, CHIP_ERROR * aError) { using namespace Clusters::EnergyEvseMode; @@ -4632,6 +4731,9 @@ id _Nullable MTRDecodeEventPayload(const ConcreteEventPath & aPath, TLV::TLVRead case Clusters::ValveConfigurationAndControl::Id: { return DecodeEventPayloadForValveConfigurationAndControlCluster(aPath.mEventId, aReader, aError); } + case Clusters::ElectricalPowerMeasurement::Id: { + return DecodeEventPayloadForElectricalPowerMeasurementCluster(aPath.mEventId, aReader, aError); + } case Clusters::ElectricalEnergyMeasurement::Id: { return DecodeEventPayloadForElectricalEnergyMeasurementCluster(aPath.mEventId, aReader, aError); } @@ -4650,6 +4752,9 @@ id _Nullable MTRDecodeEventPayload(const ConcreteEventPath & aPath, TLV::TLVRead case Clusters::EnergyPreference::Id: { return DecodeEventPayloadForEnergyPreferenceCluster(aPath.mEventId, aReader, aError); } + case Clusters::PowerTopology::Id: { + return DecodeEventPayloadForPowerTopologyCluster(aPath.mEventId, aReader, aError); + } case Clusters::EnergyEvseMode::Id: { return DecodeEventPayloadForEnergyEVSEModeCluster(aPath.mEventId, aReader, aError); } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h index 395497c0bfc648..fb805fa04b3b43 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h @@ -1071,6 +1071,53 @@ MTR_PROVISIONALLY_AVAILABLE @property (nonatomic, copy) NSNumber * _Nonnull valveFault MTR_PROVISIONALLY_AVAILABLE; @end +MTR_PROVISIONALLY_AVAILABLE +@interface MTRElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull rangeMin MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull rangeMax MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable percentMax MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable percentMin MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable percentTypical MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable fixedMax MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable fixedMin MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable fixedTypical MTR_PROVISIONALLY_AVAILABLE; +@end + +MTR_PROVISIONALLY_AVAILABLE +@interface MTRElectricalPowerMeasurementClusterMeasurementAccuracyStruct : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull measurementType MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull measured MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull minMeasuredValue MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull maxMeasuredValue MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSArray * _Nonnull accuracyRanges MTR_PROVISIONALLY_AVAILABLE; +@end + +MTR_PROVISIONALLY_AVAILABLE +@interface MTRElectricalPowerMeasurementClusterHarmonicMeasurementStruct : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull order MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable measurement MTR_PROVISIONALLY_AVAILABLE; +@end + +MTR_PROVISIONALLY_AVAILABLE +@interface MTRElectricalPowerMeasurementClusterMeasurementRangeStruct : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull measurementType MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull min MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull max MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable startTimestamp MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable endTimestamp MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable minTimestamp MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable maxTimestamp MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable startSystime MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable endSystime MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable minSystime MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable maxSystime MTR_PROVISIONALLY_AVAILABLE; +@end + +MTR_PROVISIONALLY_AVAILABLE +@interface MTRElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent : NSObject +@property (nonatomic, copy) NSArray * _Nonnull ranges MTR_PROVISIONALLY_AVAILABLE; +@end + MTR_PROVISIONALLY_AVAILABLE @interface MTRElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct : NSObject @property (nonatomic, copy) NSNumber * _Nonnull rangeMin MTR_PROVISIONALLY_AVAILABLE; @@ -1092,6 +1139,14 @@ MTR_PROVISIONALLY_AVAILABLE @property (nonatomic, copy) NSArray * _Nonnull accuracyRanges MTR_PROVISIONALLY_AVAILABLE; @end +MTR_PROVISIONALLY_AVAILABLE +@interface MTRElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct : NSObject +@property (nonatomic, copy) NSNumber * _Nullable importedResetTimestamp MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable exportedResetTimestamp MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable importedResetSystime MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable exportedResetSystime MTR_PROVISIONALLY_AVAILABLE; +@end + MTR_PROVISIONALLY_AVAILABLE @interface MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct : NSObject @property (nonatomic, copy) NSNumber * _Nonnull energy MTR_PROVISIONALLY_AVAILABLE; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm index 00c787feacb3c0..c9c38c72710756 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm @@ -4297,6 +4297,207 @@ - (NSString *)description @end +@implementation MTRElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct +- (instancetype)init +{ + if (self = [super init]) { + + _rangeMin = @(0); + + _rangeMax = @(0); + + _percentMax = nil; + + _percentMin = nil; + + _percentTypical = nil; + + _fixedMax = nil; + + _fixedMin = nil; + + _fixedTypical = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct alloc] init]; + + other.rangeMin = self.rangeMin; + other.rangeMax = self.rangeMax; + other.percentMax = self.percentMax; + other.percentMin = self.percentMin; + other.percentTypical = self.percentTypical; + other.fixedMax = self.fixedMax; + other.fixedMin = self.fixedMin; + other.fixedTypical = self.fixedTypical; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: rangeMin:%@; rangeMax:%@; percentMax:%@; percentMin:%@; percentTypical:%@; fixedMax:%@; fixedMin:%@; fixedTypical:%@; >", NSStringFromClass([self class]), _rangeMin, _rangeMax, _percentMax, _percentMin, _percentTypical, _fixedMax, _fixedMin, _fixedTypical]; + return descriptionString; +} + +@end + +@implementation MTRElectricalPowerMeasurementClusterMeasurementAccuracyStruct +- (instancetype)init +{ + if (self = [super init]) { + + _measurementType = @(0); + + _measured = @(0); + + _minMeasuredValue = @(0); + + _maxMeasuredValue = @(0); + + _accuracyRanges = [NSArray array]; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRElectricalPowerMeasurementClusterMeasurementAccuracyStruct alloc] init]; + + other.measurementType = self.measurementType; + other.measured = self.measured; + other.minMeasuredValue = self.minMeasuredValue; + other.maxMeasuredValue = self.maxMeasuredValue; + other.accuracyRanges = self.accuracyRanges; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: measurementType:%@; measured:%@; minMeasuredValue:%@; maxMeasuredValue:%@; accuracyRanges:%@; >", NSStringFromClass([self class]), _measurementType, _measured, _minMeasuredValue, _maxMeasuredValue, _accuracyRanges]; + return descriptionString; +} + +@end + +@implementation MTRElectricalPowerMeasurementClusterHarmonicMeasurementStruct +- (instancetype)init +{ + if (self = [super init]) { + + _order = @(0); + + _measurement = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRElectricalPowerMeasurementClusterHarmonicMeasurementStruct alloc] init]; + + other.order = self.order; + other.measurement = self.measurement; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: order:%@; measurement:%@; >", NSStringFromClass([self class]), _order, _measurement]; + return descriptionString; +} + +@end + +@implementation MTRElectricalPowerMeasurementClusterMeasurementRangeStruct +- (instancetype)init +{ + if (self = [super init]) { + + _measurementType = @(0); + + _min = @(0); + + _max = @(0); + + _startTimestamp = nil; + + _endTimestamp = nil; + + _minTimestamp = nil; + + _maxTimestamp = nil; + + _startSystime = nil; + + _endSystime = nil; + + _minSystime = nil; + + _maxSystime = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRElectricalPowerMeasurementClusterMeasurementRangeStruct alloc] init]; + + other.measurementType = self.measurementType; + other.min = self.min; + other.max = self.max; + other.startTimestamp = self.startTimestamp; + other.endTimestamp = self.endTimestamp; + other.minTimestamp = self.minTimestamp; + other.maxTimestamp = self.maxTimestamp; + other.startSystime = self.startSystime; + other.endSystime = self.endSystime; + other.minSystime = self.minSystime; + other.maxSystime = self.maxSystime; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: measurementType:%@; min:%@; max:%@; startTimestamp:%@; endTimestamp:%@; minTimestamp:%@; maxTimestamp:%@; startSystime:%@; endSystime:%@; minSystime:%@; maxSystime:%@; >", NSStringFromClass([self class]), _measurementType, _min, _max, _startTimestamp, _endTimestamp, _minTimestamp, _maxTimestamp, _startSystime, _endSystime, _minSystime, _maxSystime]; + return descriptionString; +} + +@end + +@implementation MTRElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent +- (instancetype)init +{ + if (self = [super init]) { + + _ranges = [NSArray array]; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent alloc] init]; + + other.ranges = self.ranges; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: ranges:%@; >", NSStringFromClass([self class]), _ranges]; + return descriptionString; +} + +@end + @implementation MTRElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct - (instancetype)init { @@ -4384,6 +4585,42 @@ - (NSString *)description @end +@implementation MTRElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct +- (instancetype)init +{ + if (self = [super init]) { + + _importedResetTimestamp = nil; + + _exportedResetTimestamp = nil; + + _importedResetSystime = nil; + + _exportedResetSystime = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct alloc] init]; + + other.importedResetTimestamp = self.importedResetTimestamp; + other.exportedResetTimestamp = self.exportedResetTimestamp; + other.importedResetSystime = self.importedResetSystime; + other.exportedResetSystime = self.exportedResetSystime; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: importedResetTimestamp:%@; exportedResetTimestamp:%@; importedResetSystime:%@; exportedResetSystime:%@; >", NSStringFromClass([self class]), _importedResetTimestamp, _exportedResetTimestamp, _importedResetSystime, _exportedResetSystime]; + return descriptionString; +} + +@end + @implementation MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct - (instancetype)init { diff --git a/src/darwin/Framework/CHIP/zap-generated/endpoint_config.h b/src/darwin/Framework/CHIP/zap-generated/endpoint_config.h new file mode 100644 index 00000000000000..27cfbdb778d5f5 --- /dev/null +++ b/src/darwin/Framework/CHIP/zap-generated/endpoint_config.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This file is only here to satisfy includes in core files that expect an + * endpoint config. This file is NOT generated by ZAP, and provides the bare + * minimum information needed to allow things to compile. + * + * TO DO: This needs a better setup. + */ +#include + +/** + * We don't have any fixed endpoints. + */ +#define FIXED_ENDPOINT_COUNT 0 + +/** + * We don't have any attributes not implemented by AttributeAccessInterface. But + * using 0 here does not work, so just claim 1. + */ +#define ATTRIBUTE_LARGEST 1 + +#define GENERATED_ATTRIBUTES {} + +#define GENERATED_ENDPOINT_TYPES {} + +#define FIXED_DEVICE_TYPES {} + +#define ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT 0 + +#define FIXED_ENDPOINT_ARRAY {} + +#define FIXED_DEVICE_TYPE_LENGTHS {} + +#define FIXED_DEVICE_TYPE_OFFSETS {} + +#define FIXED_ENDPOINT_TYPES {} diff --git a/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m b/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m index 8bbb529236671e..effce2ef5b3403 100644 --- a/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m +++ b/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m @@ -32,6 +32,12 @@ static NSString * kOnboardingPayload = @"MT:-24J0AFN00KA0648G00"; static const uint16_t kTestVendorId = 0xFFF1u; +#ifdef DEBUG +@interface MTRDeviceController (Test) ++ (void)forceLocalhostAdvertisingOnly; +@end +#endif // DEBUG + @interface MTRPerControllerStorageTestsControllerDelegate : NSObject @property (nonatomic, strong) XCTestExpectation * expectation; @property (nonatomic, strong) NSNumber * deviceID; @@ -270,6 +276,9 @@ - (nullable MTRDeviceController *)startControllerWithRootKeys:(MTRTestKeys *)roo intermediateCertificate:nil rootCertificate:root]; XCTAssertNotNil(params); + // TODO: This is only used by testControllerServer. If that moves + // elsewhere, take this back out again. + params.shouldAdvertiseOperational = YES; __auto_type * ourCertificateIssuer = [[MTRPerControllerStorageTestsCertificateIssuer alloc] initWithRootCertificate:root intermediateCertificate:nil @@ -1035,6 +1044,471 @@ - (void)test007_TestMultipleControllers XCTAssertFalse([controller3 isRunning]); } +// TODO: This might want to go in a separate test file, with some shared setup +// across multiple tests, maybe. Would need to factor out +// startControllerWithRootKeys into a test helper. +- (void)testControllerServer +{ +#ifdef DEBUG + // Force our controllers to only advertise on localhost, to avoid DNS-SD + // crosstalk. + [MTRDeviceController forceLocalhostAdvertisingOnly]; +#endif // DEBUG + + __auto_type queue = dispatch_get_main_queue(); + + __auto_type * rootKeys = [[MTRTestKeys alloc] init]; + XCTAssertNotNil(rootKeys); + + NSNumber * fabricID = @(456); + + __auto_type * operationalKeysServer = [[MTRTestKeys alloc] init]; + XCTAssertNotNil(operationalKeysServer); + + __auto_type * storageDelegateServer = [[MTRTestPerControllerStorage alloc] initWithControllerID:[NSUUID UUID]]; + XCTAssertNotNil(storageDelegateServer); + + NSNumber * nodeIDServer = @(123); + + NSError * error; + MTRDeviceController * controllerServer = [self startControllerWithRootKeys:rootKeys + operationalKeys:operationalKeysServer + fabricID:fabricID + nodeID:nodeIDServer + storage:storageDelegateServer + error:&error]; + XCTAssertNil(error); + XCTAssertNotNil(controllerServer); + XCTAssertTrue([controllerServer isRunning]); + XCTAssertEqualObjects(controllerServer.controllerNodeID, nodeIDServer); + + __auto_type * endpointId1 = @(10); + __auto_type * endpointId2 = @(20); + __auto_type * endpointId3 = @(30); + __auto_type * clusterId1 = @(0xFFF1FC02); + __auto_type * clusterId2 = @(0xFFF1FC10); + __auto_type * clusterRevision1 = @(3); + __auto_type * clusterRevision2 = @(4); + __auto_type * attributeId1 = @(0); + __auto_type * attributeId2 = @(0xFFF10002); + + __auto_type * unsignedIntValue1 = @{ + MTRTypeKey : MTRUnsignedIntegerValueType, + MTRValueKey : @(5), + }; + + __auto_type * unsignedIntValue2 = @{ + MTRTypeKey : MTRUnsignedIntegerValueType, + MTRValueKey : @(7), + }; + + __auto_type * structValue1 = @{ + MTRTypeKey : MTRStructureValueType, + MTRValueKey : @[ + @{ + MTRContextTagKey : @(1), + MTRDataKey : @ { + MTRTypeKey : MTRUnsignedIntegerValueType, + MTRValueKey : @(1), + }, + }, + @{ + MTRContextTagKey : @(2), + MTRDataKey : @ { + MTRTypeKey : MTRUTF8StringValueType, + MTRValueKey : @"struct1", + }, + }, + ], + }; + + __auto_type * structValue2 = @{ + MTRTypeKey : MTRStructureValueType, + MTRValueKey : @[ + @{ + MTRContextTagKey : @(1), + MTRDataKey : @ { + MTRTypeKey : MTRUnsignedIntegerValueType, + MTRValueKey : @(2), + }, + }, + @{ + MTRContextTagKey : @(2), + MTRDataKey : @ { + MTRTypeKey : MTRUTF8StringValueType, + MTRValueKey : @"struct2", + }, + }, + ], + }; + + __auto_type * listOfStructsValue1 = @{ + MTRTypeKey : MTRArrayValueType, + MTRValueKey : @[ + @{ + MTRDataKey : structValue1, + }, + @{ + MTRDataKey : structValue2, + }, + ], + }; + +#if 0 + __auto_type * listOfStructsValue2 = @{ + MTRTypeKey : MTRArrayValueType, + MTRValueKey : @[ + @{ MTRDataKey: structValue2, }, + ], + }; +#endif + + __auto_type responsePathFromRequestPath = ^(MTRAttributeRequestPath * path) { + return [MTRAttributePath attributePathWithEndpointID:path.endpoint clusterID:path.cluster attributeID:path.attribute]; + }; + + // Set up an endpoint on the server. + __auto_type * deviceType1 = [[MTRDeviceTypeRevision alloc] initWithDeviceTypeID:@(0xFFF10001) revision:@(1)]; + XCTAssertNotNil(deviceType1); + + __auto_type * endpoint1 = [[MTRServerEndpoint alloc] initWithEndpointID:endpointId1 deviceTypes:@[ deviceType1 ]]; + XCTAssertNotNil(endpoint1); + + __auto_type * cluster1 = [[MTRServerCluster alloc] initWithClusterID:clusterId1 revision:clusterRevision1]; + XCTAssertNotNil(cluster1); + + __auto_type * cluster2 = [[MTRServerCluster alloc] initWithClusterID:clusterId2 revision:clusterRevision2]; + XCTAssertNotNil(cluster1); + + __auto_type * attribute1 = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:attributeId1 initialValue:unsignedIntValue1 requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertNotNil(attribute1); + __auto_type * attribute1RequestPath = [MTRAttributeRequestPath requestPathWithEndpointID:endpointId1 + clusterID:clusterId1 + attributeID:attributeId1]; + XCTAssertNotNil(attribute1RequestPath); + __auto_type * attribute1ResponsePath = responsePathFromRequestPath(attribute1RequestPath); + XCTAssertNotNil(attribute1ResponsePath); + + __auto_type * attribute2 = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:attributeId2 initialValue:listOfStructsValue1 requiredPrivilege:MTRAccessControlEntryPrivilegeManage]; + XCTAssertNotNil(attribute2); + __auto_type * attribute2RequestPath = [MTRAttributeRequestPath requestPathWithEndpointID:endpointId1 + clusterID:clusterId2 + attributeID:attributeId2]; + XCTAssertNotNil(attribute2RequestPath); + __auto_type * attribute2ResponsePath = responsePathFromRequestPath(attribute2RequestPath); + XCTAssertNotNil(attribute2ResponsePath); + + __auto_type * attribute3 = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:attributeId2 initialValue:unsignedIntValue1 requiredPrivilege:MTRAccessControlEntryPrivilegeOperate]; + XCTAssertNotNil(attribute3); + __auto_type * attribute3RequestPath = [MTRAttributeRequestPath requestPathWithEndpointID:endpointId1 + clusterID:clusterId1 + attributeID:attributeId2]; + XCTAssertNotNil(attribute3RequestPath); + __auto_type * attribute3ResponsePath = responsePathFromRequestPath(attribute3RequestPath); + XCTAssertNotNil(attribute3ResponsePath); + + XCTAssertTrue([cluster1 addAttribute:attribute1]); + XCTAssertTrue([cluster1 addAttribute:attribute3]); + + XCTAssertTrue([cluster2 addAttribute:attribute2]); + + XCTAssertTrue([endpoint1 addServerCluster:cluster1]); + XCTAssertTrue([endpoint1 addServerCluster:cluster2]); + + [endpoint1 addAccessGrant:[MTRAccessGrant accessGrantForAllNodesWithPrivilege:MTRAccessControlEntryPrivilegeView]]; + + XCTAssertTrue([controllerServer addServerEndpoint:endpoint1]); + + __auto_type * endpoint2 = [[MTRServerEndpoint alloc] initWithEndpointID:endpointId2 deviceTypes:@[ deviceType1 ]]; + XCTAssertNotNil(endpoint2); + // Should be able to add this endpoint as well. + XCTAssertTrue([controllerServer addServerEndpoint:endpoint2]); + + __auto_type * endpoint3 = [[MTRServerEndpoint alloc] initWithEndpointID:endpointId2 deviceTypes:@[ deviceType1 ]]; + XCTAssertNotNil(endpoint3); + // Should not be able to add this endpoint, since it's got a duplicate + // endpoint id. + XCTAssertFalse([controllerServer addServerEndpoint:endpoint3]); + + __auto_type * operationalKeysClient = [[MTRTestKeys alloc] init]; + XCTAssertNotNil(operationalKeysClient); + + __auto_type * storageDelegateClient = [[MTRTestPerControllerStorage alloc] initWithControllerID:[NSUUID UUID]]; + XCTAssertNotNil(storageDelegateClient); + + NSNumber * nodeIDClient = @(789); + + MTRDeviceController * controllerClient = [self startControllerWithRootKeys:rootKeys + operationalKeys:operationalKeysClient + fabricID:fabricID + nodeID:nodeIDClient + storage:storageDelegateClient + error:&error]; + XCTAssertNil(error); + XCTAssertNotNil(controllerClient); + XCTAssertTrue([controllerClient isRunning]); + XCTAssertEqualObjects(controllerClient.controllerNodeID, nodeIDClient); + + __auto_type * endpoint4 = [[MTRServerEndpoint alloc] initWithEndpointID:endpointId2 deviceTypes:@[ deviceType1 ]]; + XCTAssertNotNil(endpoint4); + // Should not be able to add this endpoint, since it's got a duplicate + // endpoint id, even though we are adding on a different controller. + XCTAssertFalse([controllerClient addServerEndpoint:endpoint4]); + + __auto_type * endpoint5 = [[MTRServerEndpoint alloc] initWithEndpointID:endpointId3 deviceTypes:@[ deviceType1 ]]; + XCTAssertNotNil(endpoint5); + // Should be able to add this one, though; it's unrelated to any existing endpoints. + XCTAssertTrue([controllerClient addServerEndpoint:endpoint5]); + + __auto_type * device = [MTRBaseDevice deviceWithNodeID:nodeIDServer controller:controllerClient]; + + __auto_type * requestPath = attribute1RequestPath; + __block __auto_type * responsePath = attribute1ResponsePath; + + __auto_type checkSingleValue = ^(NSArray *> * _Nullable values, NSError * _Nullable error, NSDictionary * expectedValue) { + // The overall interaction should succeed. + XCTAssertNil(error); + XCTAssertNotNil(values); + + // And we should get a value for our attribute. + XCTAssertEqual(values.count, 1); + + NSDictionary * value = values[0]; + XCTAssertEqualObjects(value[MTRAttributePathKey], responsePath); + + XCTAssertNil(value[MTRErrorKey]); + XCTAssertNotNil(value[MTRDataKey]); + + XCTAssertEqualObjects(value[MTRDataKey], expectedValue); + }; + + __auto_type checkSinglePathError = ^(NSArray *> * _Nullable values, NSError * _Nullable error, MTRInteractionErrorCode expectedError) { + // The overall interaction should succeed. + XCTAssertNil(error); + XCTAssertNotNil(values); + + // And we should get a value for our attribute. + XCTAssertEqual(values.count, 1); + + NSDictionary * value = values[0]; + XCTAssertEqualObjects(value[MTRAttributePathKey], responsePath); + + XCTAssertNil(value[MTRDataKey]); + XCTAssertNotNil(value[MTRErrorKey]); + + NSError * pathError = value[MTRErrorKey]; + XCTAssertEqual(pathError.domain, MTRInteractionErrorDomain); + XCTAssertEqual(pathError.code, expectedError); + }; + + // First try a basic read. + XCTestExpectation * readExpectation1 = [self expectationWithDescription:@"Read 1 of attribute complete"]; + [device readAttributePaths:@[ requestPath ] + eventPaths:nil + params:nil + queue:queue + completion:^(NSArray *> * _Nullable values, NSError * _Nullable error) { + checkSingleValue(values, error, unsignedIntValue1); + [readExpectation1 fulfill]; + }]; + [self waitForExpectations:@[ readExpectation1 ] timeout:kTimeoutInSeconds]; + + // Now try a basic subscribe. + __block void (^reportHandler)(NSArray *> * _Nullable values, NSError * _Nullable error); + + XCTestExpectation * initialValueExpectation = [self expectationWithDescription:@"Got initial value"]; + reportHandler = ^(NSArray *> * _Nullable values, NSError * _Nullable error) { + checkSingleValue(values, error, unsignedIntValue1); + [initialValueExpectation fulfill]; + }; + + XCTestExpectation * subscriptionEstablishedExpectation = [self expectationWithDescription:@"Basic subscription established"]; + __auto_type * subscribeParams = [[MTRSubscribeParams alloc] initWithMinInterval:@(0) maxInterval:@(10)]; + [device subscribeToAttributesWithEndpointID:requestPath.endpoint clusterID:requestPath.cluster attributeID:requestPath.attribute + params:subscribeParams + queue:queue + reportHandler:^(NSArray *> * _Nullable values, NSError * _Nullable error) { + reportHandler(values, error); + } + subscriptionEstablished:^() { + [subscriptionEstablishedExpectation fulfill]; + }]; + [self waitForExpectations:@[ subscriptionEstablishedExpectation, initialValueExpectation ] timeout:kTimeoutInSeconds]; + + // Now change the value and expect to see it on our subscription. + XCTestExpectation * valueUpdateExpectation = [self expectationWithDescription:@"We see the new value"]; + reportHandler = ^(NSArray *> * _Nullable values, NSError * _Nullable error) { + checkSingleValue(values, error, unsignedIntValue2); + [valueUpdateExpectation fulfill]; + }; + + [attribute1 setValue:unsignedIntValue2]; + + [self waitForExpectations:@[ valueUpdateExpectation ] timeout:kTimeoutInSeconds]; + + // Now try a read of an attribute we do not have permissions for. + requestPath = attribute2RequestPath; + responsePath = attribute2ResponsePath; + XCTestExpectation * readNoPermissionsExpectation1 = [self expectationWithDescription:@"Read 1 of attribute with no permissions complete"]; + [device readAttributePaths:@[ requestPath ] + eventPaths:nil + params:nil + queue:queue + completion:^(NSArray *> * _Nullable values, NSError * _Nullable error) { + checkSinglePathError(values, error, MTRInteractionErrorCodeUnsupportedAccess); + [readNoPermissionsExpectation1 fulfill]; + }]; + [self waitForExpectations:@[ readNoPermissionsExpectation1 ] timeout:kTimeoutInSeconds]; + + // Change the permissions to give Manage access on the cluster to some + // random node ID and try again. Should still have no permissions. + __auto_type * unrelatedGrant = [MTRAccessGrant accessGrantForNodeID:@(0xabc) privilege:MTRAccessControlEntryPrivilegeManage]; + XCTAssertNotNil(unrelatedGrant); + [cluster2 addAccessGrant:unrelatedGrant]; + + XCTestExpectation * readNoPermissionsExpectation2 = [self expectationWithDescription:@"Read 2 of attribute with no permissions complete"]; + [device readAttributePaths:@[ requestPath ] + eventPaths:nil + params:nil + queue:queue + completion:^(NSArray *> * _Nullable values, NSError * _Nullable error) { + checkSinglePathError(values, error, MTRInteractionErrorCodeUnsupportedAccess); + [readNoPermissionsExpectation2 fulfill]; + }]; + [self waitForExpectations:@[ readNoPermissionsExpectation2 ] timeout:kTimeoutInSeconds]; + + // Change the permissions to give Manage access on the cluster to our client + // node ID and try again. Should be able to read the attribute now. + __auto_type * clientManageGrant = [MTRAccessGrant accessGrantForNodeID:nodeIDClient privilege:MTRAccessControlEntryPrivilegeManage]; + XCTAssertNotNil(clientManageGrant); + [cluster2 addAccessGrant:clientManageGrant]; + + XCTestExpectation * readExpectation2 = [self expectationWithDescription:@"Read 2 of attribute complete"]; + [device readAttributePaths:@[ requestPath ] + eventPaths:nil + params:nil + queue:queue + completion:^(NSArray *> * _Nullable values, NSError * _Nullable error) { + checkSingleValue(values, error, listOfStructsValue1); + [readExpectation2 fulfill]; + }]; + [self waitForExpectations:@[ readExpectation2 ] timeout:kTimeoutInSeconds]; + + // Adding Manage permissions to one cluster should not affect another one. + requestPath = attribute3RequestPath; + responsePath = attribute3ResponsePath; + + XCTestExpectation * readNoPermissionsExpectation3 = [self expectationWithDescription:@"Read 3 of attribute with no permissions complete"]; + [device readAttributePaths:@[ requestPath ] + eventPaths:nil + params:nil + queue:queue + completion:^(NSArray *> * _Nullable values, NSError * _Nullable error) { + checkSinglePathError(values, error, MTRInteractionErrorCodeUnsupportedAccess); + [readNoPermissionsExpectation3 fulfill]; + }]; + [self waitForExpectations:@[ readNoPermissionsExpectation3 ] timeout:kTimeoutInSeconds]; + + // But adding Manage permissions on the endpoint should grant Operate on + // the cluster. + [endpoint1 addAccessGrant:clientManageGrant]; + + XCTestExpectation * readExpectation3 = [self expectationWithDescription:@"Read 3 of attribute complete"]; + [device readAttributePaths:@[ requestPath ] + eventPaths:nil + params:nil + queue:queue + completion:^(NSArray *> * _Nullable values, NSError * _Nullable error) { + checkSingleValue(values, error, unsignedIntValue1); + [readExpectation3 fulfill]; + }]; + [self waitForExpectations:@[ readExpectation3 ] timeout:kTimeoutInSeconds]; + + // And removing that grant should remove the permissions again. + [endpoint1 removeAccessGrant:clientManageGrant]; + + XCTestExpectation * readNoPermissionsExpectation4 = [self expectationWithDescription:@"Read 4 of attribute with no permissions complete"]; + [device readAttributePaths:@[ requestPath ] + eventPaths:nil + params:nil + queue:queue + completion:^(NSArray *> * _Nullable values, NSError * _Nullable error) { + checkSinglePathError(values, error, MTRInteractionErrorCodeUnsupportedAccess); + [readNoPermissionsExpectation4 fulfill]; + }]; + [self waitForExpectations:@[ readNoPermissionsExpectation4 ] timeout:kTimeoutInSeconds]; + + // Now do a wildcard read on the endpoint and check that this does the right + // thing (gets the right things from descriptor, gets both clusters, etc). +#if 0 + // Unused bits ifdefed out until we doing more testing on the actual values + // we get back. + __auto_type globalAttributePath = ^(NSNumber * clusterID, MTRAttributeIDType attributeID) { + return [MTRAttributePath attributePathWithEndpointID:endpointId1 clusterID:clusterID attributeID:@(attributeID)]; + }; + __auto_type unsignedIntValue = ^(NSUInteger value) { + return @{ + MTRTypeKey: MTRUnsignedIntegerValueType, + MTRValueKey: @(value), + }; + }; + __auto_type arrayOfUnsignedIntegersValue = ^(NSArray * values) { + __auto_type * mutableArray = [[NSMutableArray alloc] init]; + for (NSNumber * value in values) { + [mutableArray addObject:@{ MTRDataKey: @{ + MTRTypeKey: MTRUnsignedIntegerValueType, + MTRValueKey: value, + }, }]; + } + return @{ + MTRTypeKey: MTRArrayValueType, + MTRValueKey: [mutableArray copy], + }; + }; +#endif + XCTestExpectation * wildcardReadExpectation = [self expectationWithDescription:@"Wildcard read of our endpoint"]; + [device readAttributePaths:@[ [MTRAttributeRequestPath requestPathWithEndpointID:endpointId1 clusterID:nil attributeID:nil] ] + eventPaths:nil + params:nil + queue:queue + completion:^(NSArray *> * _Nullable values, NSError * _Nullable error) { + XCTAssertNil(error); + XCTAssertNotNil(values); + + // TODO: Figure out how to test that values is correct that's not + // too fragile if things get returned in different valid order. + // For now just check that every path we got has a value, not an + // error. + for (NSDictionary * value in values) { + XCTAssertNotNil(value[MTRAttributePathKey]); + XCTAssertNil(value[MTRErrorKey]); + XCTAssertNotNil(value[MTRDataKey]); + } +#if 0 + XCTAssertEqualObjects(values, @[ + // cluster1 + @{ MTRAttributePathKey: attribute1ResponsePath, + MTRDataKey: unsignedIntValue2, }, + @{ MTRAttributePathKey: globalAttributePath(clusterId1, MTRAttributeIDTypeGlobalAttributeFeatureMapID), + MTRDataKey: unsignedIntValue(0), }, + @{ MTRAttributePathKey: globalAttributePath(clusterId1, MTRAttributeIDTypeGlobalAttributeClusterRevisionID), + MTRDataKey: clusterRevision1, }, + @{ MTRAttributePathKey: globalAttributePath(clusterId1, MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID), + MTRDataKey: arrayOfUnsignedIntegersValue(@[]), }, + @{ MTRAttributePathKey: globalAttributePath(clusterId1, MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID), + MTRDataKey: arrayOfUnsignedIntegersValue(@[]), }, + // etc + + ]); +#endif + [wildcardReadExpectation fulfill]; + }]; + [self waitForExpectations:@[ wildcardReadExpectation ] timeout:kTimeoutInSeconds]; + + [controllerClient shutdown]; + [controllerServer shutdown]; +} + @end #endif // MTR_PER_CONTROLLER_STORAGE_ENABLED diff --git a/src/darwin/Framework/CHIPTests/MTRServerEndpointTests.m b/src/darwin/Framework/CHIPTests/MTRServerEndpointTests.m index 57b47f8eb540b7..4a7c31a25a8b02 100644 --- a/src/darwin/Framework/CHIPTests/MTRServerEndpointTests.m +++ b/src/darwin/Framework/CHIPTests/MTRServerEndpointTests.m @@ -130,12 +130,16 @@ - (void)testServerAttribute MTRTypeKey : MTRArrayValueType, MTRValueKey : @[ @{ - MTRTypeKey : MTRUTF8StringValueType, - MTRValueKey : @"str1", + MTRDataKey : @ { + MTRTypeKey : MTRUTF8StringValueType, + MTRValueKey : @"str1", + }, }, @{ - MTRTypeKey : MTRUTF8StringValueType, - MTRValueKey : @"str2", + MTRDataKey : @ { + MTRTypeKey : MTRUTF8StringValueType, + MTRValueKey : @"str2", + }, }, ], }; diff --git a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj index 52cd52b0b9599b..552a797d34a08f 100644 --- a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj @@ -150,6 +150,18 @@ 5143851E2A65885500EDC8E6 /* MTRSwiftPairingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5143851D2A65885500EDC8E6 /* MTRSwiftPairingTests.swift */; }; 514654492A72F9DF00904E61 /* MTRDemuxingStorage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 514654482A72F9DF00904E61 /* MTRDemuxingStorage.mm */; }; 5146544B2A72F9F500904E61 /* MTRDemuxingStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 5146544A2A72F9F500904E61 /* MTRDemuxingStorage.h */; }; + 514C79ED2B62ADCD00DD6D7B /* ember-compatibility-functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C79EC2B62ADCD00DD6D7B /* ember-compatibility-functions.cpp */; }; + 514C79EE2B62ADCD00DD6D7B /* ember-compatibility-functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C79EC2B62ADCD00DD6D7B /* ember-compatibility-functions.cpp */; }; + 514C79F02B62ADDA00DD6D7B /* descriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C79EF2B62ADDA00DD6D7B /* descriptor.cpp */; }; + 514C79F12B62ADDA00DD6D7B /* descriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C79EF2B62ADDA00DD6D7B /* descriptor.cpp */; }; + 514C79F32B62ED5500DD6D7B /* attribute-storage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C79F22B62ED5500DD6D7B /* attribute-storage.cpp */; }; + 514C79F42B62ED5500DD6D7B /* attribute-storage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C79F22B62ED5500DD6D7B /* attribute-storage.cpp */; }; + 514C79F62B62F0B900DD6D7B /* util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C79F52B62F0B900DD6D7B /* util.cpp */; }; + 514C79F72B62F0B900DD6D7B /* util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C79F52B62F0B900DD6D7B /* util.cpp */; }; + 514C79F92B62F60100DD6D7B /* message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C79F82B62F60100DD6D7B /* message.cpp */; }; + 514C79FA2B62F60100DD6D7B /* message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C79F82B62F60100DD6D7B /* message.cpp */; }; + 514C79FC2B62F94C00DD6D7B /* ota-provider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C79FB2B62F94C00DD6D7B /* ota-provider.cpp */; }; + 514C79FD2B62F94C00DD6D7B /* ota-provider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C79FB2B62F94C00DD6D7B /* ota-provider.cpp */; }; 514C7A012B64223400DD6D7B /* MTRServerAttribute_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 514C79FF2B64223400DD6D7B /* MTRServerAttribute_Internal.h */; }; 514C7A022B64223400DD6D7B /* MTRServerEndpoint_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 514C7A002B64223400DD6D7B /* MTRServerEndpoint_Internal.h */; }; 514C7A042B6436D500DD6D7B /* MTRServerCluster_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 514C7A032B6436D500DD6D7B /* MTRServerCluster_Internal.h */; }; @@ -160,6 +172,13 @@ 51565CB62A7B0D6600469F18 /* MTRDeviceControllerParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 51565CB52A7B0D6600469F18 /* MTRDeviceControllerParameters.h */; settings = {ATTRIBUTES = (Public, ); }; }; 515C1C6F284F9FFB00A48F0C /* MTRFramework.mm in Sources */ = {isa = PBXBuildFile; fileRef = 515C1C6D284F9FFB00A48F0C /* MTRFramework.mm */; }; 515C1C70284F9FFB00A48F0C /* MTRFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = 515C1C6E284F9FFB00A48F0C /* MTRFramework.h */; }; + 516411312B6BF70300E67C05 /* DataModelHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 516415FE2B6B132200D5CE11 /* DataModelHandler.cpp */; }; + 516411322B6BF75700E67C05 /* MTRIMDispatch.mm in Sources */ = {isa = PBXBuildFile; fileRef = 516416002B6B483C00D5CE11 /* MTRIMDispatch.mm */; }; + 516411332B6BF77700E67C05 /* MTRServerAccessControl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 516415FA2B6ACA8300D5CE11 /* MTRServerAccessControl.mm */; }; + 516415FC2B6ACA8300D5CE11 /* MTRServerAccessControl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 516415FA2B6ACA8300D5CE11 /* MTRServerAccessControl.mm */; }; + 516415FD2B6ACA8300D5CE11 /* MTRServerAccessControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 516415FB2B6ACA8300D5CE11 /* MTRServerAccessControl.h */; }; + 516415FF2B6B132200D5CE11 /* DataModelHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 516415FE2B6B132200D5CE11 /* DataModelHandler.cpp */; }; + 516416012B6B483C00D5CE11 /* MTRIMDispatch.mm in Sources */ = {isa = PBXBuildFile; fileRef = 516416002B6B483C00D5CE11 /* MTRIMDispatch.mm */; }; 51669AF02913204400F4AA36 /* MTRBackwardsCompatTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 51669AEF2913204400F4AA36 /* MTRBackwardsCompatTests.m */; }; 5173A47529C0E2ED00F67F48 /* MTRFabricInfo_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5173A47229C0E2ED00F67F48 /* MTRFabricInfo_Internal.h */; }; 5173A47629C0E2ED00F67F48 /* MTRFabricInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5173A47329C0E2ED00F67F48 /* MTRFabricInfo.mm */; }; @@ -183,8 +202,6 @@ 51B22C2A2740CB47008D5055 /* MTRCommandPayloadsObjc.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51B22C292740CB47008D5055 /* MTRCommandPayloadsObjc.mm */; }; 51C8E3F82825CDB600D47D00 /* MTRTestKeys.m in Sources */ = {isa = PBXBuildFile; fileRef = 51C8E3F72825CDB600D47D00 /* MTRTestKeys.m */; }; 51C984622A61CE2A00B0AD9A /* MTRFabricInfoChecker.m in Sources */ = {isa = PBXBuildFile; fileRef = 51C984602A61CE2A00B0AD9A /* MTRFabricInfoChecker.m */; }; - 51CFDDB12AC5F78F00DA7CA5 /* EmptyDataModelHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51CFDDB02AC5F78F00DA7CA5 /* EmptyDataModelHandler.cpp */; }; - 51CFDDB22AC5F78F00DA7CA5 /* EmptyDataModelHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51CFDDB02AC5F78F00DA7CA5 /* EmptyDataModelHandler.cpp */; }; 51D0B1272B617246006E3511 /* MTRServerEndpoint.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D0B1252B617246006E3511 /* MTRServerEndpoint.mm */; }; 51D0B1282B617246006E3511 /* MTRServerEndpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D0B1262B617246006E3511 /* MTRServerEndpoint.h */; settings = {ATTRIBUTES = (Public, ); }; }; 51D0B12A2B61766F006E3511 /* MTRServerEndpointTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 51D0B1292B61766F006E3511 /* MTRServerEndpointTests.m */; }; @@ -249,6 +266,8 @@ 88EBF8CE27FABDD500686BC1 /* MTRDeviceAttestationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 88EBF8CB27FABDD500686BC1 /* MTRDeviceAttestationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 88EBF8CF27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 88EBF8CC27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.mm */; }; 88EBF8D027FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 88EBF8CD27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.h */; }; + 93B2CF9A2B56E45C00E4D187 /* MTRClusterNames.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93B2CF992B56E45C00E4D187 /* MTRClusterNames.mm */; }; + 93E610AA2B626E290077F02A /* MTRClusterNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E610A92B626E290077F02A /* MTRClusterNames.h */; settings = {ATTRIBUTES = (Public, ); }; }; 991DC0842475F45400C13860 /* MTRDeviceController.h in Headers */ = {isa = PBXBuildFile; fileRef = 991DC0822475F45400C13860 /* MTRDeviceController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 991DC0892475F47D00C13860 /* MTRDeviceController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 991DC0872475F47D00C13860 /* MTRDeviceController.mm */; }; 991DC08B247704DC00C13860 /* MTRLogging_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 991DC08A247704DC00C13860 /* MTRLogging_Internal.h */; }; @@ -533,6 +552,12 @@ 5143851D2A65885500EDC8E6 /* MTRSwiftPairingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MTRSwiftPairingTests.swift; sourceTree = ""; }; 514654482A72F9DF00904E61 /* MTRDemuxingStorage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRDemuxingStorage.mm; sourceTree = ""; }; 5146544A2A72F9F500904E61 /* MTRDemuxingStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRDemuxingStorage.h; sourceTree = ""; }; + 514C79EC2B62ADCD00DD6D7B /* ember-compatibility-functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "ember-compatibility-functions.cpp"; path = "util/ember-compatibility-functions.cpp"; sourceTree = ""; }; + 514C79EF2B62ADDA00DD6D7B /* descriptor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = descriptor.cpp; path = clusters/descriptor/descriptor.cpp; sourceTree = ""; }; + 514C79F22B62ED5500DD6D7B /* attribute-storage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "attribute-storage.cpp"; path = "util/attribute-storage.cpp"; sourceTree = ""; }; + 514C79F52B62F0B900DD6D7B /* util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = util.cpp; path = util/util.cpp; sourceTree = ""; }; + 514C79F82B62F60100DD6D7B /* message.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = message.cpp; path = util/message.cpp; sourceTree = ""; }; + 514C79FB2B62F94C00DD6D7B /* ota-provider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "ota-provider.cpp"; path = "clusters/ota-provider/ota-provider.cpp"; sourceTree = ""; }; 514C79FF2B64223400DD6D7B /* MTRServerAttribute_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRServerAttribute_Internal.h; sourceTree = ""; }; 514C7A002B64223400DD6D7B /* MTRServerEndpoint_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRServerEndpoint_Internal.h; sourceTree = ""; }; 514C7A032B6436D500DD6D7B /* MTRServerCluster_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRServerCluster_Internal.h; sourceTree = ""; }; @@ -543,6 +568,10 @@ 51565CB52A7B0D6600469F18 /* MTRDeviceControllerParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRDeviceControllerParameters.h; sourceTree = ""; }; 515C1C6D284F9FFB00A48F0C /* MTRFramework.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRFramework.mm; sourceTree = ""; }; 515C1C6E284F9FFB00A48F0C /* MTRFramework.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRFramework.h; sourceTree = ""; }; + 516415FA2B6ACA8300D5CE11 /* MTRServerAccessControl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRServerAccessControl.mm; sourceTree = ""; }; + 516415FB2B6ACA8300D5CE11 /* MTRServerAccessControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRServerAccessControl.h; sourceTree = ""; }; + 516415FE2B6B132200D5CE11 /* DataModelHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataModelHandler.cpp; path = util/DataModelHandler.cpp; sourceTree = ""; }; + 516416002B6B483C00D5CE11 /* MTRIMDispatch.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRIMDispatch.mm; sourceTree = ""; }; 51669AEF2913204400F4AA36 /* MTRBackwardsCompatTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTRBackwardsCompatTests.m; sourceTree = ""; }; 5173A47229C0E2ED00F67F48 /* MTRFabricInfo_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRFabricInfo_Internal.h; sourceTree = ""; }; 5173A47329C0E2ED00F67F48 /* MTRFabricInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRFabricInfo.mm; sourceTree = ""; }; @@ -573,7 +602,6 @@ 51C8E3F72825CDB600D47D00 /* MTRTestKeys.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTRTestKeys.m; sourceTree = ""; }; 51C984602A61CE2A00B0AD9A /* MTRFabricInfoChecker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTRFabricInfoChecker.m; sourceTree = ""; }; 51C984612A61CE2A00B0AD9A /* MTRFabricInfoChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRFabricInfoChecker.h; sourceTree = ""; }; - 51CFDDB02AC5F78F00DA7CA5 /* EmptyDataModelHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EmptyDataModelHandler.cpp; path = ../controller/EmptyDataModelHandler.cpp; sourceTree = ""; }; 51D0B1252B617246006E3511 /* MTRServerEndpoint.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRServerEndpoint.mm; sourceTree = ""; }; 51D0B1262B617246006E3511 /* MTRServerEndpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRServerEndpoint.h; sourceTree = ""; }; 51D0B1292B61766F006E3511 /* MTRServerEndpointTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTRServerEndpointTests.m; sourceTree = ""; }; @@ -640,6 +668,8 @@ 88EBF8CB27FABDD500686BC1 /* MTRDeviceAttestationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRDeviceAttestationDelegate.h; sourceTree = ""; }; 88EBF8CC27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRDeviceAttestationDelegateBridge.mm; sourceTree = ""; }; 88EBF8CD27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRDeviceAttestationDelegateBridge.h; sourceTree = ""; }; + 93B2CF992B56E45C00E4D187 /* MTRClusterNames.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRClusterNames.mm; sourceTree = ""; }; + 93E610A92B626E290077F02A /* MTRClusterNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRClusterNames.h; sourceTree = ""; }; 991DC0822475F45400C13860 /* MTRDeviceController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRDeviceController.h; sourceTree = ""; }; 991DC0872475F47D00C13860 /* MTRDeviceController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRDeviceController.mm; sourceTree = ""; }; 991DC08A247704DC00C13860 /* MTRLogging_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRLogging_Internal.h; sourceTree = ""; }; @@ -1020,7 +1050,13 @@ isa = PBXGroup; children = ( 5143041F2914CED9004DC7FE /* generic-callback-stubs.cpp */, - 51CFDDB02AC5F78F00DA7CA5 /* EmptyDataModelHandler.cpp */, + 514C79F22B62ED5500DD6D7B /* attribute-storage.cpp */, + 514C79EF2B62ADDA00DD6D7B /* descriptor.cpp */, + 514C79EC2B62ADCD00DD6D7B /* ember-compatibility-functions.cpp */, + 516415FE2B6B132200D5CE11 /* DataModelHandler.cpp */, + 514C79F52B62F0B900DD6D7B /* util.cpp */, + 514C79F82B62F60100DD6D7B /* message.cpp */, + 514C79FB2B62F94C00DD6D7B /* ota-provider.cpp */, ); name = app; path = ../../../app; @@ -1036,6 +1072,7 @@ 7596A83D28751220004DAE0E /* MTRBaseClusters_Internal.h */, 1EC4CE5925CC26E900D7304F /* MTRBaseClusters.mm */, D4772A45285AE98300383630 /* MTRClusterConstants.h */, + 93B2CF992B56E45C00E4D187 /* MTRClusterNames.mm */, 7596A85428788557004DAE0E /* MTRClusters.h */, 3D843715294979230070D20A /* MTRClusters_Internal.h */, 7596A85228788557004DAE0E /* MTRClusters.mm */, @@ -1133,6 +1170,9 @@ children = ( 51D0B12C2B6177D9006E3511 /* MTRAccessGrant.h */, 51D0B12B2B6177D9006E3511 /* MTRAccessGrant.mm */, + 516416002B6B483C00D5CE11 /* MTRIMDispatch.mm */, + 516415FB2B6ACA8300D5CE11 /* MTRServerAccessControl.h */, + 516415FA2B6ACA8300D5CE11 /* MTRServerAccessControl.mm */, 51D0B1362B618CC6006E3511 /* MTRServerAttribute.h */, 51D0B1372B618CC6006E3511 /* MTRServerAttribute.mm */, 514C79FF2B64223400DD6D7B /* MTRServerAttribute_Internal.h */, @@ -1215,6 +1255,7 @@ 1ED276E326C5832500547A89 /* MTRCluster.h */, 7596A84E2877E6A9004DAE0E /* MTRCluster_Internal.h */, 1ED276E126C5812A00547A89 /* MTRCluster.mm */, + 93E610A92B626E290077F02A /* MTRClusterNames.h */, 5ACDDD7927CD129700EFD68A /* MTRClusterStateCacheContainer.h */, 5ACDDD7B27CD14AF00EFD68A /* MTRClusterStateCacheContainer_Internal.h */, 5ACDDD7C27CD16D200EFD68A /* MTRClusterStateCacheContainer.mm */, @@ -1535,6 +1576,7 @@ 754F3DF427FBB94B00E60580 /* MTREventTLVValueDecoder_Internal.h in Headers */, 3CF134AF289D90FF0017A19E /* MTROperationalCertificateIssuer.h in Headers */, 5178E6822AE098520069DF72 /* MTRCommissionableBrowserResult_Internal.h in Headers */, + 516415FD2B6ACA8300D5CE11 /* MTRServerAccessControl.h in Headers */, 3CF134AB289D8DF70017A19E /* MTRDeviceAttestationInfo.h in Headers */, B2E0D7B2245B0B5C003C5B48 /* MTRManualSetupPayloadParser.h in Headers */, 3CF134A7289D8ADA0017A19E /* MTRCSRInfo.h in Headers */, @@ -1561,6 +1603,7 @@ B4FCD56A2B5EDBD300832859 /* MTRDiagnosticLogsType.h in Headers */, 5A6FEC9A27B5C89300F25F42 /* MTRDeviceControllerXPCConnection.h in Headers */, 5129BCFD26A9EE3300122DDF /* MTRError.h in Headers */, + 93E610AA2B626E290077F02A /* MTRClusterNames.h in Headers */, 2C8C8FC1253E0C2100797F05 /* MTRStorage.h in Headers */, AF1CB8702874B04C00865A96 /* MTROTAProviderDelegateBridge.h in Headers */, B2E0D7B5245B0B5C003C5B48 /* MTRQRCodeSetupPayloadParser.h in Headers */, @@ -1750,8 +1793,10 @@ B45373F32A9FEC1A00807602 /* server-ws.c in Sources */, 03F430AA2994113500166449 /* sysunix.c in Sources */, B45373C42A9FEA9100807602 /* dummy-callback.c in Sources */, + 514C79EE2B62ADCD00DD6D7B /* ember-compatibility-functions.cpp in Sources */, 039145E82993179300257B3E /* GetCommissionerNodeIdCommand.mm in Sources */, 0395469F2991DFC5006D42A8 /* json_reader.cpp in Sources */, + 514C79F42B62ED5500DD6D7B /* attribute-storage.cpp in Sources */, B45373D22A9FEB0C00807602 /* buflist.c in Sources */, B45373D72A9FEB0C00807602 /* lws_dll2.c in Sources */, B45373FE2A9FEC4F00807602 /* unix-fds.c in Sources */, @@ -1761,8 +1806,10 @@ 0395469E2991DFC5006D42A8 /* json_writer.cpp in Sources */, 03FB93E02A46200A0048CB35 /* DiscoverCommissionablesCommand.mm in Sources */, B45373EF2A9FEBFE00807602 /* ops-raw-skt.c in Sources */, + 516411332B6BF77700E67C05 /* MTRServerAccessControl.mm in Sources */, 037C3DD52991C2E200B7EEE2 /* CHIPCommandBridge.mm in Sources */, 039546BC2991E1CB006D42A8 /* LogCommands.cpp in Sources */, + 516411312B6BF70300E67C05 /* DataModelHandler.cpp in Sources */, B45373E12A9FEB7F00807602 /* ops-h1.c in Sources */, B45373EB2A9FEBDB00807602 /* ops-listen.c in Sources */, 0382FA2C2992F06C00247BBB /* Commands.cpp in Sources */, @@ -1797,25 +1844,29 @@ 039145E12993102B00257B3E /* main.mm in Sources */, 037C3DD42991BD5200B7EEE2 /* logging.mm in Sources */, B45374012A9FEC4F00807602 /* unix-sockets.c in Sources */, - 51CFDDB22AC5F78F00DA7CA5 /* EmptyDataModelHandler.cpp in Sources */, 03F430A82994112B00166449 /* editline.c in Sources */, B45373E92A9FEBC100807602 /* server.c in Sources */, 037C3DB32991BD5000B7EEE2 /* OpenCommissioningWindowCommand.mm in Sources */, 037C3DAE2991BD4F00B7EEE2 /* PairingCommandBridge.mm in Sources */, + 514C79FD2B62F94C00DD6D7B /* ota-provider.cpp in Sources */, B45373FB2A9FEC4F00807602 /* unix-service.c in Sources */, B45373F22A9FEC1A00807602 /* ops-ws.c in Sources */, 037C3DCA2991BD5100B7EEE2 /* CHIPCommandStorageDelegate.mm in Sources */, 037C3DCF2991BD5200B7EEE2 /* MTRError.mm in Sources */, 037C3DC72991BD5100B7EEE2 /* CHIPToolKeypair.mm in Sources */, B45373E52A9FEBA400807602 /* date.c in Sources */, + 514C79FA2B62F60100DD6D7B /* message.cpp in Sources */, + 514C79F72B62F0B900DD6D7B /* util.cpp in Sources */, B45373DC2A9FEB5300807602 /* sha-1.c in Sources */, B45373D12A9FEB0C00807602 /* alloc.c in Sources */, B45373C62A9FEA9100807602 /* sorted-usec-list.c in Sources */, 037C3DB62991BD5000B7EEE2 /* ModelCommandBridge.mm in Sources */, + 516411322B6BF75700E67C05 /* MTRIMDispatch.mm in Sources */, B45373C22A9FEA9100807602 /* vhost.c in Sources */, 037C3DB42991BD5000B7EEE2 /* DeviceControllerDelegateBridge.mm in Sources */, 039547012992D461006D42A8 /* generic-callback-stubs.cpp in Sources */, B45373D52A9FEB0C00807602 /* logs.c in Sources */, + 514C79F12B62ADDA00DD6D7B /* descriptor.cpp in Sources */, 0382FA312992FD6E00247BBB /* MTRLogging.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1826,20 +1877,26 @@ files = ( 2C8C8FC2253E0C2100797F05 /* MTRPersistentStorageDelegateBridge.mm in Sources */, 99AECC802798A57F00B6355B /* MTRCommissioningParameters.mm in Sources */, + 514C79F92B62F60100DD6D7B /* message.cpp in Sources */, 2CB7163C252E8A7C0026E2BB /* MTRDeviceControllerDelegateBridge.mm in Sources */, 997DED162695343400975E97 /* MTRThreadOperationalDataset.mm in Sources */, 515C1C6F284F9FFB00A48F0C /* MTRFramework.mm in Sources */, 51029DF6293AA6100087AFB0 /* MTROperationalCertificateIssuer.mm in Sources */, 27A53C1827FBC6920053F131 /* MTRAttestationTrustStoreBridge.mm in Sources */, + 93B2CF9A2B56E45C00E4D187 /* MTRClusterNames.mm in Sources */, 998F287126D56940001846C6 /* MTRP256KeypairBridge.mm in Sources */, + 516416012B6B483C00D5CE11 /* MTRIMDispatch.mm in Sources */, 51D0B1412B61B3A4006E3511 /* MTRServerCluster.mm in Sources */, + 514C79FC2B62F94C00DD6D7B /* ota-provider.cpp in Sources */, 5136661428067D550025EDAE /* MTRDeviceControllerFactory.mm in Sources */, 51D0B1392B618CC6006E3511 /* MTRServerAttribute.mm in Sources */, 51B22C2A2740CB47008D5055 /* MTRCommandPayloadsObjc.mm in Sources */, 51F522682AE70734000C4050 /* MTRDeviceTypeMetadata.mm in Sources */, 75B765C32A1D82D30014719B /* MTRAttributeSpecifiedCheck.mm in Sources */, AF5F90FF2878D351005503FA /* MTROTAProviderDelegateBridge.mm in Sources */, + 516415FF2B6B132200D5CE11 /* DataModelHandler.cpp in Sources */, 51E95DFC2A78443C00A434F0 /* MTRSessionResumptionStorageBridge.mm in Sources */, + 514C79ED2B62ADCD00DD6D7B /* ember-compatibility-functions.cpp in Sources */, 7534F12828BFF20300390851 /* MTRDeviceAttestationDelegate.mm in Sources */, B4C8E6B72B3453AD00FCD54D /* MTRDiagnosticLogsDownloader.mm in Sources */, 2C5EEEF7268A85C400CAE3D3 /* MTRDeviceConnectionBridge.mm in Sources */, @@ -1849,10 +1906,12 @@ 3CF134A9289D8D800017A19E /* MTRCSRInfo.mm in Sources */, 991DC0892475F47D00C13860 /* MTRDeviceController.mm in Sources */, B2E0D7B7245B0B5C003C5B48 /* MTRQRCodeSetupPayloadParser.mm in Sources */, + 514C79F32B62ED5500DD6D7B /* attribute-storage.cpp in Sources */, 514304202914CED9004DC7FE /* generic-callback-stubs.cpp in Sources */, 1EDCE546289049A100E41EC9 /* MTROTAHeader.mm in Sources */, 51D0B13D2B61B2F2006E3511 /* MTRDeviceTypeRevision.mm in Sources */, 1EC4CE5D25CC26E900D7304F /* MTRBaseClusters.mm in Sources */, + 514C79F62B62F0B900DD6D7B /* util.cpp in Sources */, 51565CB22A7AD77600469F18 /* MTRDeviceControllerDataStore.mm in Sources */, 51D0B12F2B617800006E3511 /* MTRAccessGrant.mm in Sources */, 88E6C9482B6334ED001A1FE0 /* MTRMetrics.mm in Sources */, @@ -1868,11 +1927,12 @@ 5ACDDD7D27CD16D200EFD68A /* MTRClusterStateCacheContainer.mm in Sources */, 513DDB8A2761F6F900DAA01A /* MTRAttributeTLVValueDecoder.mm in Sources */, 5117DD3829A931AE00FFA1AA /* MTROperationalBrowser.mm in Sources */, + 514C79F02B62ADDA00DD6D7B /* descriptor.cpp in Sources */, 3D843757294AD25A0070D20A /* MTRCertificateInfo.mm in Sources */, 5A7947E427C0129600434CF2 /* MTRDeviceController+XPC.mm in Sources */, 5A6FEC9027B563D900F25F42 /* MTRDeviceControllerOverXPC.mm in Sources */, + 516415FC2B6ACA8300D5CE11 /* MTRServerAccessControl.mm in Sources */, B289D4222639C0D300D4E314 /* MTROnboardingPayloadParser.mm in Sources */, - 51CFDDB12AC5F78F00DA7CA5 /* EmptyDataModelHandler.cpp in Sources */, 3CF134AD289D8E570017A19E /* MTRDeviceAttestationInfo.mm in Sources */, 2C1B027A2641DB4E00780EF1 /* MTROperationalCredentialsDelegate.mm in Sources */, 7560FD1C27FBBD3F005E85B3 /* MTREventTLVValueDecoder.mm in Sources */, @@ -2014,6 +2074,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; STRIP_INSTALLED_PRODUCT = NO; + SYSTEM_HEADER_SEARCH_PATHS = "$(CHIP_ROOT)/src/darwin/Framework/CHIP/"; USER_HEADER_SEARCH_PATHS = ""; WARNING_CFLAGS = ( "-Wformat", @@ -2092,6 +2153,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; + SYSTEM_HEADER_SEARCH_PATHS = "$(CHIP_ROOT)/src/darwin/Framework/CHIP/"; USER_HEADER_SEARCH_PATHS = ""; WARNING_CFLAGS = ( "-Wformat", @@ -2240,9 +2302,6 @@ "$(CHIP_ROOT)/config/ios", "$(CHIP_ROOT)/src", "$(CHIP_ROOT)/src/include", - "$(CHIP_ROOT)/src/lib", - "$(CHIP_ROOT)/src/app", - "$(CHIP_ROOT)/src/app/util", "$(CHIP_ROOT)/zzz_generated/", "$(CHIP_ROOT)/zzz_generated/app-common", "$(CHIP_ROOT)/third_party/nlassert/repo/include", @@ -2411,9 +2470,6 @@ "$(CHIP_ROOT)/config/ios", "$(CHIP_ROOT)/src", "$(CHIP_ROOT)/src/include", - "$(CHIP_ROOT)/src/lib", - "$(CHIP_ROOT)/src/app", - "$(CHIP_ROOT)/src/app/util", "$(CHIP_ROOT)/zzz_generated/", "$(CHIP_ROOT)/zzz_generated/app-common", "$(CHIP_ROOT)/third_party/nlassert/repo/include", diff --git a/src/darwin/Framework/chip_xcode_build_connector.sh b/src/darwin/Framework/chip_xcode_build_connector.sh index 54e3594dfda2a2..3ab0464bb79482 100755 --- a/src/darwin/Framework/chip_xcode_build_connector.sh +++ b/src/darwin/Framework/chip_xcode_build_connector.sh @@ -93,7 +93,7 @@ done declare -a args=( 'default_configs_cosmetic=[]' # suppress colorization 'chip_crypto="boringssl"' - 'chip_build_controller_dynamic_server=true' + 'chip_build_controller_dynamic_server=false' 'chip_build_tools=false' 'chip_build_tests=false' 'chip_enable_wifi=false' diff --git a/src/include/platform/CHIPDeviceEvent.h b/src/include/platform/CHIPDeviceEvent.h index 28e5c22400c0a7..a7656fd6cba7fc 100644 --- a/src/include/platform/CHIPDeviceEvent.h +++ b/src/include/platform/CHIPDeviceEvent.h @@ -147,13 +147,6 @@ enum PublicEventTypes */ kTimeSyncChange, - /** - * SED Interval Change - * - * Signals a change to the sleepy end device interval. - */ - kICDPollingIntervalChange, - /** * CHIPoBLE Connection Established * @@ -524,16 +517,6 @@ struct ChipDeviceEvent final bool updateNocCommandHasBeenInvoked; } FailSafeTimerExpired; - struct - { - bool armed; - } FailSafeState; - - struct - { - bool open; - } CommissioningWindowStatus; - struct { // TODO(cecille): This should just specify wifi or thread since we assume at most 1. diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index 37213302a74be9..94d6c253660491 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -16,7 +16,6 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") import("//build_overrides/nlassert.gni") import("//build_overrides/nlfaultinjection.gni") -import("//build_overrides/nlio.gni") import("${chip_root}/build/chip/buildconfig_header.gni") import("${chip_root}/build/chip/tests.gni") @@ -73,9 +72,20 @@ source_set("inet_config_header") { deps = [ ":inet_buildconfig" ] } +source_set("impl_header") { + sources = [ "InetInterfaceImpl.h" ] + public_configs = [ "${chip_root}/src:includes" ] + public_deps = [ "${chip_root}/src/system:system_config_header" ] +} + static_library("inet") { output_name = "libInetLayer" + # EndpointState header is one of: + # - src/inet/EndPointStateLwIP.h + # - src/inet/EndPointStateNetworkFramework.h + # - src/inet/EndPointStateOpenThread.h + # - src/inet/EndPointStateSockets.h sources = [ "EndPointBasis.h", "EndPointState${chip_system_config_inet}.h", @@ -99,12 +109,12 @@ static_library("inet") { ] public_deps = [ + ":impl_header", ":inet_config_header", "${chip_root}/src/lib/core:types", "${chip_root}/src/lib/support", "${chip_root}/src/platform:platform_config_header", "${chip_root}/src/system", - "${nlio_root}:nlio", ] if (chip_system_config_use_lwip) { @@ -117,6 +127,13 @@ static_library("inet") { } if (chip_inet_config_enable_tcp_endpoint) { + # Possible TCPEndpointImpl files: + # - TCPEndPointImplLwIP.cpp + # - TCPEndPointImplLwIP.h + # - TCPEndPointImplOpenThread.cpp + # - TCPEndPointImplOpenThread.h + # - TCPEndPointImplSockets.cpp + # - TCPEndPointImplSockets.h sources += [ "TCPEndPoint.cpp", "TCPEndPoint.h", @@ -127,6 +144,15 @@ static_library("inet") { } if (chip_inet_config_enable_udp_endpoint) { + # Possible UDPEndpointImpl files: + # - UDPEndPointImplLwIP.cpp + # - UDPEndPointImplLwIP.h + # - UDPEndPointImplNetworkFramework.cpp + # - UDPEndPointImplNetworkFramework.h + # - UDPEndPointImplOpenThread.cpp + # - UDPEndPointImplOpenThread.h + # - UDPEndPointImplSockets.cpp + # - UDPEndPointImplSockets.h sources += [ "BasicPacketFilters.h", "EndpointQueueFilter.h", @@ -136,6 +162,12 @@ static_library("inet") { "UDPEndPointImpl${chip_system_config_inet}.h", "UDPEndPointImpl.h", ] + + if (chip_system_config_inet == "Sockets") { + # TODO: dependency on this one is not clear as it is only ever + # enabled through CMakeLists.txt. Added here for completeness + sources += [ "ZephyrSocket.h" ] + } } if (chip_with_nlfaultinjection) { diff --git a/src/inet/tests/TestInetCommonPosix.cpp b/src/inet/tests/TestInetCommonPosix.cpp index 4ffbc87a6458bc..78126cbf5ff748 100644 --- a/src/inet/tests/TestInetCommonPosix.cpp +++ b/src/inet/tests/TestInetCommonPosix.cpp @@ -65,14 +65,12 @@ #include #if CHIP_TARGET_STYLE_UNIX - -// TapAddrAutoconf and TapInterface are only needed for LwIP on -// sockets simulation in which a host tap/tun interface is used to -// proxy the LwIP stack onto a host native network interface. - -#include "TapAddrAutoconf.h" -#include "TapInterface.h" +// NOTE: this used to be supported, so could theoretically be +// recovered, however the TAP/TUN was never actually used +// and the underlying files were never compiled in CHIP. +#error "Testing of LWIP on unix systems via TAP not supported." #endif // CHIP_TARGET_STYLE_UNIX + #endif // CHIP_SYSTEM_CONFIG_USE_LWIP using namespace chip; @@ -110,14 +108,6 @@ static void ReleaseLwIP(void) #endif // (LWIP_VERSION_MAJOR == 2) && (LWIP_VERSION_MINOR == 0) } -#if CHIP_TARGET_STYLE_UNIX -// TapAddrAutoconf and TapInterface are only needed for LwIP on -// sockets simulation in which a host tap/tun interface is used to -// proxy the LwIP stack onto a host native network interface. -// CollectTapAddresses() is only available on such targets. -static std::vector sTapIFs; -#endif // CHIP_TARGET_STYLE_UNIX - static std::vector sNetIFs; // interface to filter static bool NetworkIsReady(); @@ -196,28 +186,11 @@ static void PrintNetworkState() for (size_t j = 0; j < gNetworkOptions.TapDeviceName.size(); j++) { struct netif * netIF = &(sNetIFs[j]); -#if CHIP_TARGET_STYLE_UNIX - // TapAddrAutoconf and TapInterface are only needed for LwIP on - // sockets simulation in which a host tap/tun interface is used to - // proxy the LwIP stack onto a host native network interface. - // CollectTapAddresses() is only available on such targets. - - TapInterface * tapIF = &(sTapIFs[j]); -#endif // CHIP_TARGET_STYLE_UNIX InterfaceId(netIF).GetInterfaceName(intfName, sizeof(intfName)); printf("LwIP interface ready\n"); printf(" Interface Name: %s\n", intfName); printf(" Tap Device: %s\n", gNetworkOptions.TapDeviceName[j]); -#if CHIP_TARGET_STYLE_UNIX - // TapAddrAutoconf and TapInterface are only needed for LwIP on - // sockets simulation in which a host tap/tun interface is used to - // proxy the LwIP stack onto a host native network interface. - // CollectTapAddresses() is only available on such targets. - - printf(" MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n", tapIF->macAddr[0], tapIF->macAddr[1], tapIF->macAddr[2], - tapIF->macAddr[3], tapIF->macAddr[4], tapIF->macAddr[5]); -#endif // CHIP_TARGET_STYLE_UNIX #if INET_CONFIG_ENABLE_IPV4 printf(" IPv4 Address: %s\n", ipaddr_ntoa(&(netIF->ip_addr))); @@ -253,52 +226,14 @@ void InitNetwork() } } -#if CHIP_TARGET_STYLE_UNIX - // TapAddrAutoconf and TapInterface are only needed for LwIP on - // sockets simulation in which a host tap/tun interface is used to - // proxy the LwIP stack onto a host native network interface. - // CollectTapAddresses() is only available on such targets. - - sTapIFs.clear(); -#endif // CHIP_TARGET_STYLE_UNIX sNetIFs.clear(); for (size_t j = 0; j < gNetworkOptions.TapDeviceName.size(); j++) { -#if CHIP_TARGET_STYLE_UNIX - // TapAddrAutoconf and TapInterface are only needed for LwIP on - // sockets simulation in which a host tap/tun interface is used to - // proxy the LwIP stack onto a host native network interface. - // CollectTapAddresses() is only available on such targets. - - TapInterface tapIF; - sTapIFs.push_back(tapIF); -#endif // CHIP_TARGET_STYLE_UNIX struct netif netIF; sNetIFs.push_back(netIF); } -#if CHIP_TARGET_STYLE_UNIX - - // TapAddrAutoconf and TapInterface are only needed for LwIP on - // sockets simulation in which a host tap/tun interface is used to - // proxy the LwIP stack onto a host native network interface. - // CollectTapAddresses() is only available on such targets. - - err_t lwipErr; - - for (size_t j = 0; j < gNetworkOptions.TapDeviceName.size(); j++) - { - lwipErr = TapInterface_Init(&(sTapIFs[j]), gNetworkOptions.TapDeviceName[j], NULL); - if (lwipErr != ERR_OK) - { - printf("Failed to initialize tap device %s: %s\n", gNetworkOptions.TapDeviceName[j], - ErrorStr(System::MapErrorLwIP(lwipErr))); - exit(EXIT_FAILURE); - } - } -#endif // CHIP_TARGET_STYLE_UNIX - tcpip_init(OnLwIPInitComplete, NULL); // Lock LwIP stack @@ -310,17 +245,6 @@ void InitNetwork() addrsVec.clear(); -#if CHIP_TARGET_STYLE_UNIX - - // TapAddrAutoconf and TapInterface are only needed for LwIP on - // sockets simulation in which a host tap/tun interface is used to - // proxy the LwIP stack onto a host native network interface. - // CollectTapAddresses() is only available on such targets. - if (gNetworkOptions.TapUseSystemConfig) - { - CollectTapAddresses(addrsVec, gNetworkOptions.TapDeviceName[j]); - } -#endif // CHIP_TARGET_STYLE_UNIX #if INET_CONFIG_ENABLE_IPV4 IPAddress ip4Addr = (j < gNetworkOptions.LocalIPv4Addr.size()) ? gNetworkOptions.LocalIPv4Addr[j] : IPAddress::Any; @@ -333,25 +257,6 @@ void InitNetwork() } } -#if CHIP_TARGET_STYLE_UNIX - // TapAddrAutoconf and TapInterface are only needed for LwIP on - // sockets simulation in which a host tap/tun interface is used to - // proxy the LwIP stack onto a host native network interface. - // CollectTapAddresses() is only available on such targets. - - IPAddress ip4Gateway = (j < gNetworkOptions.IPv4GatewayAddr.size()) ? gNetworkOptions.IPv4GatewayAddr[j] : IPAddress::Any; - - { - ip4_addr_t ip4AddrLwIP, ip4NetmaskLwIP, ip4GatewayLwIP; - - ip4AddrLwIP = ip4Addr.ToIPv4(); - IP4_ADDR(&ip4NetmaskLwIP, 255, 255, 255, 0); - ip4GatewayLwIP = ip4Gateway.ToIPv4(); - netif_add(&(sNetIFs[j]), &ip4AddrLwIP, &ip4NetmaskLwIP, &ip4GatewayLwIP, &(sTapIFs[j]), TapInterface_SetupNetif, - tcpip_input); - } -#endif // CHIP_TARGET_STYLE_UNIX - #endif // INET_CONFIG_ENABLE_IPV4 netif_create_ip6_linklocal_address(&(sNetIFs[j]), 1); @@ -484,14 +389,6 @@ void ServiceEvents(uint32_t aSleepTimeMilliseconds) gSystemLayer.HandlePlatformTimer(); } -#if CHIP_TARGET_STYLE_UNIX - // TapAddrAutoconf and TapInterface are only needed for LwIP on - // sockets simulation in which a host tap/tun interface is used to - // proxy the LwIP stack onto a host native network interface. - // CollectTapAddresses() is only available on such targets. - - TapInterface_Select(&(sTapIFs[0]), &(sNetIFs[0]), aSleepTime, gNetworkOptions.TapDeviceName.size()); -#endif // CHIP_TARGET_STYLE_UNIX #endif // CHIP_SYSTEM_CONFIG_USE_LWIP } diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn index 40ba50224d195d..27611376c10069 100644 --- a/src/lib/core/BUILD.gn +++ b/src/lib/core/BUILD.gn @@ -101,9 +101,15 @@ source_set("error") { public_deps = [ ":chip_config_header", "${chip_root}/src/lib/support:attributes", + "${chip_root}/src/lib/support:type-traits", ] } +source_set("encoding") { + sources = [ "CHIPEncoding.h" ] + public_deps = [ "${nlio_root}:nlio" ] +} + source_set("types") { sources = [ "CHIPSafeCasts.h", @@ -125,14 +131,9 @@ static_library("core") { output_name = "libChipCore" sources = [ - # For now cluster enum/bitmap definitions are in zzz-generated. - # We should consider putting them directly in this directory - # instead. - "${chip_root}/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h", "CASEAuthTag.h", "CHIPCallback.h", "CHIPCore.h", - "CHIPEncoding.h", "CHIPKeyIds.cpp", "CHIPKeyIds.h", "CHIPPersistentStorageDelegate.h", @@ -171,11 +172,11 @@ static_library("core") { public_deps = [ ":chip_config_header", ":error", + "${chip_root}/src/app/common:enums", "${chip_root}/src/ble", "${chip_root}/src/inet", "${chip_root}/src/lib/support", "${chip_root}/src/system", - "${nlio_root}:nlio", ] allow_circular_includes_from = [ diff --git a/src/lib/dnssd/BUILD.gn b/src/lib/dnssd/BUILD.gn index 295be7d51a191d..1561a395aa28f9 100644 --- a/src/lib/dnssd/BUILD.gn +++ b/src/lib/dnssd/BUILD.gn @@ -27,7 +27,7 @@ static_library("dnssd") { "${chip_root}/src/crypto", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", - "${chip_root}/src/messaging:messaging_mrp_config", + "${chip_root}/src/messaging:configurations", ] sources = [ @@ -53,6 +53,7 @@ static_library("dnssd") { "ActiveResolveAttempts.cpp", "ActiveResolveAttempts.h", "Advertiser_ImplMinimalMdns.cpp", + "Advertiser_ImplMinimalMdnsAllocator.h", "IncrementalResolve.cpp", "IncrementalResolve.h", "MinimalMdnsServer.cpp", diff --git a/src/lib/dnssd/minimal_mdns/tests/TestAdvertiser.cpp b/src/lib/dnssd/minimal_mdns/tests/TestAdvertiser.cpp index aa6fcf0c04b815..8f3e39c026eb6d 100644 --- a/src/lib/dnssd/minimal_mdns/tests/TestAdvertiser.cpp +++ b/src/lib/dnssd/minimal_mdns/tests/TestAdvertiser.cpp @@ -210,7 +210,7 @@ CommissionAdvertisingParameters commissionableNodeParamsEnhancedAsICDLIT = .SetTcpSupported(chip::Optional(true)) .SetICDOperatingAsLIT(chip::Optional(true)) .SetLocalMRPConfig(Optional::Value(3600000_ms32, 3600000_ms32, 65535_ms16)); -// With ICD Operation as LIT, SII key will not be added to the advertissement +// With ICD Operation as LIT, SII key will not be added to the advertisement QNamePart txtCommissionableNodeParamsEnhancedAsICDLITParts[] = { "D=22", "VP=555+897", "CM=2", "DT=70000", "DN=testy-test", "PI=Pair me", "PH=3", "SAI=3600000", "SAT=65535", "T=1", "ICD=1" }; diff --git a/src/lib/shell/streamer_cc13x2_26x2.cpp b/src/lib/shell/streamer_cc13x2_26x2.cpp deleted file mode 100644 index f6d256409dc492..00000000000000 --- a/src/lib/shell/streamer_cc13x2_26x2.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Source implementation of an input / output stream for cc13x2_26x2 targets - */ - -#include "streamer.h" -#include -#include -#include -#include - -#include "ti_drivers_config.h" - -#include - -namespace chip { -namespace Shell { - -#ifndef SHELL_STREAMER_APP_SPECIFIC - -UART_Handle sStreamUartHandle = NULL; - -#if !MATTER_CC13X2_26X2_PLATFORM_LOG_ENABLED -extern "C" int cc13x2_26x2LogInit(void) -{ - return 0; -} - -extern "C" void cc13x2_26x2VLog(const char * msg, va_list v) -{ - if (NULL != sStreamUartHandle) - { - static char sDebugUartBuffer[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE]; - size_t ret; - - ret = vsnprintf(sDebugUartBuffer, sizeof(sDebugUartBuffer), msg, v); - if (0 < ret) - { - // PuTTY likes \r\n - size_t len = (ret + 2U) < sizeof(sDebugUartBuffer) ? (ret + 2) : sizeof(sDebugUartBuffer); - sDebugUartBuffer[len - 2] = '\r'; - sDebugUartBuffer[len - 1] = '\n'; - - UART_write(sStreamUartHandle, sDebugUartBuffer, len); - } - } -} -#endif // !MATTER_CC13X2_26X2_PLATFORM_LOG_ENABLED - -int streamer_cc13x2_26x2_init(streamer_t * streamer) -{ - UART_Params uartParams; - - UART_init(); - - UART_Params_init(&uartParams); - // Most params can be default because we only send data, we don't receive - uartParams.baudRate = 115200; - // unclear why the UART driver sticks in writing sometimes - uartParams.writeTimeout = 10000; // ticks - // Immediate return from the read function - // uartParams.readTimeout = 0; // ticks - - sStreamUartHandle = UART_open(CONFIG_UART_STREAMER, &uartParams); - return 0; -} - -ssize_t streamer_cc13x2_26x2_read(streamer_t * streamer, char * buf, size_t len) -{ - (void) streamer; - return UART_read(sStreamUartHandle, buf, len); -} - -ssize_t streamer_cc13x2_26x2_write(streamer_t * streamer, const char * buf, size_t len) -{ - (void) streamer; - return UART_write(sStreamUartHandle, buf, len); -} - -static streamer_t streamer_cc13x2_26x2 = { - .init_cb = streamer_cc13x2_26x2_init, - .read_cb = streamer_cc13x2_26x2_read, - .write_cb = streamer_cc13x2_26x2_write, -}; - -streamer_t * streamer_get() -{ - return &streamer_cc13x2_26x2; -} - -#endif // #ifndef SHELL_STREAMER_APP_SPECIFIC - -} // namespace Shell -} // namespace chip diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn index 0ead05ccfc55f1..3e426746ad3d2b 100644 --- a/src/lib/support/BUILD.gn +++ b/src/lib/support/BUILD.gn @@ -16,7 +16,6 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") import("//build_overrides/nlassert.gni") import("//build_overrides/nlfaultinjection.gni") -import("//build_overrides/nlio.gni") import("//build_overrides/nlunit_test.gni") import("//build_overrides/pigweed.gni") @@ -161,6 +160,17 @@ source_set("chip_version_header") { deps = [ ":gen_chip_version" ] } +source_set("testing") { + sources = [ + "TestGroupData.h", + "TestPersistentStorageDelegate.h", + ] +} + +source_set("type-traits") { + sources = [ "TypeTraits.h" ] +} + static_library("support") { output_name = "libSupportLayer" @@ -180,6 +190,8 @@ static_library("support") { "CHIPArgParser.cpp", "CHIPCounter.h", "CHIPMemString.h", + "CommonIterator.h", + "CommonPersistentData.h", "DLLUtil.h", "DefaultStorageKeyAllocator.h", "Defer.h", @@ -187,21 +199,31 @@ static_library("support") { "FibonacciUtils.h", "FixedBufferAllocator.cpp", "FixedBufferAllocator.h", + "Fold.h", + "FunctionTraits.h", "IniEscaping.cpp", "IniEscaping.h", + "IntrusiveList.h", "Iterators.h", + "LambdaBridge.h", "LifetimePersistedCounter.h", "ObjectLifeCycle.h", + "OwnerOf.h", "PersistedCounter.h", + "PersistentData.h", "PersistentStorageAudit.cpp", "PersistentStorageAudit.h", "PersistentStorageMacros.h", "Pool.cpp", "Pool.h", + "PoolWrapper.h", "PrivateHeap.cpp", "PrivateHeap.h", "ReferenceCountedHandle.h", + "SafePointerCast.h", + "SafeString.h", "Scoped.h", + "ScopedBuffer.h", "SerializableIntegerSet.cpp", "SerializableIntegerSet.h", "SetupDiscriminator.h", @@ -253,15 +275,16 @@ static_library("support") { ":safeint", ":span", ":text_only_logging", + ":type-traits", ":verifymacros", ":verifymacros_no_logging", "${chip_root}/src/lib/core:chip_config_header", + "${chip_root}/src/lib/core:encoding", "${chip_root}/src/lib/core:error", "${chip_root}/src/lib/core:types", "${chip_root}/src/platform:platform_config_header", "${chip_root}/src/system:system_config_header", "${nlassert_root}:nlassert", - "${nlio_root}:nlio", ] # These are needed because we include CHIPCore.h, which uses config @@ -336,6 +359,7 @@ static_library("testing_nlunit") { output_dir = "${root_out_dir}/lib" sources = [ + "UnitTestContext.h", "UnitTestExtendedAssertions.h", "UnitTestRegistration.cpp", "UnitTestRegistration.h", diff --git a/src/lib/support/PersistedCounter.h b/src/lib/support/PersistedCounter.h index 8e52b9e6077699..02096a486edcd3 100644 --- a/src/lib/support/PersistedCounter.h +++ b/src/lib/support/PersistedCounter.h @@ -92,13 +92,12 @@ class PersistedCounter : public MonotonicallyIncreasingCounter ReturnErrorOnFailure(ReadStartValue(startValue)); #if CHIP_CONFIG_PERSISTED_COUNTER_DEBUG_LOGGING - // Compiler should optimize these branches. - if (is_same_v) + if constexpr (std::is_same_v) { ChipLogDetail(EventLogging, "PersistedCounter::Init() aEpoch 0x" ChipLogFormatX64 " startValue 0x" ChipLogFormatX64, ChipLogValueX64(aEpoch), ChipLogValueX64(startValue)); } - else if (is_same_v) + else if (std::is_same_v) { ChipLogDetail(EventLogging, "PersistedCounter::Init() aEpoch 0x%" PRIx32 " startValue 0x%" PRIx32, static_cast(aEpoch), static_cast(startValue)); @@ -151,8 +150,7 @@ class PersistedCounter : public MonotonicallyIncreasingCounter { mNextEpoch = aStartValue; #if CHIP_CONFIG_PERSISTED_COUNTER_DEBUG_LOGGING - // Compiler should optimize these branches. - if (is_same_v) + if constexpr (std::is_same_v) { ChipLogDetail(EventLogging, "PersistedCounter::WriteStartValue() aStartValue 0x" ChipLogFormatX64, ChipLogValueX64(aStartValue)); @@ -178,7 +176,7 @@ class PersistedCounter : public MonotonicallyIncreasingCounter */ CHIP_ERROR ReadStartValue(T & aStartValue) { - T valueLE = 0; + T valueLE = GetInitialCounterValue(); uint16_t size = sizeof(valueLE); VerifyOrReturnError(mKey.IsInitialized(), CHIP_ERROR_INCORRECT_STATE); @@ -206,12 +204,28 @@ class PersistedCounter : public MonotonicallyIncreasingCounter aStartValue = Encoding::LittleEndian::HostSwap(valueLE); #if CHIP_CONFIG_PERSISTED_COUNTER_DEBUG_LOGGING - ChipLogDetail(EventLogging, "PersistedCounter::ReadStartValue() aStartValue 0x%x", aStartValue); + if constexpr (std::is_same_v) + { + ChipLogDetail(EventLogging, "PersistedCounter::ReadStartValue() aStartValue 0x" ChipLogFormatX64, + ChipLogValueX64(aStartValue)); + } + else + { + ChipLogDetail(EventLogging, "PersistedCounter::ReadStartValue() aStartValue 0x%" PRIx32, + static_cast(aStartValue)); + } #endif return CHIP_NO_ERROR; } + /** + * @brief Get the Initial Counter Value + * + * By default, persisted counters start off at 0. + */ + virtual inline T GetInitialCounterValue() { return 0; } + PersistentStorageDelegate * mStorage = nullptr; // start value is stored here StorageKeyName mKey; T mEpoch = 0; // epoch modulus value diff --git a/src/lib/support/tests/BUILD.gn b/src/lib/support/tests/BUILD.gn index 7a3b738ef4491a..d0b91feeba7061 100644 --- a/src/lib/support/tests/BUILD.gn +++ b/src/lib/support/tests/BUILD.gn @@ -79,6 +79,7 @@ chip_test_suite_using_nltest("tests") { public_deps = [ "${chip_root}/src/credentials", "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support:testing", "${chip_root}/src/lib/support:testing_nlunit", "${chip_root}/src/lib/support/jsontlv", "${chip_root}/src/platform", diff --git a/src/lwip/BUILD.gn b/src/lwip/BUILD.gn index 2027ab241f6e05..755b3049174f7c 100644 --- a/src/lwip/BUILD.gn +++ b/src/lwip/BUILD.gn @@ -225,6 +225,12 @@ if (current_os == "zephyr" || current_os == "mbed") { [ "${chip_root}/third_party/lwip/repo/lwip/src/apps/mdns/mdns.c" ] } else if (lwip_platform == "silabs") { public_deps += [ "${efr32_sdk_build_root}:efr32_sdk" ] + + sources += [ + "${lwip_platform}/lwipopts-rs911x.h", + "${lwip_platform}/lwipopts-thread.h", + "${lwip_platform}/lwipopts-wf200.h", + ] } else if (lwip_platform == "standalone") { public_deps += [ "${chip_root}/src/lib/support" ] } else if (lwip_platform == "k32w0") { diff --git a/src/lwip/standalone/TapInterface.c b/src/lwip/standalone/TapInterface.c deleted file mode 100644 index 4339a58b8e5e80..00000000000000 --- a/src/lwip/standalone/TapInterface.c +++ /dev/null @@ -1,532 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2018 Google LLC. - * Copyright (c) 2014-2017 Nest Labs, Inc. - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * This file implements a TUN/TAP interface shim for LwIP, used - * when running LwIP on non-LWIP-native platforms such as BSD - * sockets, to interface with host OS network interfaces on such - * platforms and the Internet, accessed via those host OS network - * interfaces. - * - * The APIs in this module used by the setup and intialization - * code of applications are: - * - * 1. TapInterface_Init - * 2. TapInterface_SetupNetif - * 3. TapInterface_Select - * - * and are generally used in the order listed. - * - * .------------------------------------------. - * | | - * .--.------------| Application | - * .--------|--|--------. | . . . | - * | V V | '------+-----------+-------------+---------' - * | | | | | - * | LwIP | .------|-----------|-------------+---------. - * | | | V V V | - * | .----------------. | | .-------. .------------. .---------. | - * | | | | | | Init | | SetupNetif | | Select |--. | - * | | | | | '-------' '------------' '---------' | | - * | | netif | | | | | - * | | | | | .-------------. .-------------. | | - * | | .------------. | | | | Low Level | | Low Level | | | - * | | | linkoutput +-|-+---+----+> Output | | Input <+----| | - * | | '------------' | | | | . | | ^ | | | - * | | | | | '------+------' '------|------' | | - * | | .------------. | | | | | | | - * | | | input <+-+-+---+-----------|----------------|-----------' | - * | | '------------' | | | | | | - * | '----------------' | | .-------|----------------+---------. | - * '--------------------' | | V ' | | - * | | File Descriptor | | - * | | ^ | | - * | '----------------|-----------------' | - * '--------------------|---------------------' - * | - * .------------------|-------------------. - * | | | - * | .--------------|---------------. | - * | | .------------|-------------. | | - * | | | V | | | - * | | | TUN/TAP Shim Interface | | | - * | | | | | | - * | | '--------------------------' | | - * | | | | - * | | TUN/TAP Driver | | - * | | | | - * | '------------------------------' | - * | | - * | Host OS | - * | | - * '--------------------------------------' - * - * This file was originally adapted from 'contrib/ports/unix/port/ - * netif/tapif.c' in the LwIP distribution. - * - */ - -/*-----------------------------------------------------------------------------------*/ -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "TapInterface.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(linux) -#include -#include -#include -#define DEVTAP "/dev/net/tun" - -#elif defined(openbsd) -#define DEVTAP "/dev/tun0" - -#else /* freebsd, cygwin? */ -#include -#define DEVTAP "/dev/tap0" -#endif - -#include -#include -#include -#include -#include - -/* Global Variables */ - -static const size_t kMacLength = sizeof(((TapInterface *) (0))->macAddr); - -/** - * This is the LwIP TUN/TAP shim interface low level output method. - * - * When the native LwIP stack has output for its native interface, \c - * netif, associated with the LwIP TUN/TAP shim interface, LwIP - * invokes this method to drive the specified buffer to the shim - * interface. - * - * @param[in] netif A pointer to the LwIP native interface - * associated with the TUN/TAP shim interface - * onto which the output should be driven. - * - * @param[in] buf A pointer to the packet buffer containing the - * output to drive onto the shim interface. - * - * @retval #ERR_OK on successfully driving the buffer onto the - * shim interface. - * - * @retval #ERR_MEM if an encapsulation buffer cannot be allocated. - * - * @retval #ERR_BUF if the allocated encapsulation buffer is not big - * enough to encapsulate the output data. - * - * @retval #ERR_IF if the output data cannot be driven onto the shim - * interface. - * - * @sa #TapInterface_SetupNetif - * - */ -static err_t TapInterface_low_level_output(struct netif * netif, struct pbuf * buf) -{ - const TapInterface * tapif = (const TapInterface *) (netif->state); - err_t retval = ERR_OK; - struct pbuf * outBuf; - int written; - - if (buf->tot_len > buf->len) - { - // Allocate a buffer from the buffer pool. Fail if none available. - outBuf = pbuf_alloc(PBUF_RAW, buf->tot_len + PBUF_LINK_ENCAPSULATION_HLEN, PBUF_POOL); - if (outBuf == NULL) - { - fprintf(stderr, "TapInterface: Failed to allocate buffer\n"); - retval = ERR_MEM; - goto done; - } - - // Fail if the buffer is not big enough to hold the output data. - if (outBuf->tot_len != outBuf->len) - { - fprintf(stderr, "TapInterface: Output data bigger than single PBUF\n"); - retval = ERR_BUF; - goto done; - } - - // Reserve the space needed by WICED for its buffer management. - pbuf_header(outBuf, -PBUF_LINK_ENCAPSULATION_HLEN); - - // Copy output data to the new buffer. - retval = pbuf_copy(outBuf, buf); - if (retval != ERR_OK) - goto done; - } - - // Otherwise send using the supplied buffer. - else - outBuf = buf; - - written = write(tapif->fd, outBuf->payload, outBuf->tot_len); - if (written == -1) - { - snmp_inc_ifoutdiscards(netif); - perror("TapInterface: write failed"); - retval = ERR_IF; - } - else - { - snmp_add_ifoutoctets(netif, written); - } - -done: - if (outBuf != NULL && outBuf != buf) - pbuf_free(outBuf); - - return retval; -} - -/** - * This is the LwIP TUN/TAP shim interface low level input method. - * - * When input has been identified as pending on the LwIP TUN/TAP shim - * interface, this API allocates a buffer and reads the packet from - * the underlying host OS into the buffer and returns it. - * - * @param[in] tapif A pointer to the LwIP TUN/TAP shim interface - * from which to read pending input. - * - * @param[in] netif A pointer to the LwIP native interface - * associated with the TUN/TAP shim interface. - * - * @returns A pointer to the buffer containing the read input on - * success; otherwise, NULL on error. - * - * @sa #TapInterface_Select - * - */ -static struct pbuf * TapInterface_low_level_input(TapInterface * tapif, struct netif * netif) -{ - struct pbuf *p, *q; - u16_t len; - char buf[2048]; - char * bufptr; - - /* Obtain the size of the packet and put it into the "len" - variable. */ - len = read(tapif->fd, buf, sizeof(buf)); - snmp_add_ifinoctets(netif, len); - - /* We allocate a pbuf chain of pbufs from the pool. */ - p = pbuf_alloc(PBUF_LINK, len, PBUF_POOL); - - if (p != NULL) - { - /* We iterate over the pbuf chain until we have read the entire - packet into the pbuf. */ - bufptr = &buf[0]; - for (q = p; q != NULL; q = q->next) - { - /* Read enough bytes to fill this pbuf in the chain. The - available data in the pbuf is given by the q->len - variable. */ - /* read data into(q->payload, q->len); */ - memcpy(q->payload, bufptr, q->len); - bufptr += q->len; - } - /* acknowledge that packet has been read(); */ - } - else - { - /* drop packet(); */ - snmp_inc_ifindiscards(netif); - printf("Could not allocate pbufs\n"); - } - - return p; -} - -/** - * LwIP netif_add setup callback function for LwIP TUN/TAP shim - * interfaces. - * - * The interface mimics / effects an Ethernet-like interface and, - * consequently, reuses and leverages existing LwIP low-level APIs - * for such interfaces. - * - * This interface should / will be called by LwIP's netif_add - * function for a LwIP TUN/TAP shim interface. \c #TapInterface_Init - * should have been called prior to invoking netif_add with this - * callback. - * - * @param[in,out] netif A pointer to the LwIP netif associated with the - * TUN/TAP shim interface. - * - * @retval #ERR_OK on successfully setting up the TUN/TAP interface. - * - * @sa #TapInterface_Init - * @sa #TapInterface_Select - * - */ -err_t TapInterface_SetupNetif(struct netif * netif) -{ - const TapInterface * tapif = (const TapInterface *) (netif->state); - - /* As far as LwIP is concerned, the network interface is an - * Ethernet-like interface, so set it up accordingly, reusing - * existing LwIP APIs for such interfaces where possible. - */ - - netif->name[0] = tapif->interfaceName[0]; - netif->name[1] = tapif->interfaceName[1]; - netif->output = etharp_output; -#if LWIP_IPV6 - netif->output_ip6 = ethip6_output; -#endif /* LWIP_IPV6 */ - netif->linkoutput = TapInterface_low_level_output; - netif->mtu = 1500; - - netif->flags |= (NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP); -#if LWIP_IPV4 - netif->flags |= (NETIF_FLAG_IGMP); -#endif -#if LWIP_IPV6 - netif->flags |= (NETIF_FLAG_MLD6); -#endif - - netif->hwaddr_len = kMacLength; - - memcpy(netif->hwaddr, tapif->macAddr, kMacLength); - - return ERR_OK; -} - -/** - * Establish an LwIP TUN/TAP interface on the underlying host OS with - * the specified name. - * - * This interface should be invoked before either \c #TapInterface_SetupNetif - * or \c #TapInterface_Select are invoked. - * - * @param[out] tapif A pointer to storage for the established - * TUN/TAP interface details. - * - * @param[in] interfaceName A pointer to a NULL-terminated C string - * containing the name of the TUN/TAP interface. - * - * @param[in] macAddr An optional pointer to the MAC address to be - * used for the TUN/TAP interface. - * - * @retval #ERR_OK on successfully establishing the TUN/TAP - * interface. - * - * @retval #ERR_ARG if \c tapif is NULL or if \c interfaceName is - * too long. - * - * @retval #ERR_IF if the OS-specific TUN/TAP driver cannot be - * opened or if the requested TUN/TAP device - * cannot be created. - * - * @sa #TapInterface_SetupNetif - * @sa #TapInterface_Select - * - */ -err_t TapInterface_Init(TapInterface * tapif, const char * interfaceName, u8_t * macAddr) -{ -#if defined(linux) - struct ifreq ifr; -#endif - - /* The TUN/TAP interface storage pointer is required; error out if - * it hasn't been provided. - */ - - if (tapif == NULL) - return ERR_ARG; - - /* Set the TUN/TAP interface storage to initial defaults. - */ - - memset(tapif, 0, sizeof(*tapif)); - tapif->fd = -1; - - /* Intialize the TUN/TAP interface name and MAC address. If the - * optional MAC address was not provided, use the current process - * identifier as a MAC address. - */ - - tapif->interfaceName = interfaceName; - - if (macAddr != NULL) - { - memcpy(tapif->macAddr, macAddr, kMacLength); - } - else - { - const u32_t pid = htonl((u32_t) getpid()); - memset(tapif->macAddr, 0, kMacLength); - memcpy(tapif->macAddr + 2, &pid, sizeof(pid)); - } - - /* Attempt to open the OS-specific TUN/TAP driver control interface. - */ - - tapif->fd = open(DEVTAP, O_RDWR); - if (tapif->fd == -1) - { - perror("TapInterface: unable to open " DEVTAP); - return ERR_IF; - } - -#if defined(linux) - /* On Linux, prepare and issue the TUNSETIFF ioctl to establish a - * TAP interface (IFF_TAP) with the previously-specified name and - * no packet information (IFF_NO_PI). - */ - - memset(&ifr, 0, sizeof(ifr)); - ifr.ifr_flags = (IFF_TAP | IFF_NO_PI); - - if (strlen(tapif->interfaceName) >= sizeof(ifr.ifr_name)) - { - perror("TapInterface: invalid device name"); - return ERR_ARG; - } - - strcpy(ifr.ifr_name, tapif->interfaceName); - - if (ioctl(tapif->fd, TUNSETIFF, (void *) &ifr) < 0) - { - perror("TapInterface: ioctl(TUNSETIFF) failed"); - return ERR_IF; - } - -#else -#warning "The LwIP TAP/TUN interface may not be fully-supported on your platform." -#endif /* defined(linux) */ - - return ERR_OK; -} - -/** - * Check the LwIP TUN/TAP shim interface to see if any input / read - * activity is pending and, if there is, process it. - * - * @param[in] tapif An array of LwIP TUN/TAP shim interfaces - * to check and, if necessary, to process the - * input for. - * - * @param[in] netif An array of the LwIP native interfaces - * associated with the TUN/TAP shim interface. - * - * @param[in] sleepTime The interval that the call should block for - * waiting for input. - * - * @param[in] numIntfs The number of elements in the tapif and netif arrays. - * - * @retval >= 0 on a successful check and/or processing of pending input. - * - * @retval -EINVAL if either \c tapif or \c netif are NULL. - * - * @sa #TapInterface_Init - * @sa #TapInterface_SetupNetif - * - */ -int TapInterface_Select(TapInterface * tapif, struct netif * netif, struct timeval sleepTime, size_t numIntfs) -{ - fd_set readfds; - int ret; - size_t j; - - if ((tapif == NULL) || (netif == NULL) || (numIntfs == 0)) - { - return -EINVAL; - } - - FD_ZERO(&readfds); - - for (j = 0; j < numIntfs; j++) - { - FD_SET(tapif[j].fd, &readfds); - } - - ret = select(tapif[numIntfs - 1].fd + 1, &readfds, NULL, NULL, &sleepTime); - if (ret > 0) - { - for (j = 0; j < numIntfs; j++) - { - if (!FD_ISSET(tapif[j].fd, &readfds)) - continue; - - struct pbuf * p = TapInterface_low_level_input(&(tapif[j]), &(netif[j])); - if (p != NULL) - { -#if LINK_STATS - lwip_stats.link.recv++; -#endif /* LINK_STATS */ - - netif[j].input(p, &(netif[j])); - } - } - } - - return ret; -} diff --git a/src/lwip/standalone/TapInterface.h b/src/lwip/standalone/TapInterface.h deleted file mode 100644 index 67304e7b1ee5c5..00000000000000 --- a/src/lwip/standalone/TapInterface.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2014-2017 Nest Labs, Inc. - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * 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. - */ - -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __MINTAPIF_H__ -#define __MINTAPIF_H__ - -#include "lwip/netif.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct TapInterface -{ - const char * interfaceName; - u8_t macAddr[6]; - int fd; -} TapInterface; - -err_t TapInterface_Init(TapInterface * tapif, const char * interfaceName, u8_t * macAddr); -err_t TapInterface_SetupNetif(struct netif * netif); -int TapInterface_Select(TapInterface * tapif, struct netif * netif, struct timeval sleepTime, size_t numIntfs); - -#ifdef __cplusplus -} -#endif - -#endif /* __MINTAPIF_H__ */ diff --git a/src/messaging/BUILD.gn b/src/messaging/BUILD.gn index 7d402e78ee2306..a170d625111a06 100644 --- a/src/messaging/BUILD.gn +++ b/src/messaging/BUILD.gn @@ -33,10 +33,16 @@ if (chip_config_resolve_peer_on_first_transmit_failure != "") { defines += [ "CHIP_CONFIG_RESOLVE_PEER_ON_FIRST_TRANSMIT_FAILURE=${chip_config_resolve_peer_on_first_transmit_failure}" ] } -source_set("messaging_mrp_config") { - sources = [ "ReliableMessageProtocolConfig.h" ] +source_set("configurations") { + sources = [ + "ReliableMessageProtocolConfig.h", + "SessionParameters.h", + ] - public_deps = [ "${chip_root}/src/system" ] + public_deps = [ + "${chip_root}/src/lib/core", + "${chip_root}/src/system", + ] } static_library("messaging") { @@ -45,6 +51,7 @@ static_library("messaging") { sources = [ "ApplicationExchangeDispatch.cpp", "ApplicationExchangeDispatch.h", + "EphemeralExchangeDispatch.h", "ErrorCategory.cpp", "ErrorCategory.h", "ExchangeContext.cpp", @@ -66,7 +73,7 @@ static_library("messaging") { cflags = [ "-Wconversion" ] public_deps = [ - ":messaging_mrp_config", + ":configurations", "${chip_root}/src/app/icd/server:icd-server-config", "${chip_root}/src/crypto", "${chip_root}/src/inet", diff --git a/src/messaging/ReliableMessageProtocolConfig.cpp b/src/messaging/ReliableMessageProtocolConfig.cpp index 67e199779c3bcd..86c95b1ff07346 100644 --- a/src/messaging/ReliableMessageProtocolConfig.cpp +++ b/src/messaging/ReliableMessageProtocolConfig.cpp @@ -76,7 +76,7 @@ Optional GetLocalMRPConfig() // which the device can be at sleep and not be able to receive any messages). config.mIdleRetransTimeout += ICDConfigurationData::GetInstance().GetSlowPollingInterval(); config.mActiveRetransTimeout += ICDConfigurationData::GetInstance().GetFastPollingInterval(); - config.mActiveThresholdTime = System::Clock::Milliseconds16(ICDConfigurationData::GetInstance().GetActiveModeThresholdMs()); + config.mActiveThresholdTime = ICDConfigurationData::GetInstance().GetActiveModeThreshold(); #endif #if CONFIG_BUILD_FOR_HOST_UNIT_TEST diff --git a/src/protocols/secure_channel/SessionParameters.h b/src/messaging/SessionParameters.h similarity index 100% rename from src/protocols/secure_channel/SessionParameters.h rename to src/messaging/SessionParameters.h diff --git a/src/messaging/tests/BUILD.gn b/src/messaging/tests/BUILD.gn index d2d3ebbd8bafb9..b6f1dcb02c5ce7 100644 --- a/src/messaging/tests/BUILD.gn +++ b/src/messaging/tests/BUILD.gn @@ -14,7 +14,6 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") -import("//build_overrides/nlio.gni") import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip/chip_test_suite.gni") @@ -33,11 +32,11 @@ static_library("helpers") { deps = [ "${chip_root}/src/credentials/tests:cert_test_vectors", + "${chip_root}/src/lib/support:testing", "${chip_root}/src/messaging", "${chip_root}/src/protocols", "${chip_root}/src/transport", "${chip_root}/src/transport/tests:helpers", - "${nlio_root}:nlio", ] } @@ -78,7 +77,6 @@ chip_test_suite_using_nltest("tests") { "${chip_root}/src/protocols", "${chip_root}/src/transport", "${chip_root}/src/transport/raw/tests:helpers", - "${nlio_root}:nlio", "${nlunit_test_root}:nlunit-test", ] diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 1a86faba89922c..c6b1aae23ee40f 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -14,7 +14,6 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") -import("//build_overrides/nlio.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/linux/pkg_config.gni") diff --git a/src/platform/Darwin/CHIPDevicePlatformConfig.h b/src/platform/Darwin/CHIPDevicePlatformConfig.h index 8cb779756bf95b..15fdaa476e3645 100644 --- a/src/platform/Darwin/CHIPDevicePlatformConfig.h +++ b/src/platform/Darwin/CHIPDevicePlatformConfig.h @@ -58,9 +58,8 @@ #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1 #endif // CHIP_DEVICE_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS -// Reserve a single dynamic endpoint that we can use to host things like OTA -// Provider server. +// Default to as many dynamic endpoints as we can manage. #if !defined(CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT) || CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT == 0 #undef CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT -#define CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT 1 +#define CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT 254 #endif // CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT diff --git a/src/platform/ESP32/BUILD.gn b/src/platform/ESP32/BUILD.gn index c5b59add8e9e34..768f6a25ba0e64 100644 --- a/src/platform/ESP32/BUILD.gn +++ b/src/platform/ESP32/BUILD.gn @@ -128,6 +128,9 @@ static_library("ESP32") { "WiFiDnssdImpl.h", ] } + if (chip_mdns == "minimal") { + sources += [ "ESP32EndpointQueueFilter.h" ] + } if (chip_enable_route_hook) { sources += [ "route_hook/ESP32RouteHook.c", diff --git a/src/platform/ESP32/CHIPPlatformConfig.h b/src/platform/ESP32/CHIPPlatformConfig.h index 245f908d434adf..c2aa892ac04b13 100644 --- a/src/platform/ESP32/CHIPPlatformConfig.h +++ b/src/platform/ESP32/CHIPPlatformConfig.h @@ -95,3 +95,7 @@ #endif // CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC #endif // CONFIG_ENABLE_ICD_SERVER + +#ifdef CONFIG_CHIP_ENABLE_BDX_LOG_TRANSFER +#define CHIP_CONFIG_ENABLE_BDX_LOG_TRANSFER 1 +#endif // CONFIG_CHIP_ENABLE_BDX_LOG_TRANSFER diff --git a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp index e52319b55bb365..8fb52e7bb71629 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -1107,6 +1108,35 @@ void ConnectivityManagerImpl::OnStationIPv6AddressAvailable(const ip_event_got_i event.Type = DeviceEventType::kInterfaceIpAddressChanged; event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV6_Assigned; PlatformMgr().PostEventOrDie(&event); + +#if CONFIG_ENABLE_ENDPOINT_QUEUE_FILTER + uint8_t station_mac[6]; + if (esp_wifi_get_mac(WIFI_IF_STA, station_mac) == ESP_OK) + { + static chip::Inet::ESP32EndpointQueueFilter sEndpointQueueFilter; + char station_mac_str[12]; + for (size_t i = 0; i < 6; ++i) + { + uint8_t dig1 = (station_mac[i] & 0xF0) >> 4; + uint8_t dig2 = station_mac[i] & 0x0F; + station_mac_str[2 * i] = dig1 > 9 ? ('A' + dig1 - 0xA) : ('0' + dig1); + station_mac_str[2 * i + 1] = dig2 > 9 ? ('A' + dig2 - 0xA) : ('0' + dig2); + } + if (sEndpointQueueFilter.SetMdnsHostName(chip::CharSpan(station_mac_str)) == CHIP_NO_ERROR) + { + chip::Inet::UDPEndPointImpl::SetQueueFilter(&sEndpointQueueFilter); + } + else + { + ChipLogError(DeviceLayer, "Failed to set mDNS hostname for endpoint queue filter"); + } + } + else + { + ChipLogError(DeviceLayer, "Failed to get the MAC address of station netif"); + } +#endif // CONFIG_ENABLE_ENDPOINT_QUEUE_FILTER + #if CONFIG_ENABLE_ROUTE_HOOK esp_route_hook_init(esp_netif_get_handle_from_ifkey(ESP32Utils::kDefaultWiFiStationNetifKey)); #endif diff --git a/src/platform/ESP32/ESP32EndpointQueueFilter.h b/src/platform/ESP32/ESP32EndpointQueueFilter.h new file mode 100644 index 00000000000000..e7d154dcf458af --- /dev/null +++ b/src/platform/ESP32/ESP32EndpointQueueFilter.h @@ -0,0 +1,129 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include + +namespace chip { +namespace Inet { + +class ESP32EndpointQueueFilter : public EndpointQueueFilter +{ +public: + CHIP_ERROR SetMdnsHostName(const chip::CharSpan & hostName) + { + ReturnErrorCodeIf(hostName.size() != sizeof(mHostNameBuffer), CHIP_ERROR_INVALID_ARGUMENT); + ReturnErrorCodeIf(!IsValidMdnsHostName(hostName), CHIP_ERROR_INVALID_ARGUMENT); + memcpy(mHostNameBuffer, hostName.data(), hostName.size()); + return CHIP_NO_ERROR; + } + + FilterOutcome FilterBeforeEnqueue(const void * endpoint, const IPPacketInfo & pktInfo, + const chip::System::PacketBufferHandle & pktPayload) override + { + if (!IsMdnsBroadcastPacket(pktInfo)) + { + return FilterOutcome::kAllowPacket; + } + // Drop the mDNS packets which don't contain 'matter' or ''. + const uint8_t matterBytes[] = { 'm', 'a', 't', 't', 'e', 'r' }; + if (PayloadContains(pktPayload, ByteSpan(matterBytes)) || PayloadContainsHostNameCaseInsensitive(pktPayload)) + { + return FilterOutcome::kAllowPacket; + } + return FilterOutcome::kDropPacket; + } + + FilterOutcome FilterAfterDequeue(const void * endpoint, const IPPacketInfo & pktInfo, + const chip::System::PacketBufferHandle & pktPayload) override + { + return FilterOutcome::kAllowPacket; + } + +private: + // TODO: Add unit tests for these static functions + static bool IsMdnsBroadcastPacket(const IPPacketInfo & pktInfo) + { + if (pktInfo.DestPort == 5353) + { +#if INET_CONFIG_ENABLE_IPV4 + ip_addr_t mdnsIPv4BroadcastAddr = IPADDR4_INIT_BYTES(224, 0, 0, 251); + if (pktInfo.DestAddress == chip::Inet::IPAddress(mdnsIPv4BroadcastAddr)) + { + return true; + } +#endif + ip_addr_t mdnsIPv6BroadcastAddr = IPADDR6_INIT_HOST(0xFF020000, 0, 0, 0xFB); + if (pktInfo.DestAddress == chip::Inet::IPAddress(mdnsIPv6BroadcastAddr)) + { + return true; + } + } + return false; + } + + static bool PayloadContains(const chip::System::PacketBufferHandle & payload, const chip::ByteSpan & byteSpan) + { + if (payload->HasChainedBuffer() || payload->TotalLength() < byteSpan.size()) + { + return false; + } + for (size_t i = 0; i <= payload->TotalLength() - byteSpan.size(); ++i) + { + if (memcmp(payload->Start() + i, byteSpan.data(), byteSpan.size()) == 0) + { + return true; + } + } + return false; + } + + bool PayloadContainsHostNameCaseInsensitive(const chip::System::PacketBufferHandle & payload) + { + uint8_t hostNameLowerCase[12]; + memcpy(hostNameLowerCase, mHostNameBuffer, sizeof(mHostNameBuffer)); + for (size_t i = 0; i < sizeof(hostNameLowerCase); ++i) + { + if (hostNameLowerCase[i] <= 'F' && hostNameLowerCase[i] >= 'A') + { + hostNameLowerCase[i] = 'a' + hostNameLowerCase[i] - 'A'; + } + } + return PayloadContains(payload, ByteSpan(mHostNameBuffer)) || PayloadContains(payload, ByteSpan(hostNameLowerCase)); + } + + static bool IsValidMdnsHostName(const chip::CharSpan & hostName) + { + for (size_t i = 0; i < hostName.size(); ++i) + { + char ch_data = *(hostName.data() + i); + if (!((ch_data >= '0' && ch_data <= '9') || (ch_data >= 'A' && ch_data <= 'F'))) + { + return false; + } + } + return true; + } + + uint8_t mHostNameBuffer[12] = { 0 }; +}; + +} // namespace Inet +} // namespace chip diff --git a/src/platform/GLibTypeDeleter.h b/src/platform/GLibTypeDeleter.h index 93ff40f61c111d..e6d9bfd0d2c1ed 100644 --- a/src/platform/GLibTypeDeleter.h +++ b/src/platform/GLibTypeDeleter.h @@ -108,6 +108,12 @@ struct GAutoPtrDeleter using deleter = GBytesDeleter; }; +template <> +struct GAutoPtrDeleter +{ + using deleter = GObjectDeleter; +}; + template <> struct GAutoPtrDeleter { diff --git a/src/platform/Infineon/PSOC6/BLEManagerImpl.cpp b/src/platform/Infineon/PSOC6/BLEManagerImpl.cpp index 9d380a7124ae8a..917cdc267e4d24 100644 --- a/src/platform/Infineon/PSOC6/BLEManagerImpl.cpp +++ b/src/platform/Infineon/PSOC6/BLEManagerImpl.cpp @@ -426,7 +426,7 @@ void BLEManagerImpl::DriveBLEState(void) ChipLogProgress(DeviceLayer, "CHIPoBLE stop advertising"); wiced_bt_start_advertisements(BTM_BLE_ADVERT_OFF, BLE_ADDR_PUBLIC, NULL); - /* Delete the heap allocated during BLE Advertisment Stop */ + /* Delete the heap allocated during BLE Advertisement Stop */ if (p_heap) { wiced_bt_delete_heap(p_heap); diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index 241c13e36670ef..a98a52de9721e1 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -54,6 +54,18 @@ namespace { static constexpr System::Clock::Timeout kNewConnectionScanTimeout = System::Clock::Seconds16(20); static constexpr System::Clock::Timeout kConnectTimeout = System::Clock::Seconds16(20); +static constexpr System::Clock::Timeout kFastAdvertiseTimeout = + System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_BLE_ADVERTISING_INTERVAL_CHANGE_TIME); +#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +// The CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS specifies the transition time +// starting from advertisement commencement. Since the extended advertisement timer is started after +// the fast-to-slow transition, we have to subtract the time spent in fast advertising. +static constexpr System::Clock::Timeout kSlowAdvertiseTimeout = System::Clock::Milliseconds32( + CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS - CHIP_DEVICE_CONFIG_BLE_ADVERTISING_INTERVAL_CHANGE_TIME); +static_assert(CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS >= + CHIP_DEVICE_CONFIG_BLE_ADVERTISING_INTERVAL_CHANGE_TIME, + "The extended advertising interval change time must be greater than the fast advertising interval change time"); +#endif const ChipBleUUID ChipUUID_CHIPoBLEChar_RX = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0x3D, 0x45, 0x59, 0x95, 0x9F, 0x4F, 0x9C, 0x42, 0x9F, 0x9D, 0x11 } }; @@ -91,7 +103,7 @@ CHIP_ERROR BLEManagerImpl::_Init() OnChipBleConnectReceived = HandleIncomingBleConnection; - PlatformMgr().ScheduleWork(DriveBLEState, 0); + DeviceLayer::SystemLayer().ScheduleLambda([this] { DriveBLEState(); }); exit: return err; @@ -119,7 +131,7 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) mFlags.Set(Flags::kAdvertisingEnabled, val); } - PlatformMgr().ScheduleWork(DriveBLEState, 0); + DeviceLayer::SystemLayer().ScheduleLambda([this] { DriveBLEState(); }); return err; } @@ -138,7 +150,7 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingMode(BLEAdvertisingMode mode) return CHIP_ERROR_INVALID_ARGUMENT; } mFlags.Set(Flags::kAdvertisingRefreshNeeded); - PlatformMgr().ScheduleWork(DriveBLEState, 0); + DeviceLayer::SystemLayer().ScheduleLambda([this] { DriveBLEState(); }); return CHIP_NO_ERROR; } @@ -186,14 +198,9 @@ uint16_t BLEManagerImpl::_NumConnections() CHIP_ERROR BLEManagerImpl::ConfigureBle(uint32_t aAdapterId, bool aIsCentral) { - - mAdapterId = aAdapterId; - mIsCentral = aIsCentral; - - mBLEAdvType = ChipAdvType::BLUEZ_ADV_TYPE_UNDIRECTED_CONNECTABLE_SCANNABLE; - mBLEAdvDurationMs = 2; - mpBLEAdvUUID = "0xFFF6"; - + mAdapterId = aAdapterId; + mIsCentral = aIsCentral; + mpBLEAdvUUID = "0xFFF6"; return CHIP_NO_ERROR; } @@ -278,17 +285,14 @@ void BLEManagerImpl::HandlePlatformSpecificBLEEvent(const ChipDeviceEvent * apEv case DeviceEventType::kPlatformLinuxBLEPeripheralAdvStartComplete: VerifyOrExit(apEvent->Platform.BLEPeripheralAdvStartComplete.mIsSuccess, err = CHIP_ERROR_INCORRECT_STATE); sInstance.mFlags.Clear(Flags::kControlOpInProgress).Clear(Flags::kAdvertisingRefreshNeeded); - - if (!sInstance.mFlags.Has(Flags::kAdvertising)) - { - sInstance.mFlags.Set(Flags::kAdvertising); - } - + // Start a timer to make sure that the fast advertising is stopped after specified timeout. + SuccessOrExit(err = DeviceLayer::SystemLayer().StartTimer(kFastAdvertiseTimeout, HandleAdvertisingTimer, this)); + sInstance.mFlags.Set(Flags::kAdvertising); break; case DeviceEventType::kPlatformLinuxBLEPeripheralAdvStopComplete: VerifyOrExit(apEvent->Platform.BLEPeripheralAdvStopComplete.mIsSuccess, err = CHIP_ERROR_INCORRECT_STATE); - sInstance.mFlags.Clear(Flags::kControlOpInProgress).Clear(Flags::kAdvertisingRefreshNeeded); + DeviceLayer::SystemLayer().CancelTimer(HandleAdvertisingTimer, this); // Transition to the not Advertising state... if (sInstance.mFlags.Has(Flags::kAdvertising)) @@ -311,6 +315,7 @@ void BLEManagerImpl::HandlePlatformSpecificBLEEvent(const ChipDeviceEvent * apEv { ChipLogError(DeviceLayer, "Disabling CHIPoBLE service due to error: %s", ErrorStr(err)); mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Disabled; + DeviceLayer::SystemLayer().CancelTimer(HandleAdvertisingTimer, this); sInstance.mFlags.Clear(Flags::kControlOpInProgress); } @@ -571,7 +576,7 @@ void BLEManagerImpl::DriveBLEState() // Initializes the Bluez BLE layer if needed. if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !mFlags.Has(Flags::kBluezBLELayerInitialized)) { - SuccessOrExit(err = mEndpoint.Init(mAdapterId, mIsCentral, nullptr)); + SuccessOrExit(err = mEndpoint.Init(mIsCentral, mAdapterId)); mFlags.Set(Flags::kBluezBLELayerInitialized); } @@ -595,15 +600,29 @@ void BLEManagerImpl::DriveBLEState() // Configure advertising data if it hasn't been done yet. if (!mFlags.Has(Flags::kAdvertisingConfigured)) { - SuccessOrExit(err = mBLEAdvertisement.Init(mEndpoint, mBLEAdvType, mpBLEAdvUUID, mBLEAdvDurationMs, mDeviceName)); + SuccessOrExit(err = mBLEAdvertisement.Init(mEndpoint, mpBLEAdvUUID, mDeviceName)); mFlags.Set(Flags::kAdvertisingConfigured); } - // Start advertising. This is an asynchronous step. BLE manager will be notified of - // advertising start completion via a call to NotifyBLEPeripheralAdvStartComplete. - SuccessOrExit(err = mBLEAdvertisement.Start()); - mFlags.Set(Flags::kControlOpInProgress); - ExitNow(); + // Setup service data for advertising. + auto serviceDataFlags = BluezAdvertisement::kServiceDataNone; +#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING + if (mFlags.Has(Flags::kExtAdvertisingEnabled)) + serviceDataFlags |= BluezAdvertisement::kServiceDataExtendedAnnouncement; +#endif + SuccessOrExit(err = mBLEAdvertisement.SetupServiceData(serviceDataFlags)); + + // Set or update the advertising intervals. + SuccessOrExit(err = mBLEAdvertisement.SetIntervals(GetAdvertisingIntervals())); + + if (!mFlags.Has(Flags::kAdvertising)) + { + // Start advertising. This is an asynchronous step. BLE manager will be notified of + // advertising start completion via a call to NotifyBLEPeripheralAdvStartComplete. + SuccessOrExit(err = mBLEAdvertisement.Start()); + mFlags.Set(Flags::kControlOpInProgress); + ExitNow(); + } } } @@ -627,11 +646,6 @@ void BLEManagerImpl::DriveBLEState() } } -void BLEManagerImpl::DriveBLEState(intptr_t arg) -{ - sInstance.DriveBLEState(); -} - void BLEManagerImpl::NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId) { ChipLogProgress(Ble, "Got notification regarding chip connection closure"); @@ -641,6 +655,39 @@ void BLEManagerImpl::NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId) #endif } +BluezAdvertisement::AdvertisingIntervals BLEManagerImpl::GetAdvertisingIntervals() const +{ + if (mFlags.Has(Flags::kFastAdvertisingEnabled)) + return { CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MIN, CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX }; +#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING + if (mFlags.Has(Flags::kExtAdvertisingEnabled)) + return { CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MIN, CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MAX }; +#endif + return { CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN, CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX }; +} + +void BLEManagerImpl::HandleAdvertisingTimer(chip::System::Layer *, void * appState) +{ + auto * self = static_cast(appState); + + if (self->mFlags.Has(Flags::kFastAdvertisingEnabled)) + { + ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start slow advertisement"); + self->_SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising); +#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING + self->mFlags.Clear(Flags::kExtAdvertisingEnabled); + DeviceLayer::SystemLayer().StartTimer(kSlowAdvertiseTimeout, HandleAdvertisingTimer, self); + } + else + { + ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start extended advertisement"); + self->mFlags.Set(Flags::kExtAdvertisingEnabled); + // This will trigger advertising intervals update in the DriveBLEState() function. + self->_SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising); +#endif + } +} + void BLEManagerImpl::InitiateScan(BleScanState scanType) { DriveBLEState(); @@ -695,18 +742,13 @@ void BLEManagerImpl::CleanScanConfig() mBLEScanConfig.mBleScanState = BleScanState::kNotScanning; } -void BLEManagerImpl::InitiateScan(intptr_t arg) -{ - sInstance.InitiateScan(static_cast(arg)); -} - void BLEManagerImpl::NewConnection(BleLayer * bleLayer, void * appState, const SetupDiscriminator & connDiscriminator) { mBLEScanConfig.mDiscriminator = connDiscriminator; mBLEScanConfig.mAppState = appState; // Scan initiation performed async, to ensure that the BLE subsystem is initialized. - PlatformMgr().ScheduleWork(InitiateScan, static_cast(BleScanState::kScanForDiscriminator)); + DeviceLayer::SystemLayer().ScheduleLambda([this] { InitiateScan(BleScanState::kScanForDiscriminator); }); } CHIP_ERROR BLEManagerImpl::CancelConnection() diff --git a/src/platform/Linux/BLEManagerImpl.h b/src/platform/Linux/BLEManagerImpl.h index 5cd3ed2460adf9..1441f2e6573573 100644 --- a/src/platform/Linux/BLEManagerImpl.h +++ b/src/platform/Linux/BLEManagerImpl.h @@ -141,6 +141,7 @@ class BLEManagerImpl final : public BLEManager, CHIP_ERROR CancelConnection() override; // ===== Members that implement virtual methods on ChipDeviceScannerDelegate + void OnDeviceScanned(BluezDevice1 & device, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) override; void OnScanComplete() override; @@ -152,6 +153,7 @@ class BLEManagerImpl final : public BLEManager, static BLEManagerImpl sInstance; // ===== Private members reserved for use by this class only. + enum class Flags : uint16_t { kAsyncInitCompleted = 0x0001, /**< One-time asynchronous initialization actions have been performed. */ @@ -164,6 +166,7 @@ class BLEManagerImpl final : public BLEManager, kFastAdvertisingEnabled = 0x0080, /**< The application has enabled fast advertising. */ kUseCustomDeviceName = 0x0100, /**< The application has configured a custom BLE device name. */ kAdvertisingRefreshNeeded = 0x0200, /**< The advertising configuration/state in BLE layer needs to be updated. */ + kExtAdvertisingEnabled = 0x0400, /**< The application has enabled CHIPoBLE extended advertising. */ }; enum @@ -174,10 +177,9 @@ class BLEManagerImpl final : public BLEManager, }; void DriveBLEState(); - static void DriveBLEState(intptr_t arg); - + BluezAdvertisement::AdvertisingIntervals GetAdvertisingIntervals() const; + static void HandleAdvertisingTimer(chip::System::Layer *, void * appState); void InitiateScan(BleScanState scanType); - static void InitiateScan(intptr_t arg); void CleanScanConfig(); CHIPoBLEServiceMode mServiceMode; @@ -189,9 +191,7 @@ class BLEManagerImpl final : public BLEManager, BluezEndpoint mEndpoint; BluezAdvertisement mBLEAdvertisement; - ChipAdvType mBLEAdvType = ChipAdvType::BLUEZ_ADV_TYPE_UNDIRECTED_CONNECTABLE_SCANNABLE; - uint16_t mBLEAdvDurationMs = 20; - const char * mpBLEAdvUUID = nullptr; + const char * mpBLEAdvUUID = nullptr; ChipDeviceScanner mDeviceScanner; BLEScanConfig mBLEScanConfig; diff --git a/src/platform/Linux/BUILD.gn b/src/platform/Linux/BUILD.gn index 635fd446eb941e..6fca28efb0ae3a 100644 --- a/src/platform/Linux/BUILD.gn +++ b/src/platform/Linux/BUILD.gn @@ -97,6 +97,8 @@ static_library("Linux") { "bluez/BluezConnection.h", "bluez/BluezEndpoint.cpp", "bluez/BluezEndpoint.h", + "bluez/BluezObjectIterator.h", + "bluez/BluezObjectList.h", "bluez/ChipDeviceScanner.cpp", "bluez/ChipDeviceScanner.h", "bluez/Types.h", diff --git a/src/platform/Linux/ThreadStackManagerImpl.cpp b/src/platform/Linux/ThreadStackManagerImpl.cpp index 20bfe905144b8f..a8f6c23f1e5a24 100644 --- a/src/platform/Linux/ThreadStackManagerImpl.cpp +++ b/src/platform/Linux/ThreadStackManagerImpl.cpp @@ -28,10 +28,6 @@ #include -#include -#include -#include - using namespace ::chip::app; using namespace ::chip::app::Clusters; using namespace chip::DeviceLayer::NetworkCommissioning; diff --git a/src/platform/Linux/bluez/BluezAdvertisement.cpp b/src/platform/Linux/bluez/BluezAdvertisement.cpp index ab6b5ddc6b0751..db74da8bec1ec4 100644 --- a/src/platform/Linux/bluez/BluezAdvertisement.cpp +++ b/src/platform/Linux/bluez/BluezAdvertisement.cpp @@ -42,52 +42,36 @@ BluezLEAdvertisement1 * BluezAdvertisement::CreateLEAdvertisement() { BluezLEAdvertisement1 * adv; BluezObjectSkeleton * object; - GVariant * serviceData; GVariant * serviceUUID; - GVariantBuilder serviceDataBuilder; GVariantBuilder serviceUUIDsBuilder; - GAutoPtr debugStr; ChipLogDetail(DeviceLayer, "Create BLE adv object at %s", mpAdvPath); object = bluez_object_skeleton_new(mpAdvPath); adv = bluez_leadvertisement1_skeleton_new(); - g_variant_builder_init(&serviceDataBuilder, G_VARIANT_TYPE("a{sv}")); g_variant_builder_init(&serviceUUIDsBuilder, G_VARIANT_TYPE("as")); - - g_variant_builder_add(&serviceDataBuilder, "{sv}", mpAdvUUID, - g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, &mDeviceIdInfo, sizeof(mDeviceIdInfo), sizeof(uint8_t))); g_variant_builder_add(&serviceUUIDsBuilder, "s", mpAdvUUID); - serviceData = g_variant_builder_end(&serviceDataBuilder); serviceUUID = g_variant_builder_end(&serviceUUIDsBuilder); - debugStr = GAutoPtr(g_variant_print(serviceData, TRUE)); - ChipLogDetail(DeviceLayer, "SET service data to %s", StringOrNullMarker(debugStr.get())); - - bluez_leadvertisement1_set_type_(adv, (mAdvType & BLUEZ_ADV_TYPE_CONNECTABLE) ? "peripheral" : "broadcast"); + bluez_leadvertisement1_set_type_(adv, "peripheral"); + bluez_leadvertisement1_set_service_uuids(adv, serviceUUID); // empty manufacturer data // empty solicit UUIDs - bluez_leadvertisement1_set_service_data(adv, serviceData); // empty data // Setting "Discoverable" to False on the adapter and to True on the advertisement convinces // Bluez to set "BR/EDR Not Supported" flag. Bluez doesn't provide API to do that explicitly // and the flag is necessary to force using LE transport. - bluez_leadvertisement1_set_discoverable(adv, (mAdvType & BLUEZ_ADV_TYPE_SCANNABLE) ? TRUE : FALSE); - if (mAdvType & BLUEZ_ADV_TYPE_SCANNABLE) - bluez_leadvertisement1_set_discoverable_timeout(adv, UINT16_MAX); + bluez_leadvertisement1_set_discoverable(adv, TRUE); + bluez_leadvertisement1_set_discoverable_timeout(adv, 0 /* infinite */); + // empty includes bluez_leadvertisement1_set_local_name(adv, mAdvName); - bluez_leadvertisement1_set_service_uuids(adv, serviceUUID); - - // 0xffff means no appearance - bluez_leadvertisement1_set_appearance(adv, 0xffff); - - bluez_leadvertisement1_set_duration(adv, mAdvDurationMs); - // empty duration, we don't have a clear notion what it would mean to timeslice between toble and anyone else - bluez_leadvertisement1_set_timeout(adv, 0); + bluez_leadvertisement1_set_appearance(adv, 0xffff /* no appearance */); + // empty duration + // empty timeout // empty secondary channel for now bluez_object_skeleton_set_leadvertisement1(object, adv); @@ -123,8 +107,7 @@ CHIP_ERROR BluezAdvertisement::InitImpl() return CHIP_NO_ERROR; } -CHIP_ERROR BluezAdvertisement::Init(const BluezEndpoint & aEndpoint, ChipAdvType aAdvType, const char * aAdvUUID, - uint32_t aAdvDurationMs, const char * aAdvName) +CHIP_ERROR BluezAdvertisement::Init(const BluezEndpoint & aEndpoint, const char * aAdvUUID, const char * aAdvName) { GAutoPtr rootPath; CHIP_ERROR err; @@ -136,10 +119,8 @@ CHIP_ERROR BluezAdvertisement::Init(const BluezEndpoint & aEndpoint, ChipAdvType mpAdapter = reinterpret_cast(g_object_ref(aEndpoint.GetAdapter())); g_object_get(G_OBJECT(mpRoot), "object-path", &MakeUniquePointerReceiver(rootPath).Get(), nullptr); - mpAdvPath = g_strdup_printf("%s/advertising", rootPath.get()); - mAdvType = aAdvType; - mpAdvUUID = g_strdup(aAdvUUID); - mAdvDurationMs = aAdvDurationMs; + mpAdvPath = g_strdup_printf("%s/advertising", rootPath.get()); + mpAdvUUID = g_strdup(aAdvUUID); if (aAdvName != nullptr) { @@ -151,13 +132,6 @@ CHIP_ERROR BluezAdvertisement::Init(const BluezEndpoint & aEndpoint, ChipAdvType g_snprintf(mAdvName, sizeof(mAdvName), "%s%04x", CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, getpid() & 0xffff); } - err = ConfigurationMgr().GetBLEDeviceIdentificationInfo(mDeviceIdInfo); - ReturnErrorOnFailure(err); - -#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING - mDeviceIdInfo.SetAdditionalDataFlag(true); -#endif - err = PlatformMgrImpl().GLibMatterContextInvokeSync( +[](BluezAdvertisement * self) { return self->InitImpl(); }, this); VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INCORRECT_STATE, @@ -169,6 +143,53 @@ CHIP_ERROR BluezAdvertisement::Init(const BluezEndpoint & aEndpoint, ChipAdvType return err; } +CHIP_ERROR BluezAdvertisement::SetIntervals(AdvertisingIntervals aAdvIntervals) +{ + VerifyOrReturnError(mpAdv != nullptr, CHIP_ERROR_UNINITIALIZED); + // If the advertisement is already running, BlueZ will update the intervals + // automatically. There is no need to stop and restart the advertisement. + bluez_leadvertisement1_set_min_interval(mpAdv, aAdvIntervals.first * 0.625); + bluez_leadvertisement1_set_max_interval(mpAdv, aAdvIntervals.second * 0.625); + return CHIP_NO_ERROR; +} + +CHIP_ERROR BluezAdvertisement::SetupServiceData(ServiceDataFlags aFlags) +{ + VerifyOrReturnError(mpAdv != nullptr, CHIP_ERROR_UNINITIALIZED); + + Ble::ChipBLEDeviceIdentificationInfo deviceInfo; + ReturnErrorOnFailure(ConfigurationMgr().GetBLEDeviceIdentificationInfo(deviceInfo)); + +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + deviceInfo.SetAdditionalDataFlag(true); +#endif + +#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING + if (aFlags & kServiceDataExtendedAnnouncement) + { + deviceInfo.SetExtendedAnnouncementFlag(true); + // In case of extended advertisement, specification requires that + // the vendor ID and product ID are set to 0. + deviceInfo.SetVendorId(0); + deviceInfo.SetProductId(0); + } +#endif + + GVariantBuilder serviceDataBuilder; + g_variant_builder_init(&serviceDataBuilder, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&serviceDataBuilder, "{sv}", mpAdvUUID, + g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, &deviceInfo, sizeof(deviceInfo), sizeof(uint8_t))); + + GVariant * serviceData = g_variant_builder_end(&serviceDataBuilder); + + GAutoPtr debugStr(g_variant_print(serviceData, TRUE)); + ChipLogDetail(DeviceLayer, "SET service data to %s", StringOrNullMarker(debugStr.get())); + + bluez_leadvertisement1_set_service_data(mpAdv, serviceData); + + return CHIP_NO_ERROR; +} + void BluezAdvertisement::Shutdown() { VerifyOrReturn(mIsInitialized); diff --git a/src/platform/Linux/bluez/BluezAdvertisement.h b/src/platform/Linux/bluez/BluezAdvertisement.h index 3e14f18bccecd7..11fe51c8e7cdb9 100644 --- a/src/platform/Linux/bluez/BluezAdvertisement.h +++ b/src/platform/Linux/bluez/BluezAdvertisement.h @@ -18,6 +18,7 @@ #pragma once #include +#include #include #include @@ -38,11 +39,19 @@ class BluezEndpoint; class BluezAdvertisement { public: + using ServiceDataFlags = uint16_t; + // Minimum and maximum advertising intervals in units of 0.625ms. + using AdvertisingIntervals = std::pair; + + static constexpr ServiceDataFlags kServiceDataNone = 0; + static constexpr ServiceDataFlags kServiceDataExtendedAnnouncement = 1 << 0; + BluezAdvertisement() = default; ~BluezAdvertisement() { Shutdown(); } - CHIP_ERROR Init(const BluezEndpoint & aEndpoint, ChipAdvType aAdvType, const char * aAdvUUID, uint32_t aAdvDurationMs, - const char * aAdvName); + CHIP_ERROR Init(const BluezEndpoint & aEndpoint, const char * aAdvUUID, const char * aAdvName); + CHIP_ERROR SetupServiceData(ServiceDataFlags aFlags); + CHIP_ERROR SetIntervals(AdvertisingIntervals aAdvIntervals); void Shutdown(); /// Start BLE advertising. @@ -77,12 +86,9 @@ class BluezAdvertisement bool mIsInitialized = false; bool mIsAdvertising = false; - Ble::ChipBLEDeviceIdentificationInfo mDeviceIdInfo; - char * mpAdvPath = nullptr; - char * mpAdvUUID = nullptr; - ChipAdvType mAdvType; - uint16_t mAdvDurationMs = 0; - char mAdvName[32] = ""; + char * mpAdvPath = nullptr; + char * mpAdvUUID = nullptr; + char mAdvName[32] = ""; }; } // namespace Internal diff --git a/src/platform/Linux/bluez/BluezEndpoint.cpp b/src/platform/Linux/bluez/BluezEndpoint.cpp index 24614eba63d24f..51a418bfee384b 100644 --- a/src/platform/Linux/bluez/BluezEndpoint.cpp +++ b/src/platform/Linux/bluez/BluezEndpoint.cpp @@ -656,22 +656,14 @@ CHIP_ERROR BluezEndpoint::RegisterGattApplication() return err; } -CHIP_ERROR BluezEndpoint::Init(uint32_t aAdapterId, bool aIsCentral, const char * apBleAddr) +CHIP_ERROR BluezEndpoint::Init(bool aIsCentral, uint32_t aAdapterId) { - CHIP_ERROR err; + VerifyOrReturnError(!mIsInitialized, CHIP_ERROR_INCORRECT_STATE); mAdapterId = aAdapterId; mIsCentral = aIsCentral; - if (apBleAddr != nullptr) - mpAdapterAddr = g_strdup(apBleAddr); - - if (aIsCentral) - { - mpConnectCancellable = g_cancellable_new(); - } - - err = PlatformMgrImpl().GLibMatterContextInvokeSync( + CHIP_ERROR err = PlatformMgrImpl().GLibMatterContextInvokeSync( +[](BluezEndpoint * self) { return self->StartupEndpointBindings(); }, this); VerifyOrReturnError(err == CHIP_NO_ERROR, err, ChipLogError(DeviceLayer, "Failed to schedule endpoint initialization")); @@ -681,6 +673,13 @@ CHIP_ERROR BluezEndpoint::Init(uint32_t aAdapterId, bool aIsCentral, const char return CHIP_NO_ERROR; } +CHIP_ERROR BluezEndpoint::Init(bool aIsCentral, const char * apBleAddr) +{ + VerifyOrReturnError(!mIsInitialized, CHIP_ERROR_INCORRECT_STATE); + mpAdapterAddr = g_strdup(apBleAddr); + return Init(aIsCentral, mAdapterId); +} + void BluezEndpoint::Shutdown() { VerifyOrReturn(mIsInitialized); @@ -707,8 +706,6 @@ void BluezEndpoint::Shutdown() g_object_unref(self->mpC2); if (self->mpC3 != nullptr) g_object_unref(self->mpC3); - if (self->mpConnectCancellable != nullptr) - g_object_unref(self->mpConnectCancellable); return CHIP_NO_ERROR; }, this); @@ -744,7 +741,7 @@ void BluezEndpoint::ConnectDeviceDone(GObject * aObject, GAsyncResult * aResult, g_clear_error(&MakeUniquePointerReceiver(error).Get()); bluez_device1_call_disconnect_sync(device, nullptr, &MakeUniquePointerReceiver(error).Get()); - bluez_device1_call_connect(device, params->mEndpoint.mpConnectCancellable, ConnectDeviceDone, params); + bluez_device1_call_connect(device, params->mEndpoint.mConnectCancellable.get(), ConnectDeviceDone, params); return; } @@ -760,8 +757,7 @@ void BluezEndpoint::ConnectDeviceDone(GObject * aObject, GAsyncResult * aResult, CHIP_ERROR BluezEndpoint::ConnectDeviceImpl(ConnectParams * apParams) { - g_cancellable_reset(apParams->mEndpoint.mpConnectCancellable); - bluez_device1_call_connect(apParams->mpDevice, apParams->mEndpoint.mpConnectCancellable, ConnectDeviceDone, apParams); + bluez_device1_call_connect(apParams->mpDevice, apParams->mEndpoint.mConnectCancellable.get(), ConnectDeviceDone, apParams); return CHIP_NO_ERROR; } @@ -770,6 +766,7 @@ CHIP_ERROR BluezEndpoint::ConnectDevice(BluezDevice1 & aDevice) auto params = chip::Platform::New(*this, &aDevice); VerifyOrReturnError(params != nullptr, CHIP_ERROR_NO_MEMORY); + mConnectCancellable.reset(g_cancellable_new()); if (PlatformMgrImpl().GLibMatterContextInvokeSync(ConnectDeviceImpl, params) != CHIP_NO_ERROR) { ChipLogError(Ble, "Failed to schedule ConnectDeviceImpl() on CHIPoBluez thread"); @@ -782,8 +779,8 @@ CHIP_ERROR BluezEndpoint::ConnectDevice(BluezDevice1 & aDevice) void BluezEndpoint::CancelConnect() { - VerifyOrDie(mpConnectCancellable != nullptr); - g_cancellable_cancel(mpConnectCancellable); + g_cancellable_cancel(mConnectCancellable.get()); + mConnectCancellable.reset(); } } // namespace Internal diff --git a/src/platform/Linux/bluez/BluezEndpoint.h b/src/platform/Linux/bluez/BluezEndpoint.h index 397b5a1597168b..772b503efd300a 100644 --- a/src/platform/Linux/bluez/BluezEndpoint.h +++ b/src/platform/Linux/bluez/BluezEndpoint.h @@ -54,6 +54,7 @@ #include #include +#include #include #include "BluezConnection.h" @@ -69,7 +70,8 @@ class BluezEndpoint BluezEndpoint() = default; ~BluezEndpoint() = default; - CHIP_ERROR Init(uint32_t aAdapterId, bool aIsCentral, const char * apBleAddr); + CHIP_ERROR Init(bool aIsCentral, uint32_t aAdapterId); + CHIP_ERROR Init(bool aIsCentral, const char * apBleAddr); void Shutdown(); BluezAdapter1 * GetAdapter() const { return mpAdapter; } @@ -148,8 +150,8 @@ class BluezEndpoint BluezGattCharacteristic1 * mpC3 = nullptr; std::unordered_map mConnMap; - GCancellable * mpConnectCancellable = nullptr; - char * mpPeerDevicePath = nullptr; + GAutoPtr mConnectCancellable; + char * mpPeerDevicePath = nullptr; // Allow BluezConnection to access our private members friend class BluezConnection; diff --git a/src/platform/Linux/bluez/ChipDeviceScanner.cpp b/src/platform/Linux/bluez/ChipDeviceScanner.cpp index 3a3115a9ae4783..5d9cbf25c9028b 100644 --- a/src/platform/Linux/bluez/ChipDeviceScanner.cpp +++ b/src/platform/Linux/bluez/ChipDeviceScanner.cpp @@ -58,9 +58,8 @@ CHIP_ERROR ChipDeviceScanner::Init(BluezAdapter1 * adapter, ChipDeviceScannerDel // Make this function idempotent by shutting down previously initialized state if any. Shutdown(); - mAdapter = BLUEZ_ADAPTER1(g_object_ref(adapter)); - mCancellable = g_cancellable_new(); - mDelegate = delegate; + mAdapter = BLUEZ_ADAPTER1(g_object_ref(adapter)); + mDelegate = delegate; // Create the D-Bus object manager client object on the glib thread, so that all D-Bus signals // will be delivered to the glib thread. @@ -73,7 +72,7 @@ CHIP_ERROR ChipDeviceScanner::Init(BluezAdapter1 * adapter, ChipDeviceScannerDel self->mManager = g_dbus_object_manager_client_new_for_bus_sync( G_BUS_TYPE_SYSTEM, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, BLUEZ_INTERFACE, "/", bluez_object_manager_client_get_proxy_type, nullptr /* unused user data in the Proxy Type Func */, - nullptr /* destroy notify */, self->mCancellable, &MakeUniquePointerReceiver(err).Get()); + nullptr /* destroy notify */, nullptr /* cancellable */, &MakeUniquePointerReceiver(err).Get()); VerifyOrReturnError(self->mManager != nullptr, CHIP_ERROR_INTERNAL, ChipLogError(Ble, "Failed to get D-Bus object manager for device scanning: %s", err->message)); return CHIP_NO_ERROR; @@ -100,8 +99,6 @@ void ChipDeviceScanner::Shutdown() g_object_unref(self->mManager); if (self->mAdapter != nullptr) g_object_unref(self->mAdapter); - if (self->mCancellable != nullptr) - g_object_unref(self->mCancellable); return CHIP_NO_ERROR; }, this); @@ -115,6 +112,7 @@ CHIP_ERROR ChipDeviceScanner::StartScan(System::Clock::Timeout timeout) VerifyOrReturnError(mScannerState != ChipDeviceScannerState::SCANNER_SCANNING, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnError(mTimerState == ScannerTimerState::TIMER_CANCELED, CHIP_ERROR_INCORRECT_STATE); + mCancellable.reset(g_cancellable_new()); if (PlatformMgrImpl().GLibMatterContextInvokeSync(MainLoopStartScan, this) != CHIP_NO_ERROR) { ChipLogError(Ble, "Failed to schedule BLE scan start."); @@ -191,7 +189,9 @@ CHIP_ERROR ChipDeviceScanner::MainLoopStopScan(ChipDeviceScanner * self) { GAutoPtr error; - g_cancellable_cancel(self->mCancellable); // in case we are currently running a scan + // In case we are currently running a scan + g_cancellable_cancel(self->mCancellable.get()); + self->mCancellable.reset(); if (self->mObjectAddedSignal) { @@ -303,7 +303,7 @@ CHIP_ERROR ChipDeviceScanner::MainLoopStartScan(ChipDeviceScanner * self) g_variant_builder_add(&filterBuilder, "{sv}", "Transport", g_variant_new_string("le")); GVariant * filter = g_variant_builder_end(&filterBuilder); - if (!bluez_adapter1_call_set_discovery_filter_sync(self->mAdapter, filter, self->mCancellable, + if (!bluez_adapter1_call_set_discovery_filter_sync(self->mAdapter, filter, self->mCancellable.get(), &MakeUniquePointerReceiver(error).Get())) { // Not critical: ignore if fails @@ -312,7 +312,8 @@ CHIP_ERROR ChipDeviceScanner::MainLoopStartScan(ChipDeviceScanner * self) } ChipLogProgress(Ble, "BLE initiating scan."); - if (!bluez_adapter1_call_start_discovery_sync(self->mAdapter, self->mCancellable, &MakeUniquePointerReceiver(error).Get())) + if (!bluez_adapter1_call_start_discovery_sync(self->mAdapter, self->mCancellable.get(), + &MakeUniquePointerReceiver(error).Get())) { ChipLogError(Ble, "Failed to start discovery: %s", error->message); return CHIP_ERROR_INTERNAL; diff --git a/src/platform/Linux/bluez/ChipDeviceScanner.h b/src/platform/Linux/bluez/ChipDeviceScanner.h index 4785a737869dda..1271ec39cb241a 100644 --- a/src/platform/Linux/bluez/ChipDeviceScanner.h +++ b/src/platform/Linux/bluez/ChipDeviceScanner.h @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -106,13 +107,13 @@ class ChipDeviceScanner GDBusObjectManager * mManager = nullptr; BluezAdapter1 * mAdapter = nullptr; - GCancellable * mCancellable = nullptr; ChipDeviceScannerDelegate * mDelegate = nullptr; gulong mObjectAddedSignal = 0; gulong mInterfaceChangedSignal = 0; ChipDeviceScannerState mScannerState = ChipDeviceScannerState::SCANNER_UNINITIALIZED; /// Used to track if timer has already expired and doesn't need to be canceled. ScannerTimerState mTimerState = ScannerTimerState::TIMER_CANCELED; + GAutoPtr mCancellable; }; } // namespace Internal diff --git a/src/platform/Linux/bluez/Types.h b/src/platform/Linux/bluez/Types.h index 0153492b5b0e32..f7be4d858d079a 100644 --- a/src/platform/Linux/bluez/Types.h +++ b/src/platform/Linux/bluez/Types.h @@ -63,23 +63,6 @@ struct GAutoPtrDeleter namespace DeviceLayer { namespace Internal { -enum ChipAdvType -{ - BLUEZ_ADV_TYPE_CONNECTABLE = 0x01, - BLUEZ_ADV_TYPE_SCANNABLE = 0x02, - BLUEZ_ADV_TYPE_DIRECTED = 0x04, - - BLUEZ_ADV_TYPE_UNDIRECTED_NONCONNECTABLE_NONSCANNABLE = 0, - BLUEZ_ADV_TYPE_UNDIRECTED_CONNECTABLE_NONSCANNABLE = BLUEZ_ADV_TYPE_CONNECTABLE, - BLUEZ_ADV_TYPE_UNDIRECTED_NONCONNECTABLE_SCANNABLE = BLUEZ_ADV_TYPE_SCANNABLE, - BLUEZ_ADV_TYPE_UNDIRECTED_CONNECTABLE_SCANNABLE = BLUEZ_ADV_TYPE_CONNECTABLE | BLUEZ_ADV_TYPE_SCANNABLE, - - BLUEZ_ADV_TYPE_DIRECTED_NONCONNECTABLE_NONSCANNABLE = BLUEZ_ADV_TYPE_DIRECTED, - BLUEZ_ADV_TYPE_DIRECTED_CONNECTABLE_NONSCANNABLE = BLUEZ_ADV_TYPE_DIRECTED | BLUEZ_ADV_TYPE_CONNECTABLE, - BLUEZ_ADV_TYPE_DIRECTED_NONCONNECTABLE_SCANNABLE = BLUEZ_ADV_TYPE_DIRECTED | BLUEZ_ADV_TYPE_SCANNABLE, - BLUEZ_ADV_TYPE_DIRECTED_CONNECTABLE_SCANNABLE = BLUEZ_ADV_TYPE_DIRECTED | BLUEZ_ADV_TYPE_CONNECTABLE | BLUEZ_ADV_TYPE_SCANNABLE, -}; - #define BLUEZ_ADDRESS_SIZE 6 ///< BLE address size (in bytes) #define BLUEZ_PATH "/org/bluez" #define BLUEZ_INTERFACE "org.bluez" diff --git a/src/platform/Linux/dbus/bluez/DbusBluez.xml b/src/platform/Linux/dbus/bluez/DbusBluez.xml index ac0952bcc30284..00887dc5e147a9 100644 --- a/src/platform/Linux/dbus/bluez/DbusBluez.xml +++ b/src/platform/Linux/dbus/bluez/DbusBluez.xml @@ -187,9 +187,11 @@ - - + + + + diff --git a/src/platform/Tizen/BLEManagerImpl.cpp b/src/platform/Tizen/BLEManagerImpl.cpp index 500943f660d67d..a759b4ecb72e75 100644 --- a/src/platform/Tizen/BLEManagerImpl.cpp +++ b/src/platform/Tizen/BLEManagerImpl.cpp @@ -73,6 +73,23 @@ namespace chip { namespace DeviceLayer { namespace Internal { +namespace { + +/* CHIPoBLE UUID strings */ +constexpr char chip_ble_service_uuid[] = "0000FFF6-0000-1000-8000-00805F9B34FB"; +constexpr char chip_ble_char_c1_tx_uuid[] = "18EE2EF5-263D-4559-959F-4F9C429F9D11"; +constexpr char chip_ble_char_c2_rx_uuid[] = "18EE2EF5-263D-4559-959F-4F9C429F9D12"; + +constexpr char chip_ble_desc_uuid_short[] = "2902"; +constexpr char chip_ble_service_uuid_short[] = "FFF6"; + +constexpr System::Clock::Timeout kNewConnectionScanTimeout = System::Clock::Seconds16(20); +constexpr System::Clock::Timeout kConnectTimeout = System::Clock::Seconds16(20); +constexpr System::Clock::Timeout kFastAdvertiseTimeout = + System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_BLE_ADVERTISING_INTERVAL_CHANGE_TIME); + +}; // namespace + BLEManagerImpl BLEManagerImpl::sInstance; struct BLEConnection @@ -85,20 +102,6 @@ struct BLEConnection bool isChipDevice; }; -/* CHIPoBLE UUID strings */ -const char chip_ble_service_uuid[] = "0000FFF6-0000-1000-8000-00805F9B34FB"; -const char chip_ble_char_c1_tx_uuid[] = "18EE2EF5-263D-4559-959F-4F9C429F9D11"; -const char chip_ble_char_c2_rx_uuid[] = "18EE2EF5-263D-4559-959F-4F9C429F9D12"; -/* CCCD */ -const char desc_uuid_short[] = "2902"; - -const char chip_ble_service_uuid_short[] = "FFF6"; - -/* Tizen Default Scan Timeout */ -static constexpr System::Clock::Timeout kNewConnectionScanTimeout = System::Clock::Seconds16(10); -/* Tizen Default Connect Timeout */ -static constexpr System::Clock::Timeout kConnectTimeout = System::Clock::Seconds16(10); - static void __BLEConnectionFree(BLEConnection * conn) { VerifyOrReturn(conn != nullptr); @@ -106,58 +109,53 @@ static void __BLEConnectionFree(BLEConnection * conn) g_free(conn); } -static void __AdapterStateChangedCb(int result, bt_adapter_state_e adapterState, void * userData) +void BLEManagerImpl::AdapterStateChangedCb(int result, bt_adapter_state_e adapterState) { ChipLogProgress(DeviceLayer, "Adapter State Changed: %s", adapterState == BT_ADAPTER_ENABLED ? "Enabled" : "Disabled"); } -void BLEManagerImpl::GattConnectionStateChangedCb(int result, bool connected, const char * remoteAddress, void * userData) +void BLEManagerImpl::GattConnectionStateChangedCb(int result, bool connected, const char * remoteAddress) { switch (result) { case BT_ERROR_NONE: case BT_ERROR_ALREADY_DONE: ChipLogProgress(DeviceLayer, "GATT %s", connected ? "connected" : "disconnected"); - sInstance.HandleConnectionEvent(connected, remoteAddress); + HandleConnectionEvent(connected, remoteAddress); break; default: ChipLogError(DeviceLayer, "GATT %s failed: %s", connected ? "connection" : "disconnection", get_error_message(result)); if (connected) - sInstance.NotifyHandleConnectFailed(TizenToChipError(result)); + NotifyHandleConnectFailed(TizenToChipError(result)); } } -CHIP_ERROR BLEManagerImpl::_BleInitialize(void * userData) +CHIP_ERROR BLEManagerImpl::_InitImpl() { int ret; - if (sInstance.mFlags.Has(Flags::kTizenBLELayerInitialized)) - { - ChipLogProgress(DeviceLayer, "BLE Already Initialized"); - return CHIP_NO_ERROR; - } - ret = bt_initialize(); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_initialize() failed: %s", get_error_message(ret))); - ret = bt_adapter_set_state_changed_cb(__AdapterStateChangedCb, nullptr); + ret = bt_adapter_set_state_changed_cb( + +[](int result, bt_adapter_state_e adapterState, void * self) { + return reinterpret_cast(self)->AdapterStateChangedCb(result, adapterState); + }, + this); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_adapter_set_state_changed_cb() failed: %s", get_error_message(ret))); ret = bt_gatt_server_initialize(); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_server_initialize() failed: %s", get_error_message(ret))); - ret = bt_gatt_set_connection_state_changed_cb(GattConnectionStateChangedCb, nullptr); + ret = bt_gatt_set_connection_state_changed_cb( + +[](int result, bool connected, const char * remoteAddress, void * self) { + return reinterpret_cast(self)->GattConnectionStateChangedCb(result, connected, remoteAddress); + }, + this); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_adapter_set_state_changed_cb() failed: %s", get_error_message(ret))); - // The hash table key is stored in the BLEConnection structure - // and is freed by the __BLEConnectionFree() function. - sInstance.mConnectionMap = - g_hash_table_new_full(g_str_hash, g_str_equal, nullptr, reinterpret_cast(__BLEConnectionFree)); - - sInstance.mFlags.Set(Flags::kTizenBLELayerInitialized); - ChipLogProgress(DeviceLayer, "BLE Initialized"); return CHIP_NO_ERROR; exit: @@ -186,8 +184,24 @@ static constexpr const char * __ConvertAttTypeToStr(bt_gatt_type_e type) } } +void BLEManagerImpl::HandleAdvertisingTimeout(chip::System::Layer *, void * appState) +{ + auto * self = static_cast(appState); + VerifyOrReturn(self->mFlags.Has(Flags::kFastAdvertisingEnabled)); + + ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start slow advertisement"); + self->_SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising); +} + +BLEManagerImpl::AdvertisingIntervals BLEManagerImpl::GetAdvertisingIntervals() const +{ + if (mFlags.Has(Flags::kFastAdvertisingEnabled)) + return { CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MIN, CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX }; + return { CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN, CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX }; +} + void BLEManagerImpl::ReadValueRequestedCb(const char * remoteAddress, int requestId, bt_gatt_server_h server, bt_gatt_h gattHandle, - int offset, void * userData) + int offset) { int ret, len = 0; bt_gatt_type_e type; @@ -209,14 +223,14 @@ void BLEManagerImpl::ReadValueRequestedCb(const char * remoteAddress, int reques } void BLEManagerImpl::WriteValueRequestedCb(const char * remoteAddress, int requestId, bt_gatt_server_h server, bt_gatt_h gattHandle, - bool responseNeeded, int offset, const char * value, int len, void * userData) + bool responseNeeded, int offset, const char * value, int len) { int ret; GAutoPtr uuid; - BLEConnection * conn = nullptr; + BLEConnection * conn; bt_gatt_type_e type; - conn = static_cast(g_hash_table_lookup(sInstance.mConnectionMap, remoteAddress)); + conn = static_cast(g_hash_table_lookup(mConnectionMap, remoteAddress)); VerifyOrReturn(conn != nullptr, ChipLogError(DeviceLayer, "Failed to find connection info")); VerifyOrReturn(__GetAttInfo(gattHandle, &MakeUniquePointerReceiver(uuid).Get(), &type) == BT_ERROR_NONE, @@ -232,10 +246,10 @@ void BLEManagerImpl::WriteValueRequestedCb(const char * remoteAddress, int reque VerifyOrReturn(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_server_send_response() failed: %s", get_error_message(ret))); - sInstance.HandleC1CharWriteEvent(conn, Uint8::from_const_char(value), len); + HandleC1CharWriteEvent(conn, Uint8::from_const_char(value), len); } -void BLEManagerImpl::NotificationStateChangedCb(bool notify, bt_gatt_server_h server, bt_gatt_h charHandle, void * userData) +void BLEManagerImpl::NotificationStateChangedCb(bool notify, bt_gatt_server_h server, bt_gatt_h charHandle) { GAutoPtr uuid; BLEConnection * conn = nullptr; @@ -243,11 +257,11 @@ void BLEManagerImpl::NotificationStateChangedCb(bool notify, bt_gatt_server_h se GHashTableIter iter; gpointer key, value; - g_hash_table_iter_init(&iter, sInstance.mConnectionMap); + g_hash_table_iter_init(&iter, mConnectionMap); while (g_hash_table_iter_next(&iter, &key, &value)) { /* NOTE: Currently Tizen Platform API does not return remote device address, which enables/disables - * notification/Indication. Therefore, returning first Connection */ + * notification/indication. Therefore, returning first connection. */ conn = static_cast(value); break; } @@ -260,7 +274,7 @@ void BLEManagerImpl::NotificationStateChangedCb(bool notify, bt_gatt_server_h se ChipLogProgress(DeviceLayer, "Notification State Changed %d on %s: %s", notify, __ConvertAttTypeToStr(type), StringOrNullMarker(uuid.get())); - sInstance.NotifyBLESubscribed(notify ? true : false, conn); + NotifyBLESubscribed(notify ? true : false, conn); } void BLEManagerImpl::WriteCompletedCb(int result, bt_gatt_h gattHandle, void * userData) @@ -288,44 +302,48 @@ void BLEManagerImpl::CharacteristicNotificationCb(bt_gatt_h characteristic, char } void BLEManagerImpl::IndicationConfirmationCb(int result, const char * remoteAddress, bt_gatt_server_h server, - bt_gatt_h characteristic, bool completed, void * userData) + bt_gatt_h characteristic, bool completed) { BLEConnection * conn = nullptr; VerifyOrReturn(result == BT_ERROR_NONE, ChipLogError(DeviceLayer, "Failed to Get Indication Confirmation")); - conn = static_cast(g_hash_table_lookup(sInstance.mConnectionMap, remoteAddress)); + conn = static_cast(g_hash_table_lookup(mConnectionMap, remoteAddress)); VerifyOrReturn(conn != nullptr, ChipLogError(DeviceLayer, "Could not find connection for [%s]", StringOrNullMarker(remoteAddress))); - VerifyOrReturn(sInstance.mGattCharC2Handle == characteristic, - ChipLogError(DeviceLayer, "Gatt characteristic handle did not match")); + VerifyOrReturn(mGattCharC2Handle == characteristic, ChipLogError(DeviceLayer, "Gatt characteristic handle did not match")); - sInstance.NotifyBLEIndicationConfirmation(conn); + NotifyBLEIndicationConfirmation(conn); } -void BLEManagerImpl::AdvertisingStateChangedCb(int result, bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e advState, - void * userData) +void BLEManagerImpl::AdvertisingStateChangedCb(int result, bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e advState) { ChipLogProgress(DeviceLayer, "Advertising %s", advState == BT_ADAPTER_LE_ADVERTISING_STARTED ? "Started" : "Stopped"); if (advState == BT_ADAPTER_LE_ADVERTISING_STARTED) { - sInstance.mFlags.Set(Flags::kAdvertising); - sInstance.NotifyBLEPeripheralAdvStartComplete(true, nullptr); + mFlags.Set(Flags::kAdvertising); + NotifyBLEPeripheralAdvStartComplete(true, nullptr); + DeviceLayer::SystemLayer().ScheduleLambda([this] { + // Start a timer to make sure that the fast advertising is stopped after specified timeout. + DeviceLayer::SystemLayer().StartTimer(kFastAdvertiseTimeout, HandleAdvertisingTimeout, this); + }); } else { - sInstance.mFlags.Clear(Flags::kAdvertising); - sInstance.NotifyBLEPeripheralAdvStopComplete(true, nullptr); + mFlags.Clear(Flags::kAdvertising); + NotifyBLEPeripheralAdvStopComplete(true, nullptr); + DeviceLayer::SystemLayer().ScheduleLambda( + [this] { DeviceLayer::SystemLayer().CancelTimer(HandleAdvertisingTimeout, this); }); } - if (sInstance.mFlags.Has(Flags::kAdvertisingRefreshNeeded)) + if (mFlags.Has(Flags::kAdvertisingRefreshNeeded)) { - sInstance.mFlags.Clear(Flags::kAdvertisingRefreshNeeded); - PlatformMgr().ScheduleWork(DriveBLEState, 0); + mFlags.Clear(Flags::kAdvertisingRefreshNeeded); + DeviceLayer::SystemLayer().ScheduleLambda([this] { DriveBLEState(); }); } - sInstance.mAdvReqInProgress = false; + mAdvReqInProgress = false; } // ====== Private Functions. @@ -401,9 +419,9 @@ void BLEManagerImpl::NotifyBLEIndicationConfirmation(BLE_CONNECTION_OBJECT conId void BLEManagerImpl::NotifyBLEConnectionEstablished(BLE_CONNECTION_OBJECT conId, CHIP_ERROR error) { - ChipDeviceEvent connectionEvent; - connectionEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEventOrDie(&connectionEvent); + ChipDeviceEvent event; + event.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; + PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::NotifyBLEDisconnection(BLE_CONNECTION_OBJECT conId, CHIP_ERROR error) @@ -418,7 +436,7 @@ void BLEManagerImpl::NotifyBLEDisconnection(BLE_CONNECTION_OBJECT conId, CHIP_ER void BLEManagerImpl::NotifyHandleConnectFailed(CHIP_ERROR error) { ChipLogProgress(DeviceLayer, "Connection failed: %" CHIP_ERROR_FORMAT, error.Format()); - if (sInstance.mIsCentral) + if (mIsCentral) { ChipDeviceEvent event; event.Type = DeviceEventType::kPlatformTizenBLECentralConnectFailed; @@ -429,7 +447,7 @@ void BLEManagerImpl::NotifyHandleConnectFailed(CHIP_ERROR error) void BLEManagerImpl::NotifyHandleNewConnection(BLE_CONNECTION_OBJECT conId) { - if (sInstance.mIsCentral) + if (mIsCentral) { ChipDeviceEvent event; event.Type = DeviceEventType::kPlatformTizenBLECentralConnected; @@ -455,9 +473,10 @@ void BLEManagerImpl::NotifySubscribeOpComplete(BLE_CONNECTION_OBJECT conId, bool PlatformMgr().PostEventOrDie(&event); } -void BLEManagerImpl::HandleConnectionTimeout(System::Layer * layer, void * data) +void BLEManagerImpl::HandleConnectionTimeout(System::Layer *, void * appState) { - sInstance.NotifyHandleConnectFailed(CHIP_ERROR_TIMEOUT); + auto * self = static_cast(appState); + self->NotifyHandleConnectFailed(CHIP_ERROR_TIMEOUT); } CHIP_ERROR BLEManagerImpl::ConnectChipThing(const char * address) @@ -467,7 +486,7 @@ CHIP_ERROR BLEManagerImpl::ConnectChipThing(const char * address) ChipLogProgress(DeviceLayer, "ConnectRequest: Addr [%s]", StringOrNullMarker(address)); - ret = bt_gatt_client_create(address, &sInstance.mGattClient); + ret = bt_gatt_client_create(address, &mGattClient); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "Failed to create GATT client: %s", get_error_message(ret)); err = TizenToChipError(ret)); @@ -480,7 +499,7 @@ CHIP_ERROR BLEManagerImpl::ConnectChipThing(const char * address) exit: if (err != CHIP_NO_ERROR) - sInstance.NotifyHandleConnectFailed(err); + NotifyHandleConnectFailed(err); return err; } @@ -516,12 +535,17 @@ void BLEManagerImpl::OnChipDeviceScanned(void * device, const Ble::ChipBLEDevice /* Set CHIP Connecting state */ mBLEScanConfig.mBleScanState = BleScanState::kConnecting; chip::DeviceLayer::PlatformMgr().LockChipStack(); - DeviceLayer::SystemLayer().StartTimer(kConnectTimeout, HandleConnectionTimeout, nullptr); + DeviceLayer::SystemLayer().StartTimer(kConnectTimeout, HandleConnectionTimeout, this); chip::DeviceLayer::PlatformMgr().UnlockChipStack(); mDeviceScanner->StopChipScan(); /* Initiate Connect */ - PlatformMgrImpl().GLibMatterContextInvokeSync(ConnectChipThing, const_cast(deviceInfo->remote_address)); + auto params = std::make_pair(this, deviceInfo->remote_address); + PlatformMgrImpl().GLibMatterContextInvokeSync( + +[](typeof(params) * aParams) { + return reinterpret_cast(aParams->first)->ConnectChipThing(aParams->second); + }, + ¶ms); } void BLEManagerImpl::OnScanComplete() @@ -575,7 +599,14 @@ CHIP_ERROR BLEManagerImpl::RegisterGATTServer() VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_characteristic_create() failed: %s", get_error_message(ret))); - ret = bt_gatt_server_set_write_value_requested_cb(char1, WriteValueRequestedCb, nullptr); + ret = bt_gatt_server_set_write_value_requested_cb( + char1, + +[](const char * remoteAddress, int requestId, bt_gatt_server_h gattServer, bt_gatt_h gattHandle, bool responseNeeded, + int offset, const char * value, int len, void * self) { + return reinterpret_cast(self)->WriteValueRequestedCb(remoteAddress, requestId, gattServer, gattHandle, + responseNeeded, offset, value, len); + }, + this); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_server_set_write_value_requested_cb() failed: %s", get_error_message(ret))); @@ -590,16 +621,27 @@ CHIP_ERROR BLEManagerImpl::RegisterGATTServer() VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_characteristic_create() failed: %s", get_error_message(ret))); - ret = bt_gatt_server_set_read_value_requested_cb(char2, ReadValueRequestedCb, nullptr); + ret = bt_gatt_server_set_read_value_requested_cb( + char2, + +[](const char * remoteAddress, int requestId, bt_gatt_server_h gattServer, bt_gatt_h gattHandle, int offset, void * self) { + return reinterpret_cast(self)->ReadValueRequestedCb(remoteAddress, requestId, gattServer, gattHandle, + offset); + }, + this); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_server_set_read_value_requested_cb() failed: %s", get_error_message(ret))); - ret = bt_gatt_server_set_characteristic_notification_state_change_cb(char2, NotificationStateChangedCb, nullptr); + ret = bt_gatt_server_set_characteristic_notification_state_change_cb( + char2, + +[](bool notify, bt_gatt_server_h gattServer, bt_gatt_h charHandle, void * self) { + return reinterpret_cast(self)->NotificationStateChangedCb(notify, gattServer, charHandle); + }, + this); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_server_set_characteristic_notification_state_change_cb() failed: %s", get_error_message(ret))); // Create CCC Descriptor - ret = bt_gatt_descriptor_create(desc_uuid_short, BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE, desc_value, + ret = bt_gatt_descriptor_create(chip_ble_desc_uuid_short, BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE, desc_value, sizeof(desc_value), &desc); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_descriptor_create() failed: %s", get_error_message(ret))); ret = bt_gatt_characteristic_add_descriptor(char2, desc); @@ -635,11 +677,12 @@ CHIP_ERROR BLEManagerImpl::RegisterGATTServer() CHIP_ERROR BLEManagerImpl::StartBLEAdvertising() { Ble::ChipBLEDeviceIdentificationInfo deviceIdInfo; + auto intervals = GetAdvertisingIntervals(); PlatformVersion version; CHIP_ERROR err; int ret; - if (sInstance.mAdvReqInProgress) + if (mAdvReqInProgress) { ChipLogProgress(DeviceLayer, "Advertising Request In Progress"); return CHIP_NO_ERROR; @@ -664,20 +707,9 @@ CHIP_ERROR BLEManagerImpl::StartBLEAdvertising() ChipLogError(DeviceLayer, "bt_adapter_le_clear_advertising_data() failed: %s", get_error_message(ret))); } - if (mFlags.Has(Flags::kFastAdvertisingEnabled)) - { - ret = bt_adapter_le_set_advertising_mode(mAdvertiser, BT_ADAPTER_LE_ADVERTISING_MODE_LOW_LATENCY); - VerifyOrExit(ret == BT_ERROR_NONE, - ChipLogError(DeviceLayer, "bt_adapter_le_set_advertising_mode() failed: %s", get_error_message(ret))); - - // NOTE: Check specification for recommended Advertising Interval range for Fast Advertising - // ret = bt_adapter_le_set_advertising_interval(mAdvertiser, BT_LE_ADV_INTERVAL_MIN, BT_LE_ADV_INTERVAL_MIN); - } - else - { - // NOTE: Check specification for recommended Advertising Interval range for Slow Advertising - // ret = bt_adapter_le_set_advertising_interval(mAdvertiser, BT_LE_ADV_INTERVAL_MAX, BT_LE_ADV_INTERVAL_MAX); - } + ret = bt_adapter_le_set_advertising_interval(mAdvertiser, intervals.first, intervals.second); + VerifyOrExit(ret == BT_ERROR_NONE, + ChipLogError(DeviceLayer, "bt_adapter_le_set_advertising_interval() failed: %s", get_error_message(ret))); err = ConfigurationMgr().GetBLEDeviceIdentificationInfo(deviceIdInfo); VerifyOrExit(err == CHIP_NO_ERROR, @@ -708,11 +740,16 @@ CHIP_ERROR BLEManagerImpl::StartBLEAdvertising() BLEManagerImpl::NotifyBLEPeripheralAdvConfiguredComplete(true, nullptr); - ret = bt_adapter_le_start_advertising_new(mAdvertiser, AdvertisingStateChangedCb, nullptr); + ret = bt_adapter_le_start_advertising_new( + mAdvertiser, + +[](int result, bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e advState, void * self) { + return reinterpret_cast(self)->AdvertisingStateChangedCb(result, advertiser, advState); + }, + this); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_adapter_le_start_advertising_new() failed: %s", get_error_message(ret))); - sInstance.mAdvReqInProgress = true; + mAdvReqInProgress = true; return CHIP_NO_ERROR; exit: @@ -728,7 +765,7 @@ CHIP_ERROR BLEManagerImpl::StopBLEAdvertising() VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_adapter_le_stop_advertising() failed: %s", get_error_message(ret))); - sInstance.mAdvReqInProgress = true; + mAdvReqInProgress = true; return CHIP_NO_ERROR; exit: @@ -791,13 +828,10 @@ static bool __GattClientForeachServiceCb(int total, int index, bt_gatt_h svcHand bool BLEManagerImpl::IsDeviceChipPeripheral(BLE_CONNECTION_OBJECT conId) { - auto conn = static_cast(conId); int ret; - - if ((ret = bt_gatt_client_foreach_services(sInstance.mGattClient, __GattClientForeachServiceCb, conn)) != BT_ERROR_NONE) + if ((ret = bt_gatt_client_foreach_services(mGattClient, __GattClientForeachServiceCb, conId)) != BT_ERROR_NONE) ChipLogError(DeviceLayer, "Failed to browse GATT services: %s", get_error_message(ret)); - - return (conn->isChipDevice ? true : false); + return (conId->isChipDevice ? true : false); } void BLEManagerImpl::AddConnectionData(const char * remoteAddr) @@ -818,7 +852,7 @@ void BLEManagerImpl::AddConnectionData(const char * remoteAddr) get_error_message(ret)); } - if (sInstance.mIsCentral) + if (mIsCentral) { /* Local Device is BLE Central Role */ if (IsDeviceChipPeripheral(conn)) @@ -970,11 +1004,6 @@ void BLEManagerImpl::DriveBLEState() } } -void BLEManagerImpl::DriveBLEState(intptr_t arg) -{ - sInstance.DriveBLEState(); -} - CHIP_ERROR BLEManagerImpl::_Init() { CHIP_ERROR err; @@ -983,12 +1012,21 @@ CHIP_ERROR BLEManagerImpl::_Init() SuccessOrExit(err); mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled; + mFlags.Set(Flags::kFastAdvertisingEnabled, true); + + ChipLogProgress(DeviceLayer, "Initialize Tizen BLE Layer"); - ChipLogProgress(DeviceLayer, "Initialize BLE"); - err = PlatformMgrImpl().GLibMatterContextInvokeSync(_BleInitialize, static_cast(nullptr)); + err = PlatformMgrImpl().GLibMatterContextInvokeSync( + +[](BLEManagerImpl * self) { return self->_InitImpl(); }, this); SuccessOrExit(err); - return PlatformMgr().ScheduleWork(DriveBLEState, 0); + // The hash table key is stored in the BLEConnection structure + // and is freed by the __BLEConnectionFree() function. + mConnectionMap = g_hash_table_new_full(g_str_hash, g_str_equal, nullptr, reinterpret_cast(__BLEConnectionFree)); + + mFlags.Set(Flags::kTizenBLELayerInitialized); + + err = DeviceLayer::SystemLayer().ScheduleLambda([this] { DriveBLEState(); }); exit: return err; @@ -1003,7 +1041,7 @@ void BLEManagerImpl::_Shutdown() CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) { mFlags.Set(Flags::kAdvertisingEnabled, val); - return PlatformMgr().ScheduleWork(DriveBLEState, 0); + return DeviceLayer::SystemLayer().ScheduleLambda([this] { DriveBLEState(); }); } CHIP_ERROR BLEManagerImpl::_SetAdvertisingMode(BLEAdvertisingMode mode) @@ -1020,7 +1058,7 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingMode(BLEAdvertisingMode mode) return CHIP_ERROR_INVALID_ARGUMENT; } mFlags.Set(Flags::kAdvertisingRefreshNeeded); - return PlatformMgr().ScheduleWork(DriveBLEState, 0); + return DeviceLayer::SystemLayer().ScheduleLambda([this] { DriveBLEState(); }); } CHIP_ERROR BLEManagerImpl::_GetDeviceName(char * buf, size_t bufSize) @@ -1081,7 +1119,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureBle(uint32_t aAdapterId, bool aIsCentral) void BLEManagerImpl::CleanScanConfig() { if (mBLEScanConfig.mBleScanState == BleScanState::kConnecting) - DeviceLayer::SystemLayer().CancelTimer(HandleConnectionTimeout, nullptr); + DeviceLayer::SystemLayer().CancelTimer(HandleConnectionTimeout, this); mBLEScanConfig.mBleScanState = BleScanState::kNotScanning; } @@ -1201,8 +1239,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) uint16_t BLEManagerImpl::GetMTU(BLE_CONNECTION_OBJECT conId) const { - auto conn = static_cast(conId); - return (conn != nullptr) ? static_cast(conn->mtu) : 0; + return (conId != nullptr) ? static_cast(conId->mtu) : 0; } bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const Ble::ChipBleUUID * svcId, @@ -1210,7 +1247,6 @@ bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const { Ble::ChipBleUUID service_uuid; Ble::ChipBleUUID char_notif_uuid; - auto conn = static_cast(conId); int ret; ChipLogProgress(DeviceLayer, "SubscribeCharacteristic"); @@ -1218,21 +1254,21 @@ bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const StringToUUID(chip_ble_service_uuid, service_uuid); StringToUUID(chip_ble_char_c2_rx_uuid, char_notif_uuid); - VerifyOrExit(conn != nullptr, ChipLogError(DeviceLayer, "Invalid Connection")); + VerifyOrExit(conId != nullptr, ChipLogError(DeviceLayer, "Invalid Connection")); VerifyOrExit(Ble::UUIDsMatch(svcId, &service_uuid), ChipLogError(DeviceLayer, "SubscribeCharacteristic() called with invalid service ID")); VerifyOrExit(Ble::UUIDsMatch(charId, &char_notif_uuid), ChipLogError(DeviceLayer, "SubscribeCharacteristic() called with invalid characteristic ID")); - VerifyOrExit(conn->gattCharC2Handle != nullptr, ChipLogError(DeviceLayer, "Char C2 is null")); + VerifyOrExit(conId->gattCharC2Handle != nullptr, ChipLogError(DeviceLayer, "Char C2 is null")); - ChipLogProgress(DeviceLayer, "Sending Notification Enable Request to CHIP Peripheral: %s", conn->peerAddr); + ChipLogProgress(DeviceLayer, "Sending Notification Enable Request to CHIP Peripheral: %s", conId->peerAddr); - ret = bt_gatt_client_set_characteristic_value_changed_cb(conn->gattCharC2Handle, CharacteristicNotificationCb, conn); + ret = bt_gatt_client_set_characteristic_value_changed_cb(conId->gattCharC2Handle, CharacteristicNotificationCb, conId); VerifyOrExit( ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_client_set_characteristic_value_changed_cb() failed: %s", get_error_message(ret))); - sInstance.NotifySubscribeOpComplete(conn, true); + NotifySubscribeOpComplete(conId, true); return true; exit: @@ -1244,7 +1280,6 @@ bool BLEManagerImpl::UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, cons { Ble::ChipBleUUID service_uuid; Ble::ChipBleUUID char_notif_uuid; - auto conn = static_cast(conId); int ret; ChipLogProgress(DeviceLayer, "UnSubscribeCharacteristic"); @@ -1252,21 +1287,21 @@ bool BLEManagerImpl::UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, cons StringToUUID(chip_ble_service_uuid, service_uuid); StringToUUID(chip_ble_char_c2_rx_uuid, char_notif_uuid); - VerifyOrExit(conn != nullptr, ChipLogError(DeviceLayer, "Invalid Connection")); + VerifyOrExit(conId != nullptr, ChipLogError(DeviceLayer, "Invalid Connection")); VerifyOrExit(Ble::UUIDsMatch(svcId, &service_uuid), ChipLogError(DeviceLayer, "UnSubscribeCharacteristic() called with invalid service ID")); VerifyOrExit(Ble::UUIDsMatch(charId, &char_notif_uuid), ChipLogError(DeviceLayer, "UnSubscribeCharacteristic() called with invalid characteristic ID")); - VerifyOrExit(conn->gattCharC2Handle != nullptr, ChipLogError(DeviceLayer, "Char C2 is null")); + VerifyOrExit(conId->gattCharC2Handle != nullptr, ChipLogError(DeviceLayer, "Char C2 is null")); - ChipLogProgress(DeviceLayer, "Disable Notification Request to CHIP Peripheral: %s", conn->peerAddr); + ChipLogProgress(DeviceLayer, "Disable Notification Request to CHIP Peripheral: %s", conId->peerAddr); - ret = bt_gatt_client_unset_characteristic_value_changed_cb(conn->gattCharC2Handle); + ret = bt_gatt_client_unset_characteristic_value_changed_cb(conId->gattCharC2Handle); VerifyOrExit( ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_client_unset_characteristic_value_changed_cb() failed: %s", get_error_message(ret))); - sInstance.NotifySubscribeOpComplete(conn, false); + NotifySubscribeOpComplete(conId, false); return true; exit: @@ -1275,19 +1310,18 @@ bool BLEManagerImpl::UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, cons bool BLEManagerImpl::CloseConnection(BLE_CONNECTION_OBJECT conId) { - auto conn = static_cast(conId); int ret; ChipLogProgress(DeviceLayer, "Close BLE Connection"); - conn = static_cast(g_hash_table_lookup(sInstance.mConnectionMap, conn->peerAddr)); - VerifyOrExit(conn != nullptr, ChipLogError(DeviceLayer, "Failed to find connection info")); + conId = static_cast(g_hash_table_lookup(mConnectionMap, conId->peerAddr)); + VerifyOrExit(conId != nullptr, ChipLogError(DeviceLayer, "Failed to find connection info")); - ChipLogProgress(DeviceLayer, "Send GATT disconnect to [%s]", conn->peerAddr); - ret = bt_gatt_disconnect(conn->peerAddr); + ChipLogProgress(DeviceLayer, "Send GATT disconnect to [%s]", conId->peerAddr); + ret = bt_gatt_disconnect(conId->peerAddr); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_disconnect() failed: %s", get_error_message(ret))); - RemoveConnectionData(conn->peerAddr); + RemoveConnectionData(conId->peerAddr); return true; exit: @@ -1297,21 +1331,27 @@ bool BLEManagerImpl::CloseConnection(BLE_CONNECTION_OBJECT conId) bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const Ble::ChipBleUUID * svcId, const Ble::ChipBleUUID * charId, System::PacketBufferHandle pBuf) { - auto conn = static_cast(conId); int ret; ChipLogProgress(DeviceLayer, "SendIndication"); - conn = static_cast(g_hash_table_lookup(sInstance.mConnectionMap, conn->peerAddr)); - VerifyOrExit(conn != nullptr, ChipLogError(DeviceLayer, "Failed to find connection info")); + conId = static_cast(g_hash_table_lookup(mConnectionMap, conId->peerAddr)); + VerifyOrExit(conId != nullptr, ChipLogError(DeviceLayer, "Failed to find connection info")); ret = bt_gatt_set_value(mGattCharC2Handle, Uint8::to_const_char(pBuf->Start()), pBuf->DataLength()); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_set_value() failed: %s", get_error_message(ret))); - ChipLogProgress(DeviceLayer, "Sending indication for CHIPoBLE RX characteristic (con %s, len %u)", conn->peerAddr, + ChipLogProgress(DeviceLayer, "Sending indication for CHIPoBLE RX characteristic (con %s, len %u)", conId->peerAddr, pBuf->DataLength()); - ret = bt_gatt_server_notify_characteristic_changed_value(mGattCharC2Handle, IndicationConfirmationCb, conn->peerAddr, nullptr); + ret = bt_gatt_server_notify_characteristic_changed_value( + mGattCharC2Handle, + +[](int result, const char * remoteAddress, bt_gatt_server_h server, bt_gatt_h characteristic, bool completed, + void * self) { + return reinterpret_cast(self)->IndicationConfirmationCb(result, remoteAddress, server, characteristic, + completed); + }, + conId->peerAddr, this); VerifyOrExit( ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_server_notify_characteristic_changed_value() failed: %s", get_error_message(ret))); @@ -1326,7 +1366,6 @@ bool BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const Ble::Ch { Ble::ChipBleUUID service_uuid; Ble::ChipBleUUID char_write_uuid; - auto conn = static_cast(conId); int ret; ChipLogProgress(DeviceLayer, "SendWriteRequest"); @@ -1334,20 +1373,20 @@ bool BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const Ble::Ch StringToUUID(chip_ble_service_uuid, service_uuid); StringToUUID(chip_ble_char_c1_tx_uuid, char_write_uuid); - VerifyOrExit(conn != nullptr, ChipLogError(DeviceLayer, "Invalid Connection")); + VerifyOrExit(conId != nullptr, ChipLogError(DeviceLayer, "Invalid Connection")); VerifyOrExit(Ble::UUIDsMatch(svcId, &service_uuid), ChipLogError(DeviceLayer, "SendWriteRequest() called with invalid service ID")); VerifyOrExit(Ble::UUIDsMatch(charId, &char_write_uuid), ChipLogError(DeviceLayer, "SendWriteRequest() called with invalid characteristic ID")); - VerifyOrExit(conn->gattCharC1Handle != nullptr, ChipLogError(DeviceLayer, "Char C1 is null")); + VerifyOrExit(conId->gattCharC1Handle != nullptr, ChipLogError(DeviceLayer, "Char C1 is null")); - ret = bt_gatt_set_value(conn->gattCharC1Handle, Uint8::to_const_char(pBuf->Start()), pBuf->DataLength()); + ret = bt_gatt_set_value(conId->gattCharC1Handle, Uint8::to_const_char(pBuf->Start()), pBuf->DataLength()); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_set_value() failed: %s", get_error_message(ret))); - ChipLogProgress(DeviceLayer, "Sending Write Request for CHIPoBLE TX characteristic (con %s, len %u)", conn->peerAddr, + ChipLogProgress(DeviceLayer, "Sending Write Request for CHIPoBLE TX characteristic (con %s, len %u)", conId->peerAddr, pBuf->DataLength()); - ret = bt_gatt_client_write_value(conn->gattCharC1Handle, WriteCompletedCb, conn); + ret = bt_gatt_client_write_value(conId->gattCharC1Handle, WriteCompletedCb, conId); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_client_write_value() failed: %s", get_error_message(ret))); return true; @@ -1382,8 +1421,8 @@ void BLEManagerImpl::NewConnection(BleLayer * bleLayer, void * appState, const S ChipLogProgress(DeviceLayer, "NewConnection: long discriminator value [%u]", connDiscriminator.GetLongValue()); } - // Initiate Scan. - PlatformMgr().ScheduleWork(InitiateScan, static_cast(BleScanState::kScanForDiscriminator)); + // Scan initiation performed async, to ensure that the BLE subsystem is initialized. + DeviceLayer::SystemLayer().ScheduleLambda([this] { InitiateScan(BleScanState::kScanForDiscriminator); }); } void BLEManagerImpl::InitiateScan(BleScanState scanType) @@ -1434,11 +1473,6 @@ void BLEManagerImpl::InitiateScan(BleScanState scanType) BleConnectionDelegate::OnConnectionError(mBLEScanConfig.mAppState, err); } -void BLEManagerImpl::InitiateScan(intptr_t arg) -{ - sInstance.InitiateScan(static_cast(arg)); -} - CHIP_ERROR BLEManagerImpl::CancelConnection() { return CHIP_ERROR_NOT_IMPLEMENTED; diff --git a/src/platform/Tizen/BLEManagerImpl.h b/src/platform/Tizen/BLEManagerImpl.h index d0080ecee561dd..1a49b9dae6c33f 100644 --- a/src/platform/Tizen/BLEManagerImpl.h +++ b/src/platform/Tizen/BLEManagerImpl.h @@ -150,6 +150,7 @@ class BLEManagerImpl final : public BLEManager, static BLEManagerImpl sInstance; // ===== Private members reserved for use by this class only. + enum class Flags : uint16_t { kAsyncInitCompleted = 0x0001, /**< One-time asynchronous initialization actions have been performed. */ @@ -164,25 +165,24 @@ class BLEManagerImpl final : public BLEManager, kAdvertisingRefreshNeeded = 0x0200, /**< The advertising configuration/state in BLE layer needs to be updated. */ }; - static CHIP_ERROR _BleInitialize(void * userData); + // Minimum and maximum advertising intervals in units of 0.625ms. + using AdvertisingIntervals = std::pair; + + CHIP_ERROR _InitImpl(); + void DriveBLEState(); - static void DriveBLEState(intptr_t arg); void InitiateScan(BleScanState scanType); - static void InitiateScan(intptr_t arg); - - static void AdvertisingStateChangedCb(int result, bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e advState, - void * userData); - static void NotificationStateChangedCb(bool notify, bt_gatt_server_h server, bt_gatt_h gattHandle, void * userData); - static void ReadValueRequestedCb(const char * remoteAddress, int requestId, bt_gatt_server_h server, bt_gatt_h gattHandle, - int offset, void * userData); - static void WriteValueRequestedCb(const char * remoteAddress, int requestId, bt_gatt_server_h server, bt_gatt_h gattHandle, - bool responseNeeded, int offset, const char * value, int len, void * userData); - static void IndicationConfirmationCb(int result, const char * remoteAddress, bt_gatt_server_h server, bt_gatt_h characteristic, - bool completed, void * userData); - static void IndicationConfirmationCb(bt_gatt_h characteristic, bt_gatt_server_notification_sent_cb callback, - const char * device_address, void * userData); - static void GattConnectionStateChangedCb(int result, bool connected, const char * remoteAddress, void * userData); + + void AdapterStateChangedCb(int result, bt_adapter_state_e adapterState); + void AdvertisingStateChangedCb(int result, bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e advState); + void NotificationStateChangedCb(bool notify, bt_gatt_server_h server, bt_gatt_h gattHandle); + void ReadValueRequestedCb(const char * remoteAddress, int requestId, bt_gatt_server_h server, bt_gatt_h gattHandle, int offset); + void WriteValueRequestedCb(const char * remoteAddress, int requestId, bt_gatt_server_h server, bt_gatt_h gattHandle, + bool responseNeeded, int offset, const char * value, int len); + void IndicationConfirmationCb(int result, const char * remoteAddress, bt_gatt_server_h server, bt_gatt_h characteristic, + bool completed); + void GattConnectionStateChangedCb(int result, bool connected, const char * remoteAddress); static void WriteCompletedCb(int result, bt_gatt_h gattHandle, void * userData); static void CharacteristicNotificationCb(bt_gatt_h characteristic, char * value, int len, void * userData); @@ -193,8 +193,8 @@ class BLEManagerImpl final : public BLEManager, void HandleC1CharWriteEvent(BLE_CONNECTION_OBJECT conId, const uint8_t * value, size_t len); void HandleRXCharChanged(BLE_CONNECTION_OBJECT conId, const uint8_t * value, size_t len); void HandleConnectionEvent(bool connected, const char * remoteAddress); - static void HandleConnectionTimeout(System::Layer * layer, void * data); - static bool IsDeviceChipPeripheral(BLE_CONNECTION_OBJECT conId); + static void HandleConnectionTimeout(System::Layer * layer, void * appState); + bool IsDeviceChipPeripheral(BLE_CONNECTION_OBJECT conId); // ==== BLE Adv & GATT Server. void NotifyBLEPeripheralGATTServerRegisterComplete(bool aIsSuccess, void * apAppstate); @@ -204,9 +204,11 @@ class BLEManagerImpl final : public BLEManager, void NotifyBLESubscribed(bool indicationsEnabled, BLE_CONNECTION_OBJECT conId); void NotifyBLEIndicationConfirmation(BLE_CONNECTION_OBJECT conId); void NotifyBLEWriteReceived(System::PacketBufferHandle & buf, BLE_CONNECTION_OBJECT conId); + static void HandleAdvertisingTimeout(chip::System::Layer *, void * appState); + AdvertisingIntervals GetAdvertisingIntervals() const; // ==== Connection. - static CHIP_ERROR ConnectChipThing(const char * userData); + CHIP_ERROR ConnectChipThing(const char * address); void NotifyBLEConnectionEstablished(BLE_CONNECTION_OBJECT conId, CHIP_ERROR error); void NotifyBLEDisconnection(BLE_CONNECTION_OBJECT conId, CHIP_ERROR error); void NotifyHandleNewConnection(BLE_CONNECTION_OBJECT conId); diff --git a/src/platform/Tizen/BlePlatformConfig.h b/src/platform/Tizen/BlePlatformConfig.h index 7877788afc5460..f31ac7105ef920 100644 --- a/src/platform/Tizen/BlePlatformConfig.h +++ b/src/platform/Tizen/BlePlatformConfig.h @@ -24,7 +24,17 @@ #pragma once +namespace chip { +namespace DeviceLayer { +namespace Internal { +class BLEConnection; +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip + // ==================== Platform Adaptations ==================== +#define BLE_CONNECTION_OBJECT chip::DeviceLayer::Internal::BLEConnection * +#define BLE_CONNECTION_UNINITIALIZED nullptr // ========== Platform-specific Configuration Overrides ========= diff --git a/src/platform/android/BUILD.gn b/src/platform/android/BUILD.gn index bd9f3cd8316220..a6e1fd6b524816 100644 --- a/src/platform/android/BUILD.gn +++ b/src/platform/android/BUILD.gn @@ -84,7 +84,10 @@ static_library("android") { source_set("inet") { sources = [ "InetInterfaceImpl.cpp" ] - deps = [ "${chip_root}/src/lib/support" ] + deps = [ + "${chip_root}/src/inet:impl_header", + "${chip_root}/src/lib/support", + ] } android_library("java") { diff --git a/src/platform/device.gni b/src/platform/device.gni index 6a4c5a05535513..aa81c50e4a5fcc 100644 --- a/src/platform/device.gni +++ b/src/platform/device.gni @@ -108,8 +108,8 @@ declare_args() { # Enable Subscription persistence / resumption for CI and supported platforms if (chip_device_platform == "darwin" || chip_device_platform == "linux" || - chip_device_platform == "esp32" || chip_device_platform == "fake" || - chip_device_platform == "efr32" || chip_device_platform == "SiWx917") { + chip_device_platform == "fake" || chip_device_platform == "efr32" || + chip_device_platform == "SiWx917") { chip_persist_subscriptions = true } else { chip_persist_subscriptions = false diff --git a/src/platform/mt793x/BLEManagerImpl.cpp b/src/platform/mt793x/BLEManagerImpl.cpp index d1f92e1b2977ac..f1ac9bfa707b88 100644 --- a/src/platform/mt793x/BLEManagerImpl.cpp +++ b/src/platform/mt793x/BLEManagerImpl.cpp @@ -656,7 +656,7 @@ void BLEManagerImpl::BleAdvTimeoutHandler(TimerHandle_t xTimer) else if (BLEMgrImpl().mFlags.Has(Flags::kAdvertising)) { // Advertisement time expired. Stop advertising - ChipLogDetail(DeviceLayer, "bleAdv Timeout : Stop advertissement"); + ChipLogDetail(DeviceLayer, "bleAdv Timeout : Stop advertisement"); BLEMgr().SetAdvertisingEnabled(false); } } diff --git a/src/platform/silabs/CHIPDevicePlatformConfig.h b/src/platform/silabs/CHIPDevicePlatformConfig.h index 12aadb24400691..fa3a50974f6a50 100644 --- a/src/platform/silabs/CHIPDevicePlatformConfig.h +++ b/src/platform/silabs/CHIPDevicePlatformConfig.h @@ -118,22 +118,6 @@ // ========== Platform-specific Configuration Overrides ========= -#ifndef CHIP_DEVICE_CONFIG_BLE_LL_TASK_PRIORITY -#define CHIP_DEVICE_CONFIG_BLE_LL_TASK_PRIORITY (configTIMER_TASK_PRIORITY - 1) -#endif // CHIP_DEVICE_CONFIG_BLE_LL_TASK_PRIORITY - -#ifndef CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY -#define CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY (CHIP_DEVICE_CONFIG_BLE_LL_TASK_PRIORITY - 1) -#endif // CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY - -#ifndef CHIP_DEVICE_CONFIG_BLE_APP_TASK_PRIORITY -#define CHIP_DEVICE_CONFIG_BLE_APP_TASK_PRIORITY (CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY - 1) -#endif // CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY - -#ifndef CHIP_DEVICE_CONFIG_BLE_APP_TASK_STACK_SIZE -#define CHIP_DEVICE_CONFIG_BLE_APP_TASK_STACK_SIZE 1536 -#endif // CHIP_DEVICE_CONFIG_BLE_APP_TASK_STACK_SIZE - #ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE #define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE (6 * 1024) #endif // CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE diff --git a/src/platform/silabs/efr32/ConfigurationManagerImpl.cpp b/src/platform/silabs/ConfigurationManagerImpl.cpp similarity index 97% rename from src/platform/silabs/efr32/ConfigurationManagerImpl.cpp rename to src/platform/silabs/ConfigurationManagerImpl.cpp index ed0aaad8e1d61f..a3e1778c11ac3f 100644 --- a/src/platform/silabs/efr32/ConfigurationManagerImpl.cpp +++ b/src/platform/silabs/ConfigurationManagerImpl.cpp @@ -19,18 +19,15 @@ /** * @file * Provides the implementation of the Device Layer ConfigurationManager object - * for EFR32 platforms using the Silicon Labs SDK. + * for Silabs platforms using the Silicon Labs SDK. */ /* this file behaves like a config.h, comes first */ -#include - -#include - #include #include +#include +#include #include - -#include "em_rmu.h" +#include #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION #include "wfx_host_events.h" @@ -55,12 +52,7 @@ CHIP_ERROR ConfigurationManagerImpl::Init() err = Internal::GenericConfigurationManagerImpl::Init(); SuccessOrExit(err); - // TODO: Initialize the global GroupKeyStore object here (#1626) - IncreaseBootCount(); - rebootCause = RMU_ResetCauseGet(); - RMU_ResetCauseClear(); - err = CHIP_NO_ERROR; exit: @@ -99,7 +91,9 @@ CHIP_ERROR ConfigurationManagerImpl::GetBootReason(uint32_t & bootReason) { // rebootCause is obtained at bootup. BootReasonType matterBootCause; -#if defined(_SILICON_LABS_32B_SERIES_1) + uint32_t rebootCause = Silabs::GetPlatform().GetRebootCause(); + +#if defined(_RMU_RSTCAUSE_MASK) if (rebootCause & RMU_RSTCAUSE_PORST || rebootCause & RMU_RSTCAUSE_EXTRST) // PowerOn or External pin reset { matterBootCause = BootReasonType::kPowerOnReboot; @@ -121,7 +115,7 @@ CHIP_ERROR ConfigurationManagerImpl::GetBootReason(uint32_t & bootReason) matterBootCause = BootReasonType::kUnspecified; } // Not tracked HARDWARE_WATCHDOG_RESET && SOFTWARE_UPDATE_COMPLETED -#elif defined(_SILICON_LABS_32B_SERIES_2) +#elif defined(_EMU_RSTCAUSE_MASK) if (rebootCause & EMU_RSTCAUSE_POR || rebootCause & EMU_RSTCAUSE_PIN) // PowerOn or External pin reset { matterBootCause = BootReasonType::kPowerOnReboot; diff --git a/src/platform/silabs/ConfigurationManagerImpl.h b/src/platform/silabs/ConfigurationManagerImpl.h index c025f51de40041..f34e37ed91bb52 100644 --- a/src/platform/silabs/ConfigurationManagerImpl.h +++ b/src/platform/silabs/ConfigurationManagerImpl.h @@ -73,7 +73,6 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp void RunConfigUnitTest(void) override; // ===== Private members reserved for use by this class only. - uint32_t rebootCause; static void DoFactoryReset(intptr_t arg); }; diff --git a/src/platform/silabs/SiWx917/BUILD.gn b/src/platform/silabs/SiWx917/BUILD.gn index 151c6e93bc5f40..c0efdd6eab6a97 100644 --- a/src/platform/silabs/SiWx917/BUILD.gn +++ b/src/platform/silabs/SiWx917/BUILD.gn @@ -39,6 +39,7 @@ static_library("SiWx917") { "${silabs_platform_dir}/CHIPDevicePlatformEvent.h", "${silabs_platform_dir}/CHIPMem-Platform.cpp", "${silabs_platform_dir}/CHIPPlatformConfig.h", + "${silabs_platform_dir}/ConfigurationManagerImpl.cpp", "${silabs_platform_dir}/ConfigurationManagerImpl.h", "${silabs_platform_dir}/ConnectivityManagerImpl.h", "${silabs_platform_dir}/DiagnosticDataProviderImpl.cpp", @@ -62,7 +63,6 @@ static_library("SiWx917") { "../rs911x/rsi_ble_config.h", "../rs911x/wfx_sl_ble_init.c", "../rs911x/wfx_sl_ble_init.h", - "ConfigurationManagerImpl.cpp", "PlatformManagerImpl.cpp", ] diff --git a/src/platform/silabs/SiWx917/ConfigurationManagerImpl.cpp b/src/platform/silabs/SiWx917/ConfigurationManagerImpl.cpp deleted file mode 100644 index f008545ddf6059..00000000000000 --- a/src/platform/silabs/SiWx917/ConfigurationManagerImpl.cpp +++ /dev/null @@ -1,315 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Nest Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Provides the implementation of the Device Layer ConfigurationManager object - * for SiWx917 platforms using the Silicon Labs SDK. - */ -/* this file behaves like a config.h, comes first */ -#include - -#include - -#include -#include -#include - -#include "core_cm4.h" - -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION -#include "wfx_host_events.h" -#endif - -namespace chip { -namespace DeviceLayer { - -using namespace ::chip::DeviceLayer::Internal; - -ConfigurationManagerImpl & ConfigurationManagerImpl::GetDefaultInstance() -{ - static ConfigurationManagerImpl sInstance; - return sInstance; -} - -CHIP_ERROR ConfigurationManagerImpl::Init() -{ - CHIP_ERROR err; - - // Initialize the generic implementation base class. - err = Internal::GenericConfigurationManagerImpl::Init(); - SuccessOrExit(err); - - // TODO: Initialize the global GroupKeyStore object here (#1626) - - IncreaseBootCount(); - // It is possible to configure the possible reset sources with RMU_ResetControl - // In this case, we keep Reset control at default setting - - err = CHIP_NO_ERROR; - -exit: - return err; -} - -bool ConfigurationManagerImpl::CanFactoryReset() -{ - // TODO: query the application to determine if factory reset is allowed. - return true; -} - -void ConfigurationManagerImpl::InitiateFactoryReset() -{ - PlatformMgr().ScheduleWork(DoFactoryReset); -} - -CHIP_ERROR ConfigurationManagerImpl::GetRebootCount(uint32_t & rebootCount) -{ - return SilabsConfig::ReadConfigValue(SilabsConfig::kConfigKey_BootCount, rebootCount); -} - -CHIP_ERROR ConfigurationManagerImpl::IncreaseBootCount(void) -{ - uint32_t bootCount = 0; - - if (SilabsConfig::ConfigValueExists(SilabsConfig::kConfigKey_BootCount)) - { - GetRebootCount(bootCount); - } - - return SilabsConfig::WriteConfigValue(SilabsConfig::kConfigKey_BootCount, bootCount + 1); -} - -CHIP_ERROR ConfigurationManagerImpl::GetBootReason(uint32_t & bootReason) -{ - // rebootCause is obtained at bootup. - BootReasonType matterBootCause; -#if defined(_SILICON_LABS_32B_SERIES_1) - if (rebootCause & RMU_RSTCAUSE_PORST || rebootCause & RMU_RSTCAUSE_EXTRST) // PowerOn or External pin reset - { - matterBootCause = BootReasonType::kPowerOnReboot; - } - else if (rebootCause & RMU_RSTCAUSE_AVDDBOD || rebootCause & RMU_RSTCAUSE_DVDDBOD || rebootCause & RMU_RSTCAUSE_DECBOD) - { - matterBootCause = BootReasonType::kBrownOutReset; - } - else if (rebootCause & RMU_RSTCAUSE_SYSREQRST) - { - matterBootCause = BootReasonType::kSoftwareReset; - } - else if (rebootCause & RMU_RSTCAUSE_WDOGRST) - { - matterBootCause = BootReasonType::kSoftwareWatchdogReset; - } - else - { - matterBootCause = BootReasonType::kUnspecified; - } - // Not tracked HARDWARE_WATCHDOG_RESET && SOFTWARE_UPDATE_COMPLETED -#elif defined(_SILICON_LABS_32B_SERIES_2) - if (rebootCause & EMU_RSTCAUSE_POR || rebootCause & EMU_RSTCAUSE_PIN) // PowerOn or External pin reset - { - matterBootCause = BootReasonType::kPowerOnReboot; - } - else if (rebootCause & EMU_RSTCAUSE_AVDDBOD || rebootCause & EMU_RSTCAUSE_DVDDBOD || rebootCause & EMU_RSTCAUSE_DECBOD || - rebootCause & EMU_RSTCAUSE_VREGIN || rebootCause & EMU_RSTCAUSE_IOVDD0BOD || rebootCause & EMU_RSTCAUSE_DVDDLEBOD) - { - matterBootCause = BootReasonType::kBrownOutReset; - } - else if (rebootCause & EMU_RSTCAUSE_SYSREQ) - { - matterBootCause = BootReasonType::kSoftwareReset; - } - else if (rebootCause & EMU_RSTCAUSE_WDOG0 || rebootCause & EMU_RSTCAUSE_WDOG1) - { - matterBootCause = BootReasonType::kSoftwareWatchdogReset; - } - else - { - matterBootCause = BootReasonType::kUnspecified; - } - // Not tracked HARDWARE_WATCHDOG_RESET && SOFTWARE_UPDATE_COMPLETED -#else - matterBootCause = BootReasonType::kUnspecified; -#endif - - bootReason = to_underlying(matterBootCause); - return CHIP_NO_ERROR; -} - -CHIP_ERROR ConfigurationManagerImpl::GetTotalOperationalHours(uint32_t & totalOperationalHours) -{ - if (!SilabsConfig::ConfigValueExists(SilabsConfig::kConfigKey_TotalOperationalHours)) - { - totalOperationalHours = 0; - return CHIP_NO_ERROR; - } - - return SilabsConfig::ReadConfigValue(SilabsConfig::kConfigKey_TotalOperationalHours, totalOperationalHours); -} - -CHIP_ERROR ConfigurationManagerImpl::StoreTotalOperationalHours(uint32_t totalOperationalHours) -{ - return SilabsConfig::WriteConfigValue(SilabsConfig::kConfigKey_TotalOperationalHours, totalOperationalHours); -} - -CHIP_ERROR ConfigurationManagerImpl::ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key persistedStorageKey, - uint32_t & value) -{ - // This method reads CHIP Persisted Counter type nvm3 objects. - // (where persistedStorageKey represents an index to the counter). - CHIP_ERROR err; - - err = SilabsConfig::ReadConfigValueCounter(persistedStorageKey, value); - if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) - { - err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; - } - SuccessOrExit(err); - -exit: - return err; -} - -CHIP_ERROR ConfigurationManagerImpl::WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key persistedStorageKey, - uint32_t value) -{ - // This method reads CHIP Persisted Counter type nvm3 objects. - // (where persistedStorageKey represents an index to the counter). - CHIP_ERROR err; - - err = SilabsConfig::WriteConfigValueCounter(persistedStorageKey, value); - if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) - { - err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; - } - SuccessOrExit(err); - -exit: - return err; -} - -CHIP_ERROR ConfigurationManagerImpl::ReadConfigValue(Key key, bool & val) -{ - return SilabsConfig::ReadConfigValue(key, val); -} - -CHIP_ERROR ConfigurationManagerImpl::ReadConfigValue(Key key, uint32_t & val) -{ - return SilabsConfig::ReadConfigValue(key, val); -} - -CHIP_ERROR ConfigurationManagerImpl::ReadConfigValue(Key key, uint64_t & val) -{ - return SilabsConfig::ReadConfigValue(key, val); -} - -CHIP_ERROR ConfigurationManagerImpl::ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen) -{ - return SilabsConfig::ReadConfigValueStr(key, buf, bufSize, outLen); -} - -CHIP_ERROR ConfigurationManagerImpl::ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen) -{ - return SilabsConfig::ReadConfigValueBin(key, buf, bufSize, outLen); -} - -CHIP_ERROR ConfigurationManagerImpl::WriteConfigValue(Key key, bool val) -{ - return SilabsConfig::WriteConfigValue(key, val); -} - -CHIP_ERROR ConfigurationManagerImpl::WriteConfigValue(Key key, uint32_t val) -{ - return SilabsConfig::WriteConfigValue(key, val); -} - -CHIP_ERROR ConfigurationManagerImpl::WriteConfigValue(Key key, uint64_t val) -{ - return SilabsConfig::WriteConfigValue(key, val); -} - -CHIP_ERROR ConfigurationManagerImpl::WriteConfigValueStr(Key key, const char * str) -{ - return SilabsConfig::WriteConfigValueStr(key, str); -} - -CHIP_ERROR ConfigurationManagerImpl::WriteConfigValueStr(Key key, const char * str, size_t strLen) -{ - return SilabsConfig::WriteConfigValueStr(key, str, strLen); -} - -CHIP_ERROR ConfigurationManagerImpl::WriteConfigValueBin(Key key, const uint8_t * data, size_t dataLen) -{ - return SilabsConfig::WriteConfigValueBin(key, data, dataLen); -} - -void ConfigurationManagerImpl::RunConfigUnitTest(void) -{ - SilabsConfig::RunConfigUnitTest(); -} - -void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) -{ - CHIP_ERROR err; - - ChipLogProgress(DeviceLayer, "Performing factory reset"); - - err = SilabsConfig::FactoryResetConfig(); - if (err != CHIP_NO_ERROR) - { - ChipLogError(DeviceLayer, "FactoryResetConfig() failed: %s", chip::ErrorStr(err)); - } - -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - - ChipLogProgress(DeviceLayer, "Clearing Thread provision"); - ThreadStackMgr().ErasePersistentInfo(); - -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD - - PersistedStorage::KeyValueStoreMgrImpl().ErasePartition(); - -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - ChipLogProgress(DeviceLayer, "Clearing WiFi provision"); - wfx_clear_wifi_provision(); -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - - // Restart the system. - ChipLogProgress(DeviceLayer, "System restarting"); - NVIC_SystemReset(); -} - -#ifdef SL_WIFI -CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) -{ - sl_wfx_mac_address_t macaddr; - wfx_get_wifi_mac_addr(SL_WFX_STA_INTERFACE, &macaddr); - memcpy(buf, &macaddr.octet[0], sizeof(macaddr.octet)); - - return CHIP_NO_ERROR; -} -#endif - -ConfigurationManager & ConfigurationMgrImpl() -{ - return ConfigurationManagerImpl::GetDefaultInstance(); -} - -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/silabs/efr32/BLEManagerImpl.cpp b/src/platform/silabs/efr32/BLEManagerImpl.cpp index 193d15bb018d6b..bd4aee39cf8160 100644 --- a/src/platform/silabs/efr32/BLEManagerImpl.cpp +++ b/src/platform/silabs/efr32/BLEManagerImpl.cpp @@ -545,7 +545,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) } else { - ChipLogDetail(DeviceLayer, "Start BLE advertissement"); + ChipLogDetail(DeviceLayer, "Start BLE advertisement"); } const uint8_t kResolvableRandomAddrType = 2; // Private resolvable random address type @@ -976,7 +976,7 @@ void BLEManagerImpl::BleAdvTimeoutHandler(TimerHandle_t xTimer) { if (BLEMgrImpl().mFlags.Has(Flags::kFastAdvertisingEnabled)) { - ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start slow advertissment"); + ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start slow advertisement"); BLEMgrImpl().mFlags.Set(Flags::kAdvertising); BLEMgr().SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising); #if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING @@ -987,7 +987,7 @@ void BLEManagerImpl::BleAdvTimeoutHandler(TimerHandle_t xTimer) #if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING else { - ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start extended advertisment"); + ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start extended advertisement"); BLEMgrImpl().mFlags.Set(Flags::kAdvertising); BLEMgrImpl().mFlags.Set(Flags::kExtAdvertisingEnabled); BLEMgr().SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising); diff --git a/src/platform/silabs/efr32/BUILD.gn b/src/platform/silabs/efr32/BUILD.gn index e244ad178a9848..83198d1436ebdc 100644 --- a/src/platform/silabs/efr32/BUILD.gn +++ b/src/platform/silabs/efr32/BUILD.gn @@ -44,6 +44,7 @@ static_library("efr32") { "${silabs_platform_dir}/CHIPDevicePlatformEvent.h", "${silabs_platform_dir}/CHIPMem-Platform.cpp", "${silabs_platform_dir}/CHIPPlatformConfig.h", + "${silabs_platform_dir}/ConfigurationManagerImpl.cpp", "${silabs_platform_dir}/ConfigurationManagerImpl.h", "${silabs_platform_dir}/ConnectivityManagerImpl.h", "${silabs_platform_dir}/DiagnosticDataProviderImpl.cpp", @@ -62,7 +63,6 @@ static_library("efr32") { "${silabs_platform_dir}/platformAbstraction/SilabsPlatformBase.h", "../../FreeRTOS/SystemTimeSupport.cpp", "../../SingletonConfigurationManager.cpp", - "ConfigurationManagerImpl.cpp", "PlatformManagerImpl.cpp", ] diff --git a/src/platform/silabs/platformAbstraction/GsdkSpam.cpp b/src/platform/silabs/platformAbstraction/GsdkSpam.cpp index 49f8ed48b17ad9..dda1b7e0e19dac 100644 --- a/src/platform/silabs/platformAbstraction/GsdkSpam.cpp +++ b/src/platform/silabs/platformAbstraction/GsdkSpam.cpp @@ -17,6 +17,7 @@ #include +#include "em_rmu.h" #include "sl_system_kernel.h" #ifdef ENABLE_WSTK_LEDS @@ -69,6 +70,10 @@ CHIP_ERROR SilabsPlatform::Init(void) { sl_system_init(); + mRebootCause = RMU_ResetCauseGet(); + // Clear register so it does accumualate the causes of each reset + RMU_ResetCauseClear(); + #if CHIP_ENABLE_OPENTHREAD sl_ot_sys_init(); #endif diff --git a/src/platform/silabs/platformAbstraction/SilabsPlatform.h b/src/platform/silabs/platformAbstraction/SilabsPlatform.h index 4e5e4b2ba57396..4c42a79996b3f0 100644 --- a/src/platform/silabs/platformAbstraction/SilabsPlatform.h +++ b/src/platform/silabs/platformAbstraction/SilabsPlatform.h @@ -49,6 +49,7 @@ class SilabsPlatform : virtual public SilabsPlatformAbstractionBase #endif inline void SetButtonsCb(SilabsButtonCb callback) override { mButtonCallback = callback; } + inline uint32_t GetRebootCause() { return mRebootCause; } static SilabsButtonCb mButtonCallback; @@ -64,6 +65,7 @@ class SilabsPlatform : virtual public SilabsPlatformAbstractionBase SilabsPlatform(){}; virtual ~SilabsPlatform() = default; + uint32_t mRebootCause = 0; static SilabsPlatform sSilabsPlatformAbstractionManager; }; diff --git a/src/platform/silabs/platformAbstraction/SilabsPlatformBase.h b/src/platform/silabs/platformAbstraction/SilabsPlatformBase.h index f5630ddbb0c0b3..fa387228ab2885 100644 --- a/src/platform/silabs/platformAbstraction/SilabsPlatformBase.h +++ b/src/platform/silabs/platformAbstraction/SilabsPlatformBase.h @@ -35,6 +35,7 @@ class SilabsPlatformAbstractionBase virtual CHIP_ERROR InitLCD() { return CHIP_ERROR_NOT_IMPLEMENTED; } virtual CHIP_ERROR SetGPIO(uint32_t port, uint32_t pin, bool state) { return CHIP_ERROR_NOT_IMPLEMENTED; } virtual bool GetGPIO(uint32_t port, uint32_t pin) { return false; } + virtual uint32_t GetRebootCause() = 0; // Scheduler virtual void StartScheduler(void) = 0; diff --git a/src/platform/silabs/rs911x/BLEManagerImpl.cpp b/src/platform/silabs/rs911x/BLEManagerImpl.cpp index a32d46b30f2715..d7e79f59dc8318 100644 --- a/src/platform/silabs/rs911x/BLEManagerImpl.cpp +++ b/src/platform/silabs/rs911x/BLEManagerImpl.cpp @@ -672,7 +672,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) } else { - ChipLogDetail(DeviceLayer, "Start BLE advertissement"); + ChipLogDetail(DeviceLayer, "Start BLE advertisement"); } if (!(mFlags.Has(Flags::kAdvertising))) @@ -1072,7 +1072,7 @@ void BLEManagerImpl::BleAdvTimeoutHandler(TimerHandle_t xTimer) { if (BLEMgrImpl().mFlags.Has(Flags::kFastAdvertisingEnabled)) { - ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start slow advertissment"); + ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start slow advertisement"); BLEMgr().SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising); } } diff --git a/src/platform/stm32/BLEManagerImpl.cpp b/src/platform/stm32/BLEManagerImpl.cpp index 1cffd11b783487..60863a2da6a698 100644 --- a/src/platform/stm32/BLEManagerImpl.cpp +++ b/src/platform/stm32/BLEManagerImpl.cpp @@ -702,14 +702,14 @@ void BLEManagerImpl::BleAdvTimeoutHandler(TimerHandle_t xTimer) if (BLEMgrImpl().mFlags.Has(Flags::kFastAdvertisingEnabled)) { /* Stop advertising and defer restart for when stop confirmation is received from the stack */ - ChipLogDetail(DeviceLayer, "bleAdv Timeout : Stop advertissement"); + ChipLogDetail(DeviceLayer, "bleAdv Timeout : Stop advertisement"); sInstance.StopAdvertising(); sInstance.mFlags.Set(Flags::kRestartAdvertising); } else if (BLEMgrImpl().mFlags.Has(Flags::kAdvertising)) { // Advertisement time expired. Stop advertising - ChipLogDetail(DeviceLayer, "bleAdv Timeout : Stop advertissement"); + ChipLogDetail(DeviceLayer, "bleAdv Timeout : Stop advertisement"); BLEMgr().SetAdvertisingEnabled(false); } } diff --git a/src/platform/telink/1m_flash.overlay b/src/platform/telink/1m_flash.overlay index 0b1fd1b2213c23..3a05c3cd43b8d0 100644 --- a/src/platform/telink/1m_flash.overlay +++ b/src/platform/telink/1m_flash.overlay @@ -21,15 +21,15 @@ }; slot0_partition: partition@19000 { label = "image-0"; - reg = <0x19000 0xda000>; + reg = <0x19000 0xd9000>; }; - factory_partition: partition@f3000 { + factory_partition: partition@f2000 { label = "factory-data"; - reg = <0xf3000 0x1000>; + reg = <0xf2000 0x1000>; }; - storage_partition: partition@f4000 { + storage_partition: partition@f3000 { label = "storage"; - reg = <0xf4000 0xa000>; + reg = <0xf3000 0xb000>; }; vendor_partition: partition@fe000 { label = "vendor-data"; diff --git a/src/platform/telink/2m_flash.overlay b/src/platform/telink/2m_flash.overlay index 95f1a749057436..09e60eca748805 100644 --- a/src/platform/telink/2m_flash.overlay +++ b/src/platform/telink/2m_flash.overlay @@ -21,19 +21,19 @@ }; slot0_partition: partition@19000 { label = "image-0"; - reg = <0x19000 0xed000>; + reg = <0x19000 0xec000>; }; - factory_partition: partition@106000{ + factory_partition: partition@105000 { label = "factory-data"; - reg = <0x106000 0x1000>; + reg = <0x105000 0x1000>; }; - storage_partition: partition@107000 { + storage_partition: partition@106000 { label = "storage"; - reg = <0x107000 0xa000>; + reg = <0x106000 0xc000>; }; - slot1_partition: partition@111000 { + slot1_partition: partition@112000 { label = "image-1"; - reg = <0x111000 0xed000>; + reg = <0x112000 0xec000>; }; vendor_partition: partition@1fe000 { label = "vendor-data"; diff --git a/src/platform/telink/4m_flash.overlay b/src/platform/telink/4m_flash.overlay index e22c007e0bc235..657684d8fc5672 100644 --- a/src/platform/telink/4m_flash.overlay +++ b/src/platform/telink/4m_flash.overlay @@ -21,19 +21,19 @@ }; slot0_partition: partition@19000 { label = "image-0"; - reg = <0x19000 0x1ed000>; + reg = <0x19000 0x1ec000>; }; - factory_partition: partition@206000 { + factory_partition: partition@205000 { label = "factory-data"; - reg = <0x206000 0x1000>; + reg = <0x205000 0x1000>; }; - storage_partition: partition@207000 { + storage_partition: partition@206000 { label = "storage"; - reg = <0x207000 0xa000>; + reg = <0x206000 0xc000>; }; - slot1_partition: partition@211000 { + slot1_partition: partition@212000 { label = "image-1"; - reg = <0x211000 0x1ed000>; + reg = <0x212000 0x1ec000>; }; vendor_partition: partition@3fe000 { label = "vendor-data"; diff --git a/src/platform/telink/CHIPDevicePlatformConfig.h b/src/platform/telink/CHIPDevicePlatformConfig.h index 07967f8b273e4f..245b802f9a88cd 100644 --- a/src/platform/telink/CHIPDevicePlatformConfig.h +++ b/src/platform/telink/CHIPDevicePlatformConfig.h @@ -200,11 +200,7 @@ #endif // CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY #ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE -#ifdef CONFIG_PM -#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 4864 -#else -#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 8192 -#endif +#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE CONFIG_CHIP_TASK_STACK_SIZE #endif // CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0 diff --git a/src/platform/webos/ThreadStackManagerImpl.cpp b/src/platform/webos/ThreadStackManagerImpl.cpp index 79ad2e408857fb..3022519eb45fff 100644 --- a/src/platform/webos/ThreadStackManagerImpl.cpp +++ b/src/platform/webos/ThreadStackManagerImpl.cpp @@ -27,10 +27,6 @@ #include -#include -#include -#include - using namespace ::chip::app; using namespace ::chip::app::Clusters; using namespace chip::DeviceLayer::NetworkCommissioning; diff --git a/src/protocols/bdx/BUILD.gn b/src/protocols/bdx/BUILD.gn index c78b91e9d907a8..17f18826ebe474 100644 --- a/src/protocols/bdx/BUILD.gn +++ b/src/protocols/bdx/BUILD.gn @@ -25,10 +25,12 @@ static_library("bdx") { "BdxTransferProxyDiagnosticLog.h", "BdxTransferServer.cpp", "BdxTransferServer.h", + "BdxTransferServerDelegate.h", "BdxTransferSession.cpp", "BdxTransferSession.h", "BdxUri.cpp", "BdxUri.h", + "DiagnosticLogs.h", "StatusCode.cpp", "StatusCode.h", "TransferFacilitator.cpp", diff --git a/src/protocols/bdx/tests/BUILD.gn b/src/protocols/bdx/tests/BUILD.gn index 7a518a3f78a7ac..59d5f01d35a9c1 100644 --- a/src/protocols/bdx/tests/BUILD.gn +++ b/src/protocols/bdx/tests/BUILD.gn @@ -14,7 +14,6 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") -import("//build_overrides/nlio.gni") import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip/chip_test_suite.gni") @@ -33,7 +32,6 @@ chip_test_suite_using_nltest("tests") { "${chip_root}/src/lib/support", "${chip_root}/src/lib/support:testing_nlunit", "${chip_root}/src/protocols/bdx", - "${nlio_root}:nlio", "${nlunit_test_root}:nlunit-test", ] diff --git a/src/protocols/secure_channel/BUILD.gn b/src/protocols/secure_channel/BUILD.gn index 2061b04e82b6d5..dcae65a6f4d271 100644 --- a/src/protocols/secure_channel/BUILD.gn +++ b/src/protocols/secure_channel/BUILD.gn @@ -1,5 +1,30 @@ import("//build_overrides/chip.gni") +source_set("check-in-counter") { + sources = [ "CheckInCounter.h" ] + + deps = [ + "${chip_root}/src/crypto", + "${chip_root}/src/lib/support", + ] +} + +source_set("check-in-message") { + sources = [ + "CheckinMessage.cpp", + "CheckinMessage.h", + ] + + public_deps = [ ":check-in-counter" ] + + deps = [ + ":type_definitions", + "${chip_root}/src/crypto", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + ] +} + static_library("type_definitions") { output_name = "libSecureChannelTypes" @@ -12,6 +37,7 @@ static_library("type_definitions") { cflags = [ "-Wconversion" ] public_deps = [ + "${chip_root}/src/lib/support:type-traits", "${chip_root}/src/protocols:type_definitions", "${chip_root}/src/system", ] @@ -29,8 +55,6 @@ static_library("secure_channel") { "CASEServer.h", "CASESession.cpp", "CASESession.h", - "CheckinMessage.cpp", - "CheckinMessage.h", "DefaultSessionResumptionStorage.cpp", "DefaultSessionResumptionStorage.h", "PASESession.cpp", @@ -51,10 +75,12 @@ static_library("secure_channel") { cflags = [ "-Wconversion" ] public_deps = [ + ":check-in-message", ":type_definitions", "${chip_root}/src/crypto", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", + "${chip_root}/src/lib/support:type-traits", "${chip_root}/src/messaging", "${chip_root}/src/system", "${chip_root}/src/tracing", diff --git a/src/protocols/secure_channel/CASEServer.cpp b/src/protocols/secure_channel/CASEServer.cpp index d701d8c568c584..2ad196a31b9461 100644 --- a/src/protocols/secure_channel/CASEServer.cpp +++ b/src/protocols/secure_channel/CASEServer.cpp @@ -183,6 +183,7 @@ void CASEServer::OnSessionEstablishmentError(CHIP_ERROR err) MATTER_TRACE_SCOPE("OnSessionEstablishmentError", "CASEServer"); ChipLogError(Inet, "CASE Session establishment failed: %" CHIP_ERROR_FORMAT, err.Format()); + MATTER_TRACE_SCOPE("CASEFail", "CASESession"); PrepareForSessionEstablishment(); } diff --git a/src/protocols/secure_channel/CASESession.cpp b/src/protocols/secure_channel/CASESession.cpp index 8573d1565686fe..ee8feaefb5f93d 100644 --- a/src/protocols/secure_channel/CASESession.cpp +++ b/src/protocols/secure_channel/CASESession.cpp @@ -37,11 +37,11 @@ #include #include #include +#include #include #include #include #include -#include #include #include #include @@ -552,6 +552,7 @@ void CASESession::OnResponseTimeout(ExchangeContext * ec) VerifyOrReturn(mExchangeCtxt == ec, ChipLogError(SecureChannel, "CASESession::OnResponseTimeout exchange doesn't match")); ChipLogError(SecureChannel, "CASESession timed out while waiting for a response from the peer. Current state was %u", to_underlying(mState)); + MATTER_TRACE_COUNTER("CASETimeout"); // Discard the exchange so that Clear() doesn't try aborting it. The // exchange will handle that. DiscardExchange(); @@ -844,6 +845,7 @@ CHIP_ERROR CASESession::HandleSigma1(System::PacketBufferHandle && msg) ByteSpan initiatorRandom; ChipLogProgress(SecureChannel, "Received Sigma1 msg"); + MATTER_TRACE_COUNTER("Sigma1"); bool sessionResumptionRequested = false; ByteSpan resumptionId; @@ -1100,6 +1102,7 @@ CHIP_ERROR CASESession::SendSigma2() mState = State::kSentSigma2; ChipLogProgress(SecureChannel, "Sent Sigma2 msg"); + MATTER_TRACE_COUNTER("Sigma2"); return CHIP_NO_ERROR; } @@ -1116,6 +1119,7 @@ CHIP_ERROR CASESession::HandleSigma2Resume(System::PacketBufferHandle && msg) uint32_t decodeTagIdSeq = 0; ChipLogDetail(SecureChannel, "Received Sigma2Resume msg"); + MATTER_TRACE_COUNTER("Sigma2Resume"); uint8_t sigma2ResumeMIC[CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES]; @@ -1585,6 +1589,7 @@ CHIP_ERROR CASESession::HandleSigma3a(System::PacketBufferHandle && msg) uint8_t msg_salt[kIPKSize + kSHA256_Hash_Length]; ChipLogProgress(SecureChannel, "Received Sigma3 msg"); + MATTER_TRACE_COUNTER("Sigma3"); auto helper = WorkHelper::Create(*this, &HandleSigma3b, &CASESession::HandleSigma3c); VerifyOrExit(helper, err = CHIP_ERROR_NO_MEMORY); diff --git a/src/protocols/secure_channel/CheckInCounter.h b/src/protocols/secure_channel/CheckInCounter.h new file mode 100644 index 00000000000000..257114b8a1e971 --- /dev/null +++ b/src/protocols/secure_channel/CheckInCounter.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 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. + */ + +/** + * @brief The file implements the Matter Check-In counter + * + */ +#pragma once + +#include +#include + +namespace chip { +namespace Protocols { +namespace SecureChannel { + +/** + * @brief + * + */ +class CheckInCounter : public PersistedCounter +{ +public: + CheckInCounter(){}; + ~CheckInCounter() override{}; + + /** + * @brief Returns the next Check-In counter Value to use + * + * @return uint32_t Check-in Counter value to use + */ + inline uint32_t GetNextCheckInCounterValue() { return (mCounterValue + 1); }; + +private: + /** + * @brief Get the Initial Counter Value for the Check-In counter + * Initial value is randomized for the Check-In counter + * + * @return uint32_t random value + */ + inline uint32_t GetInitialCounterValue() override { return chip::Crypto::GetRandU32(); } +}; + +} // namespace SecureChannel +} // namespace Protocols +} // namespace chip diff --git a/src/protocols/secure_channel/Constants.h b/src/protocols/secure_channel/Constants.h index e2415ca6089353..231e99b33c1763 100644 --- a/src/protocols/secure_channel/Constants.h +++ b/src/protocols/secure_channel/Constants.h @@ -129,7 +129,7 @@ struct MessageTypeTraits static auto GetTypeToNameTable() { - static const std::array typeToNameTable = { + static const std::array typeToNameTable = { { { SecureChannel::MsgType::MsgCounterSyncReq, "MsgCounterSyncReq" }, { SecureChannel::MsgType::MsgCounterSyncRsp, "MsgCounterSyncRsp" }, @@ -144,6 +144,7 @@ struct MessageTypeTraits { SecureChannel::MsgType::CASE_Sigma3, "CASE_Sigma3" }, { SecureChannel::MsgType::CASE_Sigma2Resume, "CASE_Sigma2Resume" }, { SecureChannel::MsgType::StatusReport, "StatusReport" }, + { SecureChannel::MsgType::ICD_CheckIn, "ICD_CheckInMessage" }, }, }; diff --git a/src/protocols/secure_channel/PASESession.cpp b/src/protocols/secure_channel/PASESession.cpp index 67da1d103ebf83..95fb9c89c7432e 100644 --- a/src/protocols/secure_channel/PASESession.cpp +++ b/src/protocols/secure_channel/PASESession.cpp @@ -39,9 +39,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -251,6 +251,7 @@ void PASESession::OnResponseTimeout(ExchangeContext * ec) // If we were waiting for something, mNextExpectedMsg had better have a value. ChipLogError(SecureChannel, "PASESession timed out while waiting for a response from the peer. Expected message type was %u", to_underlying(mNextExpectedMsg.Value())); + MATTER_TRACE_COUNTER("PASETimeout"); // Discard the exchange so that Clear() doesn't try closing it. The // exchange will handle that. DiscardExchange(); @@ -572,6 +573,7 @@ CHIP_ERROR PASESession::HandleMsg1_and_SendMsg2(System::PacketBufferHandle && ms size_t verifier_len = kMAX_Hash_Length; ChipLogDetail(SecureChannel, "Received spake2p msg1"); + MATTER_TRACE_SCOPE("Pake1", "PASESession"); System::PacketBufferTLVReader tlvReader; TLV::TLVType containerType = TLV::kTLVType_Structure; @@ -620,6 +622,7 @@ CHIP_ERROR PASESession::HandleMsg1_and_SendMsg2(System::PacketBufferHandle && ms } ChipLogDetail(SecureChannel, "Sent spake2p msg2"); + MATTER_TRACE_COUNTER("Pake2"); exit: @@ -711,6 +714,7 @@ CHIP_ERROR PASESession::HandleMsg3(System::PacketBufferHandle && msg) CHIP_ERROR err = CHIP_NO_ERROR; ChipLogDetail(SecureChannel, "Received spake2p msg3"); + MATTER_TRACE_COUNTER("Pake3"); mNextExpectedMsg.ClearValue(); @@ -871,6 +875,7 @@ CHIP_ERROR PASESession::OnMessageReceived(ExchangeContext * exchange, const Payl DiscardExchange(); Clear(); ChipLogError(SecureChannel, "Failed during PASE session setup: %" CHIP_ERROR_FORMAT, err.Format()); + MATTER_TRACE_COUNTER("PASEFail"); // Do this last in case the delegate frees us. NotifySessionEstablishmentError(err); } diff --git a/src/protocols/secure_channel/PairingSession.h b/src/protocols/secure_channel/PairingSession.h index ffbb6d9966485d..e8849822de57e1 100644 --- a/src/protocols/secure_channel/PairingSession.h +++ b/src/protocols/secure_channel/PairingSession.h @@ -28,9 +28,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/src/protocols/secure_channel/tests/BUILD.gn b/src/protocols/secure_channel/tests/BUILD.gn index fe3cafe7f0d4fb..9a0ec760950d3f 100644 --- a/src/protocols/secure_channel/tests/BUILD.gn +++ b/src/protocols/secure_channel/tests/BUILD.gn @@ -1,6 +1,5 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") -import("//build_overrides/nlio.gni") import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip/chip_test_suite.gni") import("${chip_root}/src/app/icd/icd.gni") @@ -30,12 +29,12 @@ chip_test_suite_using_nltest("tests") { "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", "${chip_root}/src/lib/support:test_utils", + "${chip_root}/src/lib/support:testing", "${chip_root}/src/lib/support:testing_nlunit", "${chip_root}/src/messaging/tests:helpers", "${chip_root}/src/protocols", "${chip_root}/src/protocols/secure_channel", "${chip_root}/src/transport/raw/tests:helpers", - "${nlio_root}:nlio", "${nlunit_test_root}:nlunit-test", ] diff --git a/src/protocols/user_directed_commissioning/tests/BUILD.gn b/src/protocols/user_directed_commissioning/tests/BUILD.gn index dc33a2cf9d23a7..f536273f2e28ce 100644 --- a/src/protocols/user_directed_commissioning/tests/BUILD.gn +++ b/src/protocols/user_directed_commissioning/tests/BUILD.gn @@ -12,7 +12,6 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") -import("//build_overrides/nlio.gni") import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip/chip_test_suite.gni") @@ -27,7 +26,6 @@ chip_test_suite_using_nltest("tests") { "${chip_root}/src/lib/support", "${chip_root}/src/lib/support:testing_nlunit", "${chip_root}/src/protocols", - "${nlio_root}:nlio", "${nlunit_test_root}:nlunit-test", ] diff --git a/src/python_testing/TC_AccessChecker.py b/src/python_testing/TC_AccessChecker.py index f340f94fd4be17..6da413c99c6da3 100644 --- a/src/python_testing/TC_AccessChecker.py +++ b/src/python_testing/TC_AccessChecker.py @@ -62,6 +62,12 @@ async def setup_class(self): self.TH2_nodeid = self.matter_test_config.controller_node_id + 1 self.TH2 = fabric_admin.NewController(nodeId=self.TH2_nodeid) + # Both the tests in this suite are potentially long-running if there are a large number of attributes on the DUT + # and the network is slow. Set the default to 3 minutes to account for this. + @property + def default_timeout(self) -> int: + return 180 + @async_test_body async def setup_test(self): super().setup_test() diff --git a/src/python_testing/TC_IDM_1_4.py b/src/python_testing/TC_IDM_1_4.py index 04dfdf12c7bf0a..86e49bb3523f42 100644 --- a/src/python_testing/TC_IDM_1_4.py +++ b/src/python_testing/TC_IDM_1_4.py @@ -146,7 +146,7 @@ async def steps_3_to_9(self, dummy_value): invoke_request_2 = Clusters.Command.InvokeRequestInfo(endpoint, command) commandRefsOverride = [1, 1] try: - result = await dev_ctrl.TestOnlySendBatchCommands(dut_node_id, [invoke_request_1, invoke_request_2], commandRefsOverride=commandRefsOverride) + await dev_ctrl.TestOnlySendBatchCommands(dut_node_id, [invoke_request_1, invoke_request_2], commandRefsOverride=commandRefsOverride) asserts.fail("Unexpected success return after sending two unique commands with identical CommandRef in the InvokeRequest") except InteractionModelError as e: asserts.assert_equal(e.status, Status.InvalidAction, @@ -216,7 +216,7 @@ async def steps_3_to_9(self, dummy_value): # receiving a path-specific response to the same command, with the TimedRequestMessage sent before # the InvokeRequestMessage. try: - result = await dev_ctrl.TestOnlySendBatchCommands(dut_node_id, [invoke_request_1, invoke_request_2], suppressTimedRequestMessage=True) + await dev_ctrl.TestOnlySendBatchCommands(dut_node_id, [invoke_request_1, invoke_request_2], suppressTimedRequestMessage=True) asserts.fail("Unexpected success call to sending Batch command when non-path specific error expected") except InteractionModelError as e: asserts.assert_equal(e.status, Status.TimedRequestMismatch, diff --git a/src/python_testing/TC_TestEventTrigger.py b/src/python_testing/TC_TestEventTrigger.py index a27e2f78760879..b11f115016813a 100644 --- a/src/python_testing/TC_TestEventTrigger.py +++ b/src/python_testing/TC_TestEventTrigger.py @@ -15,6 +15,8 @@ # limitations under the License. # +import logging + import chip.clusters as Clusters from chip.interaction_model import InteractionModelError from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main @@ -110,6 +112,104 @@ async def test_correct_key_invalid_code(self): ) ) + @async_test_body + async def test_multiple_command_request_feature_present_if_needed(self): + dev_ctrl = self.default_controller + test_event_triggers_enabled = await self.read_single_attribute( + dev_ctrl, + self.dut_node_id, + endpoint=0, + attribute=Clusters.GeneralDiagnostics.Attributes.TestEventTriggersEnabled + ) + asserts.assert_true(test_event_triggers_enabled, "This test expects Test Event Triggers are Enabled") + + max_paths_per_invoke = await self.read_single_attribute(self.default_controller, node_id=self.dut_node_id, endpoint=0, attribute=Clusters.BasicInformation.Attributes.MaxPathsPerInvoke) + feature_map = await self.read_single_attribute(self.default_controller, node_id=self.dut_node_id, endpoint=0, attribute=Clusters.GeneralDiagnostics.Attributes.FeatureMap) + accepted_commands = await self.read_single_attribute(self.default_controller, node_id=self.dut_node_id, endpoint=0, attribute=Clusters.GeneralDiagnostics.Attributes.AcceptedCommandList) + generated_commands = await self.read_single_attribute(self.default_controller, node_id=self.dut_node_id, endpoint=0, attribute=Clusters.GeneralDiagnostics.Attributes.GeneratedCommandList) + + has_multiple_paths_per_invoke = max_paths_per_invoke > 1 + has_data_model_test_feature = (feature_map & Clusters.GeneralDiagnostics.Bitmaps.Feature.kDataModelTest) != 0 + has_payload_test_request_command = (Clusters.GeneralDiagnostics.Commands.PayloadTestRequest.command_id in accepted_commands) + has_payload_test_response_command = ( + Clusters.GeneralDiagnostics.Commands.PayloadTestResponse.command_id in generated_commands) + + logging.info(f"Number of supported invoke paths reported: {max_paths_per_invoke}") + if has_multiple_paths_per_invoke: + asserts.assert_true(has_data_model_test_feature, "Must have DMTEST feature when > 1 invoke paths supported") + + if has_data_model_test_feature: + asserts.assert_true(has_payload_test_request_command, "Must support PayloadTestRequest command when DMTEST supported") + asserts.assert_true(has_payload_test_response_command, + "Must generate PayloadTestResponse command when DMTEST supported") + + if has_data_model_test_feature: + # Test count too large (above max 2048) + with asserts.assert_raises_regex(InteractionModelError, + "ConstraintError", + "PayloadTestRequest with request too large (> 2048) must return ConstraintError"): + await dev_ctrl.SendCommand( + self.dut_node_id, + endpoint=0, + payload=Clusters.GeneralDiagnostics.Commands.PayloadTestRequest( + enableKey=kExpectedKey, + value=0x55, + count=2049 + ) + ) + + # Test size > 1 MTU but still legal by constraints, but should fail since that will be too large (unless future TCP transport) + with asserts.assert_raises_regex(InteractionModelError, + "ResourceExhausted", + "PayloadTestRequest with request too large (> 1 MTU) must return ResourceExhausted"): + await dev_ctrl.SendCommand( + self.dut_node_id, + endpoint=0, + payload=Clusters.GeneralDiagnostics.Commands.PayloadTestRequest( + enableKey=kExpectedKey, + value=0x55, + count=1280 + 1 + ) + ) + + # Test empty count succeeds + response = await dev_ctrl.SendCommand( + self.dut_node_id, + endpoint=0, + payload=Clusters.GeneralDiagnostics.Commands.PayloadTestRequest( + enableKey=kExpectedKey, + value=ord('B'), + count=0 + ) + ) + asserts.assert_equal(response.payload, b'', "Expect empty payload for count == 0") + + # Test size that should always fit. + response = await dev_ctrl.SendCommand( + self.dut_node_id, + endpoint=0, + payload=Clusters.GeneralDiagnostics.Commands.PayloadTestRequest( + enableKey=kExpectedKey, + value=ord('A'), + count=800 + ) + ) + asserts.assert_equal(response.payload, b'A' * 800, "Expect response to match for count == 800") + + if not has_data_model_test_feature: + with asserts.assert_raises_regex(InteractionModelError, + "UnsupportedCommand", + "PayloadTestRequest must not be supported if not reported"): + await dev_ctrl.SendCommand( + self.dut_node_id, + endpoint=0, + payload=Clusters.GeneralDiagnostics.Commands.PayloadTestRequest( + enableKey=kExpectedKey, + value=0x55, + count=1 + ) + ) + if __name__ == "__main__": default_matter_test_main() diff --git a/src/python_testing/TestBatchInvoke.py b/src/python_testing/TestBatchInvoke.py index e1f848ae9b1919..97f56e6ed02f9b 100644 --- a/src/python_testing/TestBatchInvoke.py +++ b/src/python_testing/TestBatchInvoke.py @@ -88,10 +88,13 @@ async def test_batch_invoke(self): sleepBeforeResponseTimeMs=0, sizeOfResponseBuffer=response_size, fillCharacter=ord(request_2_fill_character)) invoke_request_2 = Clusters.Command.InvokeRequestInfo(endpoint, command) try: - result = await dev_ctrl.SendBatchCommands(dut_node_id, [invoke_request_1, invoke_request_2]) + testOnlyResponse = await dev_ctrl.TestOnlySendBatchCommands(dut_node_id, [invoke_request_1, invoke_request_2]) except InteractionModelError: asserts.fail("DUT failed to successfully responded to a InvokeRequest action with two valid commands") + asserts.assert_greater(testOnlyResponse.ResponseMessageCount, 1, + "Unexpected, DUT sent response back in single InvokeResponseMessage") + result = testOnlyResponse.Responses asserts.assert_true(type_matches(result, list), "Unexpected return from SendBatchCommands") asserts.assert_equal(len(result), 2, "Unexpected number of InvokeResponses sent back from DUT") asserts.assert_true(type_matches( diff --git a/src/python_testing/TestMatterTestingSupport.py b/src/python_testing/TestMatterTestingSupport.py index 9577b3bd112a3f..2ed29074a153bb 100644 --- a/src/python_testing/TestMatterTestingSupport.py +++ b/src/python_testing/TestMatterTestingSupport.py @@ -15,6 +15,7 @@ # limitations under the License. # +import os import time import typing from datetime import datetime, timedelta, timezone @@ -23,7 +24,8 @@ from chip.clusters.Types import Nullable, NullValue from chip.tlv import uint from matter_testing_support import (MatterBaseTest, async_test_body, compare_time, default_matter_test_main, - get_wait_seconds_from_set_time, parse_pics, type_matches, utc_time_in_matter_epoch) + get_wait_seconds_from_set_time, parse_pics, parse_pics_xml, type_matches, + utc_time_in_matter_epoch) from mobly import asserts, signals from taglist_and_topology_test_support import (TagProblem, create_device_type_list_for_root, create_device_type_lists, find_tag_list_problems, find_tree_roots, get_all_children, @@ -584,6 +586,41 @@ def test_root_node_tag_list_functions(self): problems = find_tag_list_problems(roots=[0], device_types={0: device_type_list}, endpoint_dict=endpoints) asserts.assert_equal(len(problems.keys()), 0, 'Unexpected problems found in root endpoint') + def pics_assert(self, pics: str, support: bool): + asserts.assert_equal(self.check_pics(pics), support, + f'Unexpected PICS value for {pics} - expected {support}, got {self.check_pics(pics)}') + + def test_xml_pics(self): + script_dir = os.path.dirname(os.path.realpath(__file__)) + with open(f'{script_dir}/test_testing/example_pics_xml_basic_info.xml') as f: + pics = parse_pics_xml(f.read()) + print(pics) + # force the parsed pics here to be in the config so we can check the check_pics function + self.matter_test_config.pics = pics + self.pics_assert('BINFO.S', True) + self.pics_assert('BINFO.S.A0000', True) + self.pics_assert('BINFO.S.A0001', True) + self.pics_assert('BINFO.S.A0002', True) + self.pics_assert('BINFO.S.A0003', True) + self.pics_assert('BINFO.S.A0004', True) + self.pics_assert('BINFO.S.A0005', True) + self.pics_assert('BINFO.S.A0006', True) + self.pics_assert('BINFO.S.A0007', True) + self.pics_assert('BINFO.S.A0008', True) + self.pics_assert('BINFO.S.A0009', True) + self.pics_assert('BINFO.S.A000a', True) + self.pics_assert('BINFO.S.A000b', True) + self.pics_assert('BINFO.S.A000c', True) + self.pics_assert('BINFO.S.A000d', True) + self.pics_assert('BINFO.S.A000e', True) + self.pics_assert('BINFO.S.A000f', True) + self.pics_assert('BINFO.S.A0010', True) + self.pics_assert('BINFO.S.A0011', False) + self.pics_assert('BINFO.S.A0012', True) + self.pics_assert('BINFO.S.A0013', True) + self.pics_assert('BINFO.S.A0014', False) + self.pics_assert('PICSDOESNOTEXIST', False) + if __name__ == "__main__": default_matter_test_main() diff --git a/src/python_testing/matter_testing_support.py b/src/python_testing/matter_testing_support.py index 9d3c3e2a1fa302..4ddb4ce50fdf0e 100644 --- a/src/python_testing/matter_testing_support.py +++ b/src/python_testing/matter_testing_support.py @@ -18,6 +18,7 @@ import argparse import asyncio import builtins +import glob import inspect import json import logging @@ -29,6 +30,7 @@ import sys import typing import uuid +import xml.etree.ElementTree as ET from binascii import hexlify, unhexlify from dataclasses import asdict as dataclass_asdict from dataclasses import dataclass, field @@ -138,7 +140,7 @@ def get_default_paa_trust_store(root_path: pathlib.Path) -> pathlib.Path: return pathlib.Path.cwd() -def parse_pics(lines=typing.List[str]) -> dict[str, bool]: +def parse_pics(lines: typing.List[str]) -> dict[str, bool]: pics = {} for raw in lines: line, _, _ = raw.partition("#") @@ -156,11 +158,30 @@ def parse_pics(lines=typing.List[str]) -> dict[str, bool]: return pics -def read_pics_from_file(filename: str) -> dict[str, bool]: - """ Reads a dictionary of PICS from a file. """ - with open(filename, 'r') as f: - lines = f.readlines() - return parse_pics(lines) +def parse_pics_xml(contents: str) -> dict[str, bool]: + pics = {} + mytree = ET.fromstring(contents) + for pi in mytree.iter('picsItem'): + name = pi.find('itemNumber').text + support = pi.find('support').text + pics[name] = int(json.loads(support.lower())) == 1 + return pics + + +def read_pics_from_file(path: str) -> dict[str, bool]: + """ Reads a dictionary of PICS from a file (ci format) or directory (xml format). """ + if os.path.isdir(os.path.abspath(path)): + pics_dict = {} + for filename in glob.glob(f'{path}/*.xml'): + with open(filename, 'r') as f: + contents = f.read() + pics_dict.update(parse_pics_xml(contents)) + return pics_dict + + else: + with open(path, 'r') as f: + lines = f.readlines() + return parse_pics(lines) def type_matches(received_value, desired_type): @@ -303,6 +324,7 @@ class MatterTestConfig: tests: List[str] = field(default_factory=list) timeout: typing.Union[int, None] = None endpoint: int = 0 + app_pid: int = 0 commissioning_method: Optional[str] = None discriminators: Optional[List[int]] = None @@ -1244,6 +1266,7 @@ def convert_args_to_matter_config(args: argparse.Namespace) -> MatterTestConfig: config.tests = [] if args.tests is None else args.tests config.timeout = args.timeout # This can be none, we pull the default from the test if it's unspecified config.endpoint = 0 if args.endpoint is None else args.endpoint + config.app_pid = 0 if args.app_pid is None else args.app_pid config.controller_node_id = args.controller_node_id config.trace_to = args.trace_to @@ -1296,6 +1319,7 @@ def parse_matter_test_args(argv: List[str]) -> MatterTestConfig: help='Node ID for primary DUT communication, ' 'and NodeID to assign if commissioning (default: %d)' % _DEFAULT_DUT_NODE_ID, nargs="+") basic_group.add_argument('--endpoint', type=int, default=0, help="Endpoint under test") + basic_group.add_argument('--app-pid', type=int, default=0, help="The PID of the app against which the test is going to run") basic_group.add_argument('--timeout', type=int, help="Test timeout in seconds") basic_group.add_argument("--PICS", help="PICS file path", type=str) diff --git a/src/python_testing/mdns_discovery/mdns_discovery.py b/src/python_testing/mdns_discovery/mdns_discovery.py new file mode 100644 index 00000000000000..86661d65729da3 --- /dev/null +++ b/src/python_testing/mdns_discovery/mdns_discovery.py @@ -0,0 +1,375 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +import asyncio +import json +from dataclasses import asdict, dataclass +from enum import Enum +from typing import Dict, List, Optional + +from zeroconf import IPVersion, ServiceStateChange, Zeroconf +from zeroconf.asyncio import AsyncServiceBrowser, AsyncServiceInfo, AsyncZeroconfServiceTypes + + +@dataclass +class MdnsServiceInfo: + # The unique name of the mDNS service. + service_name: str + + # The service type of the service, typically indicating the service protocol and domain. + service_type: str + + # The instance name of the service. + instance_name: str + + # The domain name of the machine hosting the service. + server: str + + # The network port on which the service is available. + port: int + + # A list of IP addresses associated with the service. + addresses: list[str] + + # A dictionary of key-value pairs representing the service's metadata. + txt_record: dict[str, str] + + # The priority of the service, used in service selection when multiple instances are available. + priority: int + + # The network interface index on which the service is advertised. + interface_index: int + + # The relative weight for records with the same priority, used in load balancing. + weight: int + + # The time-to-live value for the host name in the DNS record. + host_ttl: int + + # The time-to-live value for other records associated with the service. + other_ttl: int + + +class MdnsServiceType(Enum): + """ + Enum for Matter mDNS service types used in network service discovery. + """ + COMMISSIONER = "_matterd._udp.local." + COMMISSIONABLE = "_matterc._udp.local." + OPERATIONAL = "_matter._tcp.local." + BORDER_ROUTER = "_meshcop._udp.local." + + +class MdnsDiscovery: + + DISCOVERY_TIMEOUT_SEC = 15 + + def __init__(self): + """ + Initializes the MdnsDiscovery instance. + + Main methods: + - get_commissioner_service + - get_commissionable_service + - get_operational_service + - get_border_router_service + - get_all_services + """ + # An instance of Zeroconf to manage mDNS operations. + self._zc = Zeroconf(ip_version=IPVersion.V6Only) + + # A dictionary to store discovered services. + self._discovered_services = {} + + # A list of service types + self._service_types = [] + + # An asyncio Event to signal when a service has been discovered + self._event = asyncio.Event() + + # Public methods + async def get_commissioner_service(self, log_output: bool = False, + discovery_timeout_sec: float = DISCOVERY_TIMEOUT_SEC + ) -> Optional[MdnsServiceInfo]: + """ + Asynchronously discovers a commissioner mDNS service within the network. + + Args: + log_output (bool): Logs the discovered services to the console. Defaults to False. + discovery_timeout_sec (float): Defaults to 15 seconds. + + Returns: + Optional[MdnsServiceInfo]: An instance of MdnsServiceInfo or None if timeout reached. + """ + return await self._get_service(MdnsServiceType.COMMISSIONER, log_output, discovery_timeout_sec) + + async def get_commissionable_service(self, log_output: bool = False, + discovery_timeout_sec: float = DISCOVERY_TIMEOUT_SEC + ) -> Optional[MdnsServiceInfo]: + """ + Asynchronously discovers a commissionable mDNS service within the network. + + Args: + log_output (bool): Logs the discovered services to the console. Defaults to False. + discovery_timeout_sec (float): Defaults to 15 seconds. + + Returns: + Optional[MdnsServiceInfo]: An instance of MdnsServiceInfo or None if timeout reached. + """ + return await self._get_service(MdnsServiceType.COMMISSIONABLE, log_output, discovery_timeout_sec) + + async def get_operational_service(self, service_name: str = None, + service_type: str = None, + discovery_timeout_sec: float = DISCOVERY_TIMEOUT_SEC, + log_output: bool = False + ) -> Optional[MdnsServiceInfo]: + """ + Asynchronously discovers an operational mDNS service within the network. + + Args: + log_output (bool): Logs the discovered services to the console. Defaults to False. + discovery_timeout_sec (float): Defaults to 15 seconds. + service_name (str): The unique name of the mDNS service. Defaults to None. + service_type (str): The service type of the service. Defaults to None. + + Returns: + Optional[MdnsServiceInfo]: An instance of MdnsServiceInfo or None if timeout reached. + """ + # Validation to ensure both or none of the parameters are provided + if (service_name is None) != (service_type is None): + raise ValueError("Both service_name and service_type must be provided together or not at all.") + + mdns_service_info = None + + if service_name is None and service_type is None: + mdns_service_info = await self._get_service(MdnsServiceType.OPERATIONAL, log_output, discovery_timeout_sec) + else: + print(f"Looking for MDNS service type '{service_type}', service name '{service_name}'") + + # Get service info + service_info = AsyncServiceInfo(service_type, service_name) + is_discovered = await service_info.async_request(self._zc, 3000) + if is_discovered: + mdns_service_info = self._to_mdns_service_info_class(service_info) + self._discovered_services = {} + self._discovered_services[service_type] = [mdns_service_info] + + if log_output: + self._log_output() + + return mdns_service_info + + async def get_border_router_service(self, log_output: bool = False, + discovery_timeout_sec: float = DISCOVERY_TIMEOUT_SEC + ) -> Optional[MdnsServiceInfo]: + """ + Asynchronously discovers a border router mDNS service within the network. + + Args: + log_output (bool): Logs the discovered services to the console. Defaults to False. + discovery_timeout_sec (float): Defaults to 15 seconds. + + Returns: + Optional[MdnsServiceInfo]: An instance of MdnsServiceInfo or None if timeout reached. + """ + return await self._get_service(MdnsServiceType.BORDER_ROUTER, log_output, discovery_timeout_sec) + + async def get_all_services(self, log_output: bool = False, + discovery_timeout_sec: float = DISCOVERY_TIMEOUT_SEC + ) -> Dict[str, List[MdnsServiceInfo]]: + """ + Asynchronously discovers all available mDNS services within the network. + + Args: + log_output (bool): Logs the discovered services to the console. Defaults to False. + discovery_timeout_sec (float): Defaults to 15 seconds. + + Returns: + Dict[str, List[MdnsServiceInfo]]: A dictionary mapping service types (str) to + lists of MdnsServiceInfo objects. + """ + await self._discover(discovery_timeout_sec, log_output, all_services=True) + + return self._discovered_services + + # Private methods + async def _discover(self, + discovery_timeout_sec: float, + log_output: bool, + all_services: bool = False + ) -> None: + """ + Asynchronously discovers network services using multicast DNS (mDNS). + + Args: + discovery_timeout_sec (float): The duration in seconds to wait for the discovery process, allowing for service + announcements to be collected. + all_services (bool): If True, discovers all available mDNS services. If False, discovers services based on the + predefined `_service_types` list. Defaults to False. + log_output (bool): If True, logs the discovered services to the console in JSON format for debugging or informational + purposes. Defaults to False. + + Returns: + None: This method does not return any value. + + Note: + The discovery duration may need to be adjusted based on network conditions and expected response times for service + announcements. The method leverages an asyncio event to manage asynchronous waiting and cancellation based on discovery + success or timeout. + """ + self._event.clear() + + if all_services: + self._service_types = list(await AsyncZeroconfServiceTypes.async_find()) + + print(f"Browsing for MDNS service(s) of type: {self._service_types}") + + aiobrowser = AsyncServiceBrowser(zeroconf=self._zc, + type_=self._service_types, + handlers=[self._on_service_state_change] + ) + + try: + await asyncio.wait_for(self._event.wait(), timeout=discovery_timeout_sec) + except asyncio.TimeoutError: + print(f"MDNS service discovery timed out after {discovery_timeout_sec} seconds.") + finally: + await aiobrowser.async_cancel() + + if log_output: + self._log_output() + + def _on_service_state_change( + self, + zeroconf: Zeroconf, + service_type: str, + name: str, + state_change: ServiceStateChange + ) -> None: + """ + Callback method triggered on mDNS service state change. + + This method is called by the Zeroconf library when there is a change in the state of an mDNS service. + It handles the addition of new services by initiating a query for their detailed information. + + Args: + zeroconf (Zeroconf): The Zeroconf instance managing the network operations. + service_type (str): The service type of the mDNS service that changed state. + name (str): The service name of the mDNS service. + state_change (ServiceStateChange): The type of state change that occurred. + + Returns: + None: This method does not return any value. + """ + if state_change.value == ServiceStateChange.Added.value: + self._event.set() + asyncio.ensure_future(self._query_service_info( + zeroconf, + service_type, + name) + ) + + async def _query_service_info(self, zeroconf: Zeroconf, service_type: str, service_name: str) -> None: + """ + This method queries for service details such as its address, port, and TXT records + containing metadata. + + Args: + zeroconf (Zeroconf): The Zeroconf instance used for managing network operations and service discovery. + service_type (str): The type of the mDNS service being queried. + service_name (str): The specific service name of the mDNS service to query. This service name uniquely + identifies the service instance within the local network. + + Returns: + None: This method does not return any value. + """ + # Get service info + service_info = AsyncServiceInfo(service_type, service_name) + is_service_discovered = await service_info.async_request(zeroconf, 3000) + service_info.async_clear_cache() + + if is_service_discovered: + mdns_service_info = self._to_mdns_service_info_class(service_info) + + if service_type not in self._discovered_services: + self._discovered_services[service_type] = [mdns_service_info] + else: + self._discovered_services[service_type].append(mdns_service_info) + + def _to_mdns_service_info_class(self, service_info: AsyncServiceInfo) -> MdnsServiceInfo: + """ + Converts an AsyncServiceInfo object into a MdnsServiceInfo data class. + + Args: + service_info (AsyncServiceInfo): The service information to convert. + + Returns: + MdnsServiceInfo: The converted service information as a data class. + """ + mdns_service_info = MdnsServiceInfo( + service_name=service_info.name, + service_type=service_info.type, + instance_name=service_info.get_name(), + server=service_info.server, + port=service_info.port, + addresses=service_info.parsed_addresses(), + txt_record=service_info.decoded_properties, + priority=service_info.priority, + interface_index=service_info.interface_index, + weight=service_info.weight, + host_ttl=service_info.host_ttl, + other_ttl=service_info.other_ttl + ) + + return mdns_service_info + + async def _get_service(self, service_type: MdnsServiceType, + log_output: bool, + discovery_timeout_sec: float + ) -> Optional[MdnsServiceInfo]: + """ + Asynchronously discovers a specific type of mDNS service within the network and returns its details. + + Args: + service_type (MdnsServiceType): The enum representing the type of mDNS service to discover. + log_output (bool): Logs the discovered services to the console. Defaults to False. + discovery_timeout_sec (float): Defaults to 15 seconds. + + Returns: + Optional[MdnsServiceInfo]: An instance of MdnsServiceInfo representing the discovered service, if + any. Returns None if no service of the specified type is discovered within + the timeout period. + """ + mdns_service_info = None + self._service_types = [service_type.value] + await self._discover(discovery_timeout_sec, log_output) + if service_type.value in self._discovered_services: + mdns_service_info = self._discovered_services[service_type.value][0] + + return mdns_service_info + + def _log_output(self) -> str: + """ + Converts the discovered services to a JSON string and prints it. + + The method is intended to be used for debugging or informational purposes, providing a clear and + comprehensive view of all services discovered during the mDNS service discovery process. + """ + converted_services = {key: [asdict(item) for item in value] for key, value in self._discovered_services.items()} + json_str = json.dumps(converted_services, indent=4) + print(json_str) diff --git a/src/python_testing/mdns_discovery/mdns_service_type_enum.py b/src/python_testing/mdns_discovery/mdns_service_type_enum.py new file mode 100644 index 00000000000000..efd77ca3beef5c --- /dev/null +++ b/src/python_testing/mdns_discovery/mdns_service_type_enum.py @@ -0,0 +1,26 @@ +# +# Copyright (c) 2024 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. +# + + +from enum import Enum + + +class MdnsServiceType(Enum): + COMMISSIONER = "_matterd._udp.local." + COMMISSIONABLE = "_matterc._udp.local." + OPERATIONAL = "_matter._tcp.local." + BORDER_ROUTER = "_meshcop._udp.local." diff --git a/src/python_testing/requirements.txt b/src/python_testing/requirements.txt index 84196f3f9e48f2..9cf6dc9737612a 100644 --- a/src/python_testing/requirements.txt +++ b/src/python_testing/requirements.txt @@ -1,3 +1,4 @@ mobly pyasn1 pyasn1_modules +zeroconf \ No newline at end of file diff --git a/src/python_testing/test_testing/example_pics_xml_basic_info.xml b/src/python_testing/test_testing/example_pics_xml_basic_info.xml new file mode 100644 index 00000000000000..3a8e279f3aa345 --- /dev/null +++ b/src/python_testing/test_testing/example_pics_xml_basic_info.xml @@ -0,0 +1,250 @@ + + + + + Basic Information Test Plan + + + + + + BINFO.S + Does the device implement the Basic Information Cluster as a server? + 9.1. Role - index.html[pdf] + O + true + + + + + + PIXIT.BINFO.PrimaryColor + ProductAppearance.PrimaryColor should reflect the product’s color + 10. PIXIT Definition - index.html[pdf] + M + 0x00 + + + PIXIT.BINFO.Finish + ProductAppearance.Finish should reflect the product’s finish + 10. PIXIT Definition - index.html[pdf] + M + 0x00 + + + + + + + + BINFO.S.A0000 + Does the DUT(server) support the DataModelRevision attribute? + 9.2.1. Attributes - index.html[pdf] + M + true + + + BINFO.S.A0001 + Does the DUT(server) support the VendorName attribute? + 9.2.1. Attributes - index.html[pdf] + M + true + + + BINFO.S.A0002 + Does the DUT(server) support the VendorID attribute? + 9.2.1. Attributes - index.html[pdf] + M + true + + + BINFO.S.A0003 + Does the DUT(server) support the ProductName attribute? + 9.2.1. Attributes - index.html[pdf] + M + true + + + BINFO.S.A0004 + Does the DUT(server) support the ProductID attribute? + 9.2.1. Attributes - index.html[pdf] + M + true + + + BINFO.S.A0005 + Does the DUT(server) support the NodeLabel attribute? + 9.2.1. Attributes - index.html[pdf] + M + true + + + BINFO.S.A0006 + Does the DUT(server) support the Location attribute? + 9.2.1. Attributes - index.html[pdf] + M + true + + + BINFO.S.A0007 + Does the DUT(server) support the HardwareVersion attribute? + 9.2.1. Attributes - index.html[pdf] + M + true + + + BINFO.S.A0008 + Does the DUT(server) support the HardwareVersionString attribute? + 9.2.1. Attributes - index.html[pdf] + M + true + + + BINFO.S.A0009 + Does the DUT(server) support the SoftwareVersion attribute? + 9.2.1. Attributes - index.html[pdf] + M + true + + + BINFO.S.A000a + Does the DUT(server) support the SoftwareVersionString attribute? + 9.2.1. Attributes - index.html[pdf] + M + true + + + BINFO.S.A000b + Does the DUT(server) support the ManufacturingDate attribute? + 9.2.1. Attributes - index.html[pdf] + O + true + + + BINFO.S.A000c + Does the DUT(server) support the PartNumber attribute? + 9.2.1. Attributes - index.html[pdf] + O + true + + + BINFO.S.A000d + Does the DUT(server) support the ProductURL attribute? + 9.2.1. Attributes - index.html[pdf] + O + true + + + BINFO.S.A000e + Does the DUT(server) support the ProductLabel attribute? + 9.2.1. Attributes - index.html[pdf] + O + true + + + BINFO.S.A000f + Does the DUT(server) support the SerialNumber attribute? + 9.2.1. Attributes - index.html[pdf] + O + true + + + BINFO.S.A0010 + Does the DUT(server) support the LocalConfigDisabled attribute? + 9.2.1. Attributes - index.html[pdf] + O + true + + + BINFO.S.A0011 + Does the DUT(server) support the Reachable attribute? + 9.2.1. Attributes - index.html[pdf] + O + false + + + BINFO.S.A0012 + Does the DUT(server) support the UniqueID attribute? + 9.2.1. Attributes - index.html[pdf] + O + true + + + BINFO.S.A0013 + Does the DUT(server) support the CapabilityMinima attribute? + 9.2.1. Attributes - index.html[pdf] + M + true + + + BINFO.S.A0014 + Does the DUT(server) support the ProductAppearance attribute? + 9.2.1. Attributes - index.html[pdf] + O + false + + + + + + BINFO.S.E00 + Does the DUT(server) support the StartUp event? + 9.2.2. Events - index.html[pdf] + M + true + + + BINFO.S.E01 + Does the DUT(server) support the ShutDown event? + 9.2.2. Events - index.html[pdf] + O + false + + + BINFO.S.E02 + Does the DUT(server) support the Leave event? + 9.2.2. Events - index.html[pdf] + O + false + + + BINFO.S.E03 + Does the DUT(server) support the ReachableChanged event? + 9.2.2. Events - index.html[pdf] + M + false + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index 5953dc6a0ffdd0..1389bddc3ca4c0 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -248,6 +248,12 @@ static_library("system") { ] if (chip_system_layer_impl_config_file == "") { + # This includes one of: + # - SystemLayerImplFreeRTOS.h + # - SystemLayerImplFreeRTOS.cpp + # or + # - SystemLayerImplSelect.h + # - SystemLayerImplSelect.cpp sources += [ "SystemLayerImpl${chip_system_config_event_loop}.cpp", "SystemLayerImpl${chip_system_config_event_loop}.h", diff --git a/src/system/SystemClock.cpp b/src/system/SystemClock.cpp index 3ef63797598f1f..d320149e43e6aa 100644 --- a/src/system/SystemClock.cpp +++ b/src/system/SystemClock.cpp @@ -61,6 +61,39 @@ ClockBase * gClockBase = &gClockImpl; } // namespace Internal +Timestamp ClockBase::GetMonotonicTimestamp() +{ + // Below implementation uses `__atomic_*` API which has wider support than + // on embedded platforms, so that embedded platforms can use + // it by widening the #ifdefs later. +#if CHIP_DEVICE_LAYER_USE_ATOMICS_FOR_CLOCK + uint64_t prevTimestamp = __atomic_load_n(&mLastTimestamp, __ATOMIC_SEQ_CST); + static_assert(sizeof(prevTimestamp) == sizeof(Timestamp), "Must have scalar match between timestamp and uint64_t for atomics."); + + // Force a reorder barrier to prevent GetMonotonicMilliseconds64() from being + // optimizer-called before prevTimestamp loading, so that newTimestamp acquisition happens-after + // the prevTimestamp load. + __atomic_signal_fence(__ATOMIC_SEQ_CST); +#else + uint64_t prevTimestamp = mLastTimestamp; +#endif // CHIP_DEVICE_LAYER_USE_ATOMICS_FOR_CLOCK + + Timestamp newTimestamp = GetMonotonicMilliseconds64(); + + // Need to guarantee the invariant that monotonic clock never goes backwards, which would break multiple system + // assumptions which use these clocks. + VerifyOrDie(newTimestamp.count() >= prevTimestamp); + +#if CHIP_DEVICE_LAYER_USE_ATOMICS_FOR_CLOCK + // newTimestamp guaranteed to never be < the last timestamp. + __atomic_store_n(&mLastTimestamp, newTimestamp.count(), __ATOMIC_SEQ_CST); +#else + mLastTimestamp = newTimestamp.count(); +#endif // CHIP_DEVICE_LAYER_USE_ATOMICS_FOR_CLOCK + + return newTimestamp; +} + #if !CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME #if CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS diff --git a/src/system/SystemClock.h b/src/system/SystemClock.h index 77196f995bbc89..4c691e1d2b7039 100644 --- a/src/system/SystemClock.h +++ b/src/system/SystemClock.h @@ -43,6 +43,14 @@ #include #include +#if CHIP_DEVICE_LAYER_TARGET_DARWIN || CHIP_DEVICE_LAYER_TARGET_LINUX +#define CHIP_DEVICE_LAYER_USE_ATOMICS_FOR_CLOCK 1 +#endif // CHIP_DEVICE_LAYER_TARGET_DARWIN || CHIP_DEVICE_LAYER_TARGET_LINUX + +#ifndef CHIP_DEVICE_LAYER_USE_ATOMICS_FOR_CLOCK +#define CHIP_DEVICE_LAYER_USE_ATOMICS_FOR_CLOCK 0 +#endif + namespace chip { namespace System { @@ -149,15 +157,20 @@ class ClockBase * * Although some platforms may choose to return a value that measures the time since boot for the * system, applications must *not* rely on this. + * + * WARNING: *** It is up to each platform to ensure that GetMonotonicTimestamp can be + * called safely in a re-entrant way from multiple contexts if making use + * of this method from the application, outside the Matter stack execution + * serialization context. *** */ - Timestamp GetMonotonicTimestamp() { return GetMonotonicMilliseconds64(); } + virtual Timestamp GetMonotonicTimestamp(); /** - * Returns a monotonic system time in units of microseconds. + * Returns a monotonic system time in units of microseconds, from the platform. * * This function returns an elapsed time in microseconds since an arbitrary, platform-defined epoch. - * The value returned is guaranteed to be ever-increasing (i.e. never wrapping or decreasing) between - * reboots of the system. Additionally, the underlying time source is guaranteed to tick + * The value returned MUST BE guaranteed to be ever-increasing (i.e. never wrapping or decreasing) until + * reboot of the system. Additionally, the underlying time source is guaranteed to tick * continuously during any system sleep modes that do not entail a restart upon wake. * * Although some platforms may choose to return a value that measures the time since boot for the @@ -176,11 +189,11 @@ class ClockBase virtual Microseconds64 GetMonotonicMicroseconds64() = 0; /** - * Returns a monotonic system time in units of milliseconds. + * Returns a monotonic system time in units of microseconds, from the platform. * * This function returns an elapsed time in milliseconds since an arbitrary, platform-defined epoch. - * The value returned is guaranteed to be ever-increasing (i.e. never wrapping or decreasing) between - * reboots of the system. Additionally, the underlying time source is guaranteed to tick + * The value returned MUST BE guaranteed to be ever-increasing (i.e. never wrapping or decreasing) until + * reboot of the system. Additionally, the underlying time source is guaranteed to tick * continuously during any system sleep modes that do not entail a restart upon wake. * * Although some platforms may choose to return a value that measures the time since boot for the @@ -288,6 +301,9 @@ class ClockBase * current time. */ virtual CHIP_ERROR SetClock_RealTime(Microseconds64 aNewCurTime) = 0; + +protected: + uint64_t mLastTimestamp = 0; }; // Currently we have a single implementation class, ClockImpl, whose members are implemented in build-specific files. @@ -334,7 +350,14 @@ class MockClock : public ClockImpl return CHIP_NO_ERROR; } - void SetMonotonic(Milliseconds64 timestamp) { mSystemTime = timestamp; } + void SetMonotonic(Milliseconds64 timestamp) + { + mSystemTime = timestamp; +#if CHIP_DEVICE_LAYER_USE_ATOMICS_FOR_CLOCK + __atomic_store_n(&mLastTimestamp, timestamp.count(), __ATOMIC_SEQ_CST); +#endif // CHIP_DEVICE_LAYER_USE_ATOMICS_FOR_CLOCK + } + void AdvanceMonotonic(Milliseconds64 increment) { mSystemTime += increment; } void AdvanceRealTime(Milliseconds64 increment) { mRealTime += increment; } diff --git a/src/tracing/backend.h b/src/tracing/backend.h index 7e04490e333ff7..3d8bec8ada501f 100644 --- a/src/tracing/backend.h +++ b/src/tracing/backend.h @@ -63,6 +63,7 @@ class Backend : public ::chip::IntrusiveListNodeBase<> /// Trace a zero-sized event virtual void TraceInstant(const char * label, const char * group) {} + virtual void TraceCounter(const char * label) {} virtual void LogMessageSend(MessageSendInfo &) { TraceInstant("MessageSent", "Messaging"); } virtual void LogMessageReceived(MessageReceivedInfo &) { TraceInstant("MessageReceived", "Messaging"); } diff --git a/src/tracing/esp32_trace/BUILD.gn b/src/tracing/esp32_trace/BUILD.gn index 7548894ab072ce..294cf1f5dc160b 100644 --- a/src/tracing/esp32_trace/BUILD.gn +++ b/src/tracing/esp32_trace/BUILD.gn @@ -29,6 +29,8 @@ static_library("backend") { output_dir = "${root_out_dir}/lib" sources = [ + "counter.cpp", + "counter.h", "esp32_tracing.cpp", "esp32_tracing.h", ] @@ -43,7 +45,10 @@ static_library("backend") { "${chip_root}/src/system", ] } - public_deps = [ "${chip_root}/src/tracing" ] + public_deps = [ + "${chip_root}/src/lib/core", + "${chip_root}/src/tracing", + ] } source_set("esp32_trace_tracing") { diff --git a/src/tracing/esp32_trace/counter.cpp b/src/tracing/esp32_trace/counter.cpp new file mode 100644 index 00000000000000..0b315a87007484 --- /dev/null +++ b/src/tracing/esp32_trace/counter.cpp @@ -0,0 +1,72 @@ +/* + * + * Copyright (c) 2024 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 + +using namespace chip; + +namespace Insights { + +// This is a one time allocation for counters. It is not supposed to be freed. +ESPInsightsCounter * ESPInsightsCounter::mHead = nullptr; + +ESPInsightsCounter * ESPInsightsCounter::GetInstance(const char * label) +{ + ESPInsightsCounter * current = mHead; + + while (current != nullptr) + { + if (strcmp(current->label, label) == 0) + { + current->instanceCount++; + return current; + } + current = current->mNext; + } + + // Allocate a new instance if counter is not present in the list. + void * ptr = Platform::MemoryAlloc(sizeof(ESPInsightsCounter)); + VerifyOrDie(ptr != nullptr); + + ESPInsightsCounter * newInstance = new (ptr) ESPInsightsCounter(label); + newInstance->mNext = mHead; + mHead = newInstance; + + return newInstance; +} + +int ESPInsightsCounter::GetInstanceCount() const +{ + return instanceCount; +} + +void ESPInsightsCounter::ReportMetrics() +{ + if (!registered) + { + esp_diag_metrics_register("SYS_CNT" /* Tag of metrics */, label /* Unique key 8 */, + label /* label displayed on dashboard */, "insights.cnt" /* hierarchical path */, + ESP_DIAG_DATA_TYPE_UINT /* data_type */); + registered = true; + } + ESP_LOGI("mtr", "Label = %s Count = %d", label, instanceCount); + esp_diag_metrics_add_uint(label, instanceCount); +} + +} // namespace Insights diff --git a/src/tracing/esp32_trace/counter.h b/src/tracing/esp32_trace/counter.h new file mode 100644 index 00000000000000..bfa6205c341a13 --- /dev/null +++ b/src/tracing/esp32_trace/counter.h @@ -0,0 +1,55 @@ +/* + * + * Copyright (c) 2024 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 + +namespace Insights { + +/* + * + * This class is used to monotonically increment the counters as per the label of the counter macro + * 'MATTER_TRACE_COUNTER(label)' and report the metrics to esp-insights. + * As per the label of the counter macro, it adds the counter in the linked list with the name label if not + * present and returns the same instance and increments the value if the counter is already present + * in the list. + */ + +class ESPInsightsCounter +{ +private: + static ESPInsightsCounter * mHead; // head of the counter list + const char * label; // unique key + int instanceCount; + ESPInsightsCounter * mNext; // pointer to point to the next entry in the list + bool registered = false; + + ESPInsightsCounter(const char * labelParam) : label(labelParam), instanceCount(1), mNext(nullptr) {} + +public: + static ESPInsightsCounter * GetInstance(const char * label); + + int GetInstanceCount() const; + + void ReportMetrics(); +}; + +} // namespace Insights diff --git a/src/tracing/esp32_trace/esp32_tracing.cpp b/src/tracing/esp32_trace/esp32_tracing.cpp index 7a1313089703f2..7937772606eec0 100644 --- a/src/tracing/esp32_trace/esp32_tracing.cpp +++ b/src/tracing/esp32_trace/esp32_tracing.cpp @@ -16,13 +16,14 @@ * limitations under the License. */ -#include "esp32_tracing.h" #include #include #include #include #include #include +#include +#include namespace chip { namespace Tracing { @@ -148,6 +149,10 @@ void ESP32Backend::LogNodeDiscovered(NodeDiscoveredInfo & info) {} void ESP32Backend::LogNodeDiscoveryFailed(NodeDiscoveryFailedInfo & info) {} +void ESP32Backend::TraceCounter(const char * label) +{ + ::Insights::ESPInsightsCounter::GetInstance(label)->ReportMetrics(); +} void ESP32Backend::TraceBegin(const char * label, const char * group) { HashValue hashValue = MurmurHash(group); diff --git a/src/tracing/esp32_trace/esp32_tracing.h b/src/tracing/esp32_trace/esp32_tracing.h index 7fe783d817d8d8..6d9a277e06561d 100644 --- a/src/tracing/esp32_trace/esp32_tracing.h +++ b/src/tracing/esp32_trace/esp32_tracing.h @@ -28,6 +28,8 @@ class ESP32Backend : public ::chip::Tracing::Backend /// Trace a zero-sized event void TraceInstant(const char * label, const char * group) override; + void TraceCounter(const char * label) override; + void LogMessageSend(MessageSendInfo &) override; void LogMessageReceived(MessageReceivedInfo &) override; diff --git a/src/tracing/esp32_trace/include/matter/tracing/macros_impl.h b/src/tracing/esp32_trace/include/matter/tracing/macros_impl.h index 4d8a8a2a214525..b95c20754237a1 100644 --- a/src/tracing/esp32_trace/include/matter/tracing/macros_impl.h +++ b/src/tracing/esp32_trace/include/matter/tracing/macros_impl.h @@ -28,6 +28,7 @@ #define MATTER_TRACE_BEGIN(label, group) ::chip::Tracing::Internal::Begin(label, group) #define MATTER_TRACE_END(label, group) ::chip::Tracing::Internal::End(label, group) #define MATTER_TRACE_INSTANT(label, group) ::chip::Tracing::Internal::Instant(label, group) +#define MATTER_TRACE_COUNTER(label) ::chip::Tracing::Internal::Counter(label) namespace chip { namespace Tracing { diff --git a/src/tracing/json/json_tracing.cpp b/src/tracing/json/json_tracing.cpp index 6c651b3190b485..af66e12a61a50b 100644 --- a/src/tracing/json/json_tracing.cpp +++ b/src/tracing/json/json_tracing.cpp @@ -23,9 +23,8 @@ #include #include #include -#include - #include +#include #include @@ -276,6 +275,26 @@ void JsonBackend::TraceInstant(const char * label, const char * group) OutputValue(value); } +void JsonBackend::TraceCounter(const char * label) +{ + std::string counterId = std::string(label); + if (mCounters.find(counterId) == mCounters.end()) + { + mCounters[counterId] = 1; + } + else + { + mCounters[counterId]++; + } + ::Json::Value value; + value["event"] = "TraceCounter"; + value["label"] = label; + value["count"] = mCounters[counterId]; + + // Output the counter event + OutputValue(value); +} + void JsonBackend::LogMessageSend(MessageSendInfo & info) { ::Json::Value value; diff --git a/src/tracing/json/json_tracing.h b/src/tracing/json/json_tracing.h index 74451b705b73e0..302c4bd5b5a485 100644 --- a/src/tracing/json/json_tracing.h +++ b/src/tracing/json/json_tracing.h @@ -19,6 +19,7 @@ #include #include +#include namespace Json { class Value; @@ -50,6 +51,7 @@ class JsonBackend : public ::chip::Tracing::Backend void TraceBegin(const char * label, const char * group) override; void TraceEnd(const char * label, const char * group) override; void TraceInstant(const char * label, const char * group) override; + void TraceCounter(const char * label) override; void LogMessageSend(MessageSendInfo &) override; void LogMessageReceived(MessageReceivedInfo &) override; void LogNodeLookup(NodeLookupInfo &) override; @@ -61,6 +63,8 @@ class JsonBackend : public ::chip::Tracing::Backend /// Does the actual write of the value void OutputValue(::Json::Value & value); + std::unordered_map mCounters; + // Output file if writing to a file. If closed, writing // to ChipLog* std::fstream mOutputFile; diff --git a/src/tracing/macros.h b/src/tracing/macros.h index 5f836e44d373bc..b456137b88a166 100644 --- a/src/tracing/macros.h +++ b/src/tracing/macros.h @@ -78,6 +78,7 @@ #define MATTER_TRACE_END(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_TRACE_INSTANT(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_TRACE_SCOPE(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) +#define MATTER_TRACE_COUNTER(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_LOG_MESSAGE_SEND(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_LOG_MESSAGE_RECEIVED(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) diff --git a/src/tracing/multiplexed/include/matter/tracing/macros_impl.h b/src/tracing/multiplexed/include/matter/tracing/macros_impl.h index e1f2adc56d989e..8b3e728289dc1d 100644 --- a/src/tracing/multiplexed/include/matter/tracing/macros_impl.h +++ b/src/tracing/multiplexed/include/matter/tracing/macros_impl.h @@ -28,6 +28,7 @@ #define MATTER_TRACE_BEGIN(label, group) ::chip::Tracing::Internal::Begin(label, group) #define MATTER_TRACE_END(label, group) ::chip::Tracing::Internal::End(label, group) #define MATTER_TRACE_INSTANT(label, group) ::chip::Tracing::Internal::Instant(label, group) +#define MATTER_TRACE_COUNTER(label) ::chip::Tracing::Internal::Counter(label) namespace chip { namespace Tracing { diff --git a/src/tracing/none/include/matter/tracing/macros_impl.h b/src/tracing/none/include/matter/tracing/macros_impl.h index 3f7f052b5cac0d..3119dce2a2b49f 100644 --- a/src/tracing/none/include/matter/tracing/macros_impl.h +++ b/src/tracing/none/include/matter/tracing/macros_impl.h @@ -31,3 +31,4 @@ #define MATTER_TRACE_END(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_TRACE_INSTANT(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_TRACE_SCOPE(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) +#define MATTER_TRACE_COUNTER(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) diff --git a/src/tracing/perfetto/include/matter/tracing/macros_impl.h b/src/tracing/perfetto/include/matter/tracing/macros_impl.h index 266ac69f5735a0..9b05d2f3539a45 100644 --- a/src/tracing/perfetto/include/matter/tracing/macros_impl.h +++ b/src/tracing/perfetto/include/matter/tracing/macros_impl.h @@ -30,3 +30,10 @@ PERFETTO_DEFINE_CATEGORIES(perfetto::Category("Matter").SetDescription("Matter t #define MATTER_TRACE_END(label, group) TRACE_EVENT_END("Matter") #define MATTER_TRACE_INSTANT(label, group) TRACE_EVENT_INSTANT("Matter", label, "class_name", group) #define MATTER_TRACE_SCOPE(label, group) TRACE_EVENT("Matter", label, "class_name", group) + +#define MATTER_TRACE_COUNTER(label) \ + do \ + { \ + static int count##_label = 0; \ + TRACE_COUNTER("Matter", label, ++count##_label); \ + } while (0) diff --git a/src/tracing/perfetto/perfetto_tracing.cpp b/src/tracing/perfetto/perfetto_tracing.cpp index 6d89dbbccc9723..b68ec33d33101d 100644 --- a/src/tracing/perfetto/perfetto_tracing.cpp +++ b/src/tracing/perfetto/perfetto_tracing.cpp @@ -21,10 +21,9 @@ #include #include #include -#include - #include #include +#include namespace chip { namespace Tracing { diff --git a/src/tracing/registry.cpp b/src/tracing/registry.cpp index 9f7507aa9f75a6..7c43442b5b83db 100644 --- a/src/tracing/registry.cpp +++ b/src/tracing/registry.cpp @@ -76,6 +76,14 @@ void Instant(const char * label, const char * group) } } +void Counter(const char * label) +{ + for (auto & backend : gTracingBackends) + { + backend.TraceCounter(label); + } +} + void LogMessageSend(::chip::Tracing::MessageSendInfo & info) { for (auto & backend : gTracingBackends) diff --git a/src/tracing/registry.h b/src/tracing/registry.h index 853372585840fa..083ebcb2225ad2 100644 --- a/src/tracing/registry.h +++ b/src/tracing/registry.h @@ -76,6 +76,7 @@ namespace Internal { void Begin(const char * label, const char * group); void End(const char * label, const char * group); void Instant(const char * label, const char * group); +void Counter(const char * label); void LogMessageSend(::chip::Tracing::MessageSendInfo & info); void LogMessageReceived(::chip::Tracing::MessageReceivedInfo & info); diff --git a/src/transport/BUILD.gn b/src/transport/BUILD.gn index 33a8f05f8c64df..fa556d40afd5b0 100644 --- a/src/transport/BUILD.gn +++ b/src/transport/BUILD.gn @@ -13,7 +13,6 @@ # limitations under the License. import("//build_overrides/chip.gni") -import("//build_overrides/nlio.gni") import("//build_overrides/pigweed.gni") import("${chip_root}/src/ble/ble.gni") import("${chip_root}/src/lib/core/core.gni") @@ -45,6 +44,7 @@ static_library("transport") { "SessionManager.h", "SessionMessageCounter.h", "SessionMessageDelegate.h", + "SessionUpdateDelegate.h", "TracingStructs.h", "TransportMgr.h", "TransportMgrBase.cpp", @@ -68,11 +68,13 @@ static_library("transport") { "${chip_root}/src/tracing", "${chip_root}/src/tracing:macros", "${chip_root}/src/transport/raw", - "${nlio_root}:nlio", ] if (chip_enable_transport_trace) { - sources += [ "TraceMessage.cpp" ] + sources += [ + "TraceMessage.cpp", + "TraceMessage.h", + ] } if (chip_enable_transport_pw_trace) { public_deps += [ "$dir_pw_trace" ] diff --git a/src/transport/Session.h b/src/transport/Session.h index f211a610386bf2..0b6048d5c077c0 100644 --- a/src/transport/Session.h +++ b/src/transport/Session.h @@ -25,8 +25,8 @@ #include #include #include +#include #include -#include #include namespace chip { diff --git a/src/transport/raw/BUILD.gn b/src/transport/raw/BUILD.gn index ae3aeb58f8e3e9..736b16cdb08477 100644 --- a/src/transport/raw/BUILD.gn +++ b/src/transport/raw/BUILD.gn @@ -44,6 +44,7 @@ static_library("raw") { "${chip_root}/src/inet", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", + "${chip_root}/src/lib/support:type-traits", "${chip_root}/src/platform", ] } diff --git a/src/transport/raw/tests/BUILD.gn b/src/transport/raw/tests/BUILD.gn index 1767b113d07ce3..8adcb9beb7eeee 100644 --- a/src/transport/raw/tests/BUILD.gn +++ b/src/transport/raw/tests/BUILD.gn @@ -14,7 +14,6 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") -import("//build_overrides/nlio.gni") import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip/chip_test_suite.gni") @@ -43,6 +42,7 @@ chip_test_suite_using_nltest("tests") { "TestMessageHeader.cpp", "TestPeerAddress.cpp", "TestTCP.cpp", + "TestUDP.cpp", ] public_deps = [ @@ -54,7 +54,6 @@ chip_test_suite_using_nltest("tests") { "${chip_root}/src/lib/support:testing_nlunit", "${chip_root}/src/transport", "${chip_root}/src/transport/raw", - "${nlio_root}:nlio", "${nlunit_test_root}:nlunit-test", ] diff --git a/src/transport/raw/tests/TestTCP.cpp b/src/transport/raw/tests/TestTCP.cpp index 62b03f4e3feb03..620e97ca4325b3 100644 --- a/src/transport/raw/tests/TestTCP.cpp +++ b/src/transport/raw/tests/TestTCP.cpp @@ -34,7 +34,6 @@ #include #include -#include #include #include diff --git a/src/transport/raw/tests/TestUDP.cpp b/src/transport/raw/tests/TestUDP.cpp index bff5e9efa1de00..b26d23277d5844 100644 --- a/src/transport/raw/tests/TestUDP.cpp +++ b/src/transport/raw/tests/TestUDP.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -196,7 +195,7 @@ static nlTestSuite sSuite = */ static int Initialize(void * aContext) { - CHIP_ERROR err = reinterpret_cast(aContext)->Init(&sSuite); + CHIP_ERROR err = reinterpret_cast(aContext)->Init(); return (err == CHIP_NO_ERROR) ? SUCCESS : FAILURE; } diff --git a/src/transport/retransmit/tests/BUILD.gn b/src/transport/retransmit/tests/BUILD.gn index 0b75a5b4d4a931..fb08fa08f48a1d 100644 --- a/src/transport/retransmit/tests/BUILD.gn +++ b/src/transport/retransmit/tests/BUILD.gn @@ -14,7 +14,6 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") -import("//build_overrides/nlio.gni") import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip/chip_test_suite.gni") @@ -32,7 +31,6 @@ chip_test_suite_using_nltest("tests") { public_deps = [ "${chip_root}/src/lib/support:testing_nlunit", "${chip_root}/src/transport/retransmit", - "${nlio_root}:nlio", "${nlunit_test_root}:nlunit-test", ] diff --git a/src/transport/tests/BUILD.gn b/src/transport/tests/BUILD.gn index f982134d5b84a1..18987c6c8c38e9 100644 --- a/src/transport/tests/BUILD.gn +++ b/src/transport/tests/BUILD.gn @@ -14,13 +14,15 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") -import("//build_overrides/nlio.gni") import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip/chip_test_suite.gni") source_set("helpers") { - sources = [ "LoopbackTransportManager.h" ] + sources = [ + "LoopbackTransportManager.h", + "UDPTransportManager.h", + ] public_deps = [ "${chip_root}/src/transport:transport", @@ -55,11 +57,11 @@ chip_test_suite_using_nltest("tests") { "${chip_root}/src/inet/tests:helpers", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", + "${chip_root}/src/lib/support:testing", "${chip_root}/src/lib/support:testing_nlunit", "${chip_root}/src/protocols", "${chip_root}/src/transport", "${chip_root}/src/transport/tests:helpers", - "${nlio_root}:nlio", "${nlunit_test_root}:nlunit-test", ] } diff --git a/third_party/imgui/repo b/third_party/imgui/repo index 96839b445e32e4..f50ddc431e3b88 160000 --- a/third_party/imgui/repo +++ b/third_party/imgui/repo @@ -1 +1 @@ -Subproject commit 96839b445e32e46d87a44fd43a9cdd60c806f7e1 +Subproject commit f50ddc431e3b8840036e88abc4c3cf74500aa12b diff --git a/third_party/mbedtls/repo b/third_party/mbedtls/repo index 1b9cea30b1d59a..6b36a5db07ae0e 160000 --- a/third_party/mbedtls/repo +++ b/third_party/mbedtls/repo @@ -1 +1 @@ -Subproject commit 1b9cea30b1d59a42df7d0f98aed97462985d42d5 +Subproject commit 6b36a5db07ae0e299c9e67f526c28db93e586e25 diff --git a/third_party/nanopb/repo b/third_party/nanopb/repo index f8724ee54b3733..1f0c2e19c661f1 160000 --- a/third_party/nanopb/repo +++ b/third_party/nanopb/repo @@ -1 +1 @@ -Subproject commit f8724ee54b3733aebfc25ac0ed5e8b142569c59e +Subproject commit 1f0c2e19c661f18dd88428858b8e965a26589e03 diff --git a/third_party/openthread/repo b/third_party/openthread/repo index bf587dd09005ab..cf357d70be94e6 160000 --- a/third_party/openthread/repo +++ b/third_party/openthread/repo @@ -1 +1 @@ -Subproject commit bf587dd09005abc49a5595f8691afb9512fac9c1 +Subproject commit cf357d70be94e6f3f21d07b3c16e29bb7ec5cc7e diff --git a/third_party/ot-br-posix/repo b/third_party/ot-br-posix/repo index 13d583e361c703..9326cc38b6b6ce 160000 --- a/third_party/ot-br-posix/repo +++ b/third_party/ot-br-posix/repo @@ -1 +1 @@ -Subproject commit 13d583e361c7038b967b601d5e5f6739b0bcf736 +Subproject commit 9326cc38b6b6ce81958a96d7821c4cb21976d636 diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 3a80deb7f99e33..415f89b4db04fb 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -50,6 +50,9 @@ declare_args() { sl_ot_idle_interval_ms = 15000 # 15s Idle Intervals sl_ot_active_interval_ms = 200 # 200ms Active Intervals + # SSED Specific configurations + sl_ot_csl_timeout_sec = 30 # 30s CSL timeout + # ICD Matter Configuration flags sl_idle_mode_interval_s = 600 # 10min Idle Mode Interval sl_active_mode_interval_ms = 1000 # 1s Active Mode Interval @@ -59,6 +62,9 @@ declare_args() { silabs_log_enabled = true + # Enable Synchronized Sleepy End Device + enable_synchronized_sed = false + # Argument to enable IPv4 for wifi # aligning to match chip_inet_config_enable_ipv4 default configuration chip_enable_wifi_ipv4 = false @@ -160,7 +166,6 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/radio/rail_lib/protocol/ieee802154", "${efr32_sdk_root}/platform/radio/rail_lib/protocol/ble", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions", - "${efr32_sdk_root}/platform/radio/rail_lib/plugin/rail_util_power_manager_init", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/rail_util_pti", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/rail_util_power_manager_init", "${efr32_sdk_root}/platform/service/device_init/inc", @@ -296,13 +301,6 @@ template("efr32_sdk") { #"__STACK_SIZE=0", ] - if (!(use_silabs_thread_lib || use_silabs_thread_lib)) { - #Enabling this config temporarly to fix a build issue until - #official fix is pushed - - defines += [ "OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE=1" ] - } - # Temporary configuration to enable COAP specific configurations if (use_thread_coap_lib) { defines += [ "SL_USE_COAP_CONFIG=1" ] @@ -433,6 +431,14 @@ template("efr32_sdk") { "SL_OT_IDLE_INTERVAL=${sl_ot_idle_interval_ms}", "SL_OT_ACTIVE_INTERVAL=${sl_ot_active_interval_ms}", ] + + if (enable_synchronized_sed) { + defines += [ + "CHIP_DEVICE_CONFIG_THREAD_SSED=1", + "SL_CSL_ENABLE=1", + "SL_CSL_TIMEOUT=${sl_ot_csl_timeout_sec}", + ] + } } if (defined(invoker.chip_enable_wifi) && invoker.chip_enable_wifi) { diff --git a/third_party/silabs/silabs_lwip/BUILD.gn b/third_party/silabs/silabs_lwip/BUILD.gn index 223ad948e0d85d..dd05ec4cf319c6 100644 --- a/third_party/silabs/silabs_lwip/BUILD.gn +++ b/third_party/silabs/silabs_lwip/BUILD.gn @@ -33,7 +33,12 @@ lwip_target("silabs_lwip") { "${chip_root}/src/lwip/silabs/lwippools.h", ] - sources = [ "${chip_root}/src/lwip/freertos/sys_arch.c" ] + sources = [ + "${chip_root}/src/lwip/freertos/sys_arch.c", + "${chip_root}/src/lwip/silabs/lwipopts-rs911x.h", + "${chip_root}/src/lwip/silabs/lwipopts-thread.h", + "${chip_root}/src/lwip/silabs/lwipopts-wf200.h", + ] public_deps = [ "${chip_root}/src/lwip:lwip_buildconfig", diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index 912428b16a4b25..808a68fc3a02ee 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -4434,68 +4434,6 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) } // namespace TestEventTriggersEnabled -namespace FeatureMap { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); -} - -} // namespace FeatureMap - -namespace ClusterRevision { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace ClusterRevision - } // namespace Attributes } // namespace GeneralDiagnostics @@ -9918,17 +9856,17 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) } // namespace Attributes } // namespace ValveConfigurationAndControl -namespace ElectricalEnergyMeasurement { +namespace ElectricalPowerMeasurement { namespace Attributes { -namespace FeatureMap { +namespace ClusterRevision { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ElectricalEnergyMeasurement::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ElectricalPowerMeasurement::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -9937,9 +9875,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -9947,10 +9885,16 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ElectricalEnergyMeasurement::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::ElectricalPowerMeasurement::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -} // namespace FeatureMap +} // namespace ClusterRevision + +} // namespace Attributes +} // namespace ElectricalPowerMeasurement + +namespace ElectricalEnergyMeasurement { +namespace Attributes { namespace ClusterRevision { @@ -10481,6 +10425,74 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) } // namespace Attributes } // namespace EnergyPreference +namespace PowerTopology { +namespace Attributes { + +namespace FeatureMap { + +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerTopology::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + *value = Traits::StorageToWorking(temp); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::PowerTopology::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); +} + +} // namespace FeatureMap + +namespace ClusterRevision { + +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerTopology::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + *value = Traits::StorageToWorking(temp); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::PowerTopology::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); +} + +} // namespace ClusterRevision + +} // namespace Attributes +} // namespace PowerTopology + namespace EnergyEvseMode { namespace Attributes { diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index 841ec992bfc42d..58daa784c6998f 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -842,16 +842,6 @@ EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean EmberAfStatus Set(chip::EndpointId endpoint, bool value); } // namespace TestEventTriggersEnabled -namespace FeatureMap { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace FeatureMap - -namespace ClusterRevision { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace ClusterRevision - } // namespace Attributes } // namespace GeneralDiagnostics @@ -1936,13 +1926,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); } // namespace Attributes } // namespace ValveConfigurationAndControl -namespace ElectricalEnergyMeasurement { +namespace ElectricalPowerMeasurement { namespace Attributes { -namespace FeatureMap { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace FeatureMap +namespace ClusterRevision { +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); +} // namespace ClusterRevision + +} // namespace Attributes +} // namespace ElectricalPowerMeasurement + +namespace ElectricalEnergyMeasurement { +namespace Attributes { namespace ClusterRevision { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u @@ -2057,6 +2053,22 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); } // namespace Attributes } // namespace EnergyPreference +namespace PowerTopology { +namespace Attributes { + +namespace FeatureMap { +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); +} // namespace FeatureMap + +namespace ClusterRevision { +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); +} // namespace ClusterRevision + +} // namespace Attributes +} // namespace PowerTopology + namespace EnergyEvseMode { namespace Attributes { diff --git a/zzz_generated/app-common/app-common/zap-generated/callback.h b/zzz_generated/app-common/app-common/zap-generated/callback.h index 9989e8424bbe87..350190a22e5762 100644 --- a/zzz_generated/app-common/app-common/zap-generated/callback.h +++ b/zzz_generated/app-common/app-common/zap-generated/callback.h @@ -358,6 +358,11 @@ void emberAfBooleanStateConfigurationClusterInitCallback(chip::EndpointId endpoi */ void emberAfValveConfigurationAndControlClusterInitCallback(chip::EndpointId endpoint); +/** + * @param endpoint Endpoint that is being initialized + */ +void emberAfElectricalPowerMeasurementClusterInitCallback(chip::EndpointId endpoint); + /** * @param endpoint Endpoint that is being initialized */ @@ -388,6 +393,11 @@ void emberAfEnergyEvseClusterInitCallback(chip::EndpointId endpoint); */ void emberAfEnergyPreferenceClusterInitCallback(chip::EndpointId endpoint); +/** + * @param endpoint Endpoint that is being initialized + */ +void emberAfPowerTopologyClusterInitCallback(chip::EndpointId endpoint); + /** * @param endpoint Endpoint that is being initialized */ @@ -3124,6 +3134,44 @@ chip::Protocols::InteractionModel::Status MatterValveConfigurationAndControlClus */ void emberAfValveConfigurationAndControlClusterServerTickCallback(chip::EndpointId endpoint); +// +// Electrical Power Measurement Cluster +// + +/** + * @param endpoint Endpoint that is being initialized + */ +void emberAfElectricalPowerMeasurementClusterServerInitCallback(chip::EndpointId endpoint); + +/** + * @param endpoint Endpoint that is being shutdown + */ +void MatterElectricalPowerMeasurementClusterServerShutdownCallback(chip::EndpointId endpoint); + +/** + * @param endpoint Endpoint that is being initialized + */ +void emberAfElectricalPowerMeasurementClusterClientInitCallback(chip::EndpointId endpoint); + +/** + * @param attributePath Concrete attribute path that changed + */ +void MatterElectricalPowerMeasurementClusterServerAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath); + +/** + * @param attributePath Concrete attribute path to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +chip::Protocols::InteractionModel::Status MatterElectricalPowerMeasurementClusterServerPreAttributeChangedCallback( + const chip::app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value); + +/** + * @param endpoint Endpoint that is being served + */ +void emberAfElectricalPowerMeasurementClusterServerTickCallback(chip::EndpointId endpoint); + // // Electrical Energy Measurement Cluster // @@ -3355,6 +3403,45 @@ MatterEnergyPreferenceClusterServerPreAttributeChangedCallback(const chip::app:: */ void emberAfEnergyPreferenceClusterServerTickCallback(chip::EndpointId endpoint); +// +// Power Topology Cluster +// + +/** + * @param endpoint Endpoint that is being initialized + */ +void emberAfPowerTopologyClusterServerInitCallback(chip::EndpointId endpoint); + +/** + * @param endpoint Endpoint that is being shutdown + */ +void MatterPowerTopologyClusterServerShutdownCallback(chip::EndpointId endpoint); + +/** + * @param endpoint Endpoint that is being initialized + */ +void emberAfPowerTopologyClusterClientInitCallback(chip::EndpointId endpoint); + +/** + * @param attributePath Concrete attribute path that changed + */ +void MatterPowerTopologyClusterServerAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath); + +/** + * @param attributePath Concrete attribute path to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +chip::Protocols::InteractionModel::Status +MatterPowerTopologyClusterServerPreAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath, + EmberAfAttributeType attributeType, uint16_t size, uint8_t * value); + +/** + * @param endpoint Endpoint that is being served + */ +void emberAfPowerTopologyClusterServerTickCallback(chip::EndpointId endpoint); + // // Energy EVSE Mode Cluster // @@ -5375,6 +5462,12 @@ bool emberAfGeneralDiagnosticsClusterTestEventTriggerCallback( bool emberAfGeneralDiagnosticsClusterTimeSnapshotCallback( chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::GeneralDiagnostics::Commands::TimeSnapshot::DecodableType & commandData); +/** + * @brief General Diagnostics Cluster PayloadTestRequest Command callback (from client) + */ +bool emberAfGeneralDiagnosticsClusterPayloadTestRequestCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::GeneralDiagnostics::Commands::PayloadTestRequest::DecodableType & commandData); /** * @brief Software Diagnostics Cluster ResetWatermarks Command callback (from client) */ diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h index 988e6b713a862e..ca25c08c748e0c 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h @@ -24,6 +24,146 @@ namespace chip { namespace app { namespace Clusters { +static auto __attribute__((unused)) EnsureKnownEnumValue(detail::ChangeIndicationEnum val) +{ + using EnumType = detail::ChangeIndicationEnum; + switch (val) + { + case EnumType::kOk: + case EnumType::kWarning: + case EnumType::kCritical: + return val; + default: + return EnumType::kUnknownEnumValue; + } +} +static auto __attribute__((unused)) EnsureKnownEnumValue(detail::DegradationDirectionEnum val) +{ + using EnumType = detail::DegradationDirectionEnum; + switch (val) + { + case EnumType::kUp: + case EnumType::kDown: + return val; + default: + return EnumType::kUnknownEnumValue; + } +} +static auto __attribute__((unused)) EnsureKnownEnumValue(detail::ErrorStateEnum val) +{ + using EnumType = detail::ErrorStateEnum; + switch (val) + { + case EnumType::kNoError: + case EnumType::kUnableToStartOrResume: + case EnumType::kUnableToCompleteOperation: + case EnumType::kCommandInvalidInState: + return val; + default: + return EnumType::kUnknownEnumValue; + } +} +static auto __attribute__((unused)) EnsureKnownEnumValue(detail::LevelValueEnum val) +{ + using EnumType = detail::LevelValueEnum; + switch (val) + { + case EnumType::kUnknown: + case EnumType::kLow: + case EnumType::kMedium: + case EnumType::kHigh: + case EnumType::kCritical: + return val; + default: + return EnumType::kUnknownEnumValue; + } +} +static auto __attribute__((unused)) EnsureKnownEnumValue(detail::MeasurementMediumEnum val) +{ + using EnumType = detail::MeasurementMediumEnum; + switch (val) + { + case EnumType::kAir: + case EnumType::kWater: + case EnumType::kSoil: + return val; + default: + return EnumType::kUnknownEnumValue; + } +} +static auto __attribute__((unused)) EnsureKnownEnumValue(detail::MeasurementTypeEnum val) +{ + using EnumType = detail::MeasurementTypeEnum; + switch (val) + { + case EnumType::kUnspecified: + case EnumType::kVoltage: + case EnumType::kActiveCurrent: + case EnumType::kReactiveCurrent: + case EnumType::kApparentCurrent: + case EnumType::kActivePower: + case EnumType::kReactivePower: + case EnumType::kApparentPower: + case EnumType::kRMSVoltage: + case EnumType::kRMSCurrent: + case EnumType::kRMSPower: + case EnumType::kFrequency: + case EnumType::kPowerFactor: + case EnumType::kNeutralCurrent: + case EnumType::kElectricalEnergy: + return val; + default: + return EnumType::kUnknownEnumValue; + } +} +static auto __attribute__((unused)) EnsureKnownEnumValue(detail::MeasurementUnitEnum val) +{ + using EnumType = detail::MeasurementUnitEnum; + switch (val) + { + case EnumType::kPpm: + case EnumType::kPpb: + case EnumType::kPpt: + case EnumType::kMgm3: + case EnumType::kUgm3: + case EnumType::kNgm3: + case EnumType::kPm3: + case EnumType::kBqm3: + return val; + default: + return EnumType::kUnknownEnumValue; + } +} +static auto __attribute__((unused)) EnsureKnownEnumValue(detail::OperationalStateEnum val) +{ + using EnumType = detail::OperationalStateEnum; + switch (val) + { + case EnumType::kStopped: + case EnumType::kRunning: + case EnumType::kPaused: + case EnumType::kError: + return val; + default: + return EnumType::kUnknownEnumValue; + } +} +static auto __attribute__((unused)) EnsureKnownEnumValue(detail::ProductIdentifierTypeEnum val) +{ + using EnumType = detail::ProductIdentifierTypeEnum; + switch (val) + { + case EnumType::kUpc: + case EnumType::kGtin8: + case EnumType::kEan: + case EnumType::kGtin14: + case EnumType::kOem: + return val; + default: + return EnumType::kUnknownEnumValue; + } +} + static auto __attribute__((unused)) EnsureKnownEnumValue(Identify::EffectIdentifierEnum val) { using EnumType = Identify::EffectIdentifierEnum; @@ -37,7 +177,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Identify::EffectIdentif case EnumType::kStopEffect: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Identify::EffectVariantEnum val) @@ -48,7 +188,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Identify::EffectVariant case EnumType::kDefault: return val; default: - return static_cast(1); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Identify::IdentifyTypeEnum val) @@ -64,7 +204,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Identify::IdentifyTypeE case EnumType::kActuator: return val; default: - return static_cast(6); + return EnumType::kUnknownEnumValue; } } @@ -78,7 +218,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OnOff::DelayedAllOffEff case EnumType::kDelayedOffSlowFade: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(OnOff::DyingLightEffectVariantEnum val) @@ -89,7 +229,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OnOff::DyingLightEffect case EnumType::kDyingLightFadeOff: return val; default: - return static_cast(1); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(OnOff::EffectIdentifierEnum val) @@ -101,7 +241,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OnOff::EffectIdentifier case EnumType::kDyingLight: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(OnOff::StartUpOnOffEnum val) @@ -114,7 +254,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OnOff::StartUpOnOffEnum case EnumType::kToggle: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } @@ -127,7 +267,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(LevelControl::MoveModeE case EnumType::kDown: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(LevelControl::StepModeEnum val) @@ -139,7 +279,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(LevelControl::StepModeE case EnumType::kDown: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } @@ -153,7 +293,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(AccessControl::AccessCo case EnumType::kGroup: return val; default: - return static_cast(0); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(AccessControl::AccessControlEntryPrivilegeEnum val) @@ -168,7 +308,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(AccessControl::AccessCo case EnumType::kAdminister: return val; default: - return static_cast(0); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(AccessControl::ChangeTypeEnum val) @@ -181,7 +321,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(AccessControl::ChangeTy case EnumType::kRemoved: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } @@ -194,7 +334,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Actions::ActionErrorEnu case EnumType::kInterrupted: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Actions::ActionStateEnum val) @@ -208,7 +348,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Actions::ActionStateEnu case EnumType::kDisabled: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Actions::ActionTypeEnum val) @@ -225,7 +365,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Actions::ActionTypeEnum case EnumType::kAlarm: return val; default: - return static_cast(7); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Actions::EndpointListTypeEnum val) @@ -238,7 +378,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Actions::EndpointListTy case EnumType::kZone: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } @@ -270,7 +410,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(BasicInformation::Color case EnumType::kGold: return val; default: - return static_cast(21); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(BasicInformation::ProductFinishEnum val) @@ -286,7 +426,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(BasicInformation::Produ case EnumType::kFabric: return val; default: - return static_cast(6); + return EnumType::kUnknownEnumValue; } } @@ -300,7 +440,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OtaSoftwareUpdateProvid case EnumType::kDiscontinue: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(OtaSoftwareUpdateProvider::DownloadProtocolEnum val) @@ -314,7 +454,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OtaSoftwareUpdateProvid case EnumType::kVendorSpecific: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(OtaSoftwareUpdateProvider::StatusEnum val) @@ -328,7 +468,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OtaSoftwareUpdateProvid case EnumType::kDownloadProtocolNotSupported: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } @@ -342,7 +482,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OtaSoftwareUpdateReques case EnumType::kUrgentUpdateAvailable: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(OtaSoftwareUpdateRequestor::ChangeReasonEnum val) @@ -357,7 +497,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OtaSoftwareUpdateReques case EnumType::kDelayByProvider: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(OtaSoftwareUpdateRequestor::UpdateStateEnum val) @@ -376,7 +516,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OtaSoftwareUpdateReques case EnumType::kDelayedOnUserConsent: return val; default: - return static_cast(9); + return EnumType::kUnknownEnumValue; } } @@ -400,7 +540,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(TimeFormatLocalization: case EnumType::kUseActiveLocale: return val; default: - return static_cast(12); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(TimeFormatLocalization::HourFormatEnum val) @@ -413,7 +553,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(TimeFormatLocalization: case EnumType::kUseActiveLocale: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } @@ -427,7 +567,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(UnitLocalization::TempU case EnumType::kKelvin: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } @@ -471,7 +611,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::BatApprove case EnumType::kZincCerium: return val; default: - return static_cast(33); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::BatChargeFaultEnum val) @@ -492,7 +632,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::BatChargeF case EnumType::kSafetyTimeout: return val; default: - return static_cast(11); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::BatChargeLevelEnum val) @@ -505,7 +645,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::BatChargeL case EnumType::kCritical: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::BatChargeStateEnum val) @@ -519,7 +659,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::BatChargeS case EnumType::kIsNotCharging: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::BatCommonDesignationEnum val) @@ -610,7 +750,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::BatCommonD case EnumType::k32600: return val; default: - return static_cast(81); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::BatFaultEnum val) @@ -623,7 +763,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::BatFaultEn case EnumType::kUnderTemp: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::BatReplaceabilityEnum val) @@ -637,7 +777,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::BatReplace case EnumType::kFactoryReplaceable: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::PowerSourceStatusEnum val) @@ -651,7 +791,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::PowerSourc case EnumType::kUnavailable: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::WiredCurrentTypeEnum val) @@ -663,7 +803,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::WiredCurre case EnumType::kDc: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::WiredFaultEnum val) @@ -676,7 +816,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(PowerSource::WiredFault case EnumType::kUnderVoltage: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } @@ -692,7 +832,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(GeneralCommissioning::C case EnumType::kBusyWithOtherAdmin: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(GeneralCommissioning::RegulatoryLocationTypeEnum val) @@ -705,7 +845,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(GeneralCommissioning::R case EnumType::kIndoorOutdoor: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } @@ -729,7 +869,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(NetworkCommissioning::N case EnumType::kUnknownError: return val; default: - return static_cast(13); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(NetworkCommissioning::WiFiBandEnum val) @@ -745,7 +885,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(NetworkCommissioning::W case EnumType::k1g: return val; default: - return static_cast(6); + return EnumType::kUnknownEnumValue; } } @@ -759,7 +899,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DiagnosticLogs::IntentE case EnumType::kCrashLogs: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DiagnosticLogs::StatusEnum val) @@ -774,7 +914,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DiagnosticLogs::StatusE case EnumType::kDenied: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DiagnosticLogs::TransferProtocolEnum val) @@ -786,7 +926,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DiagnosticLogs::Transfe case EnumType::kBdx: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } @@ -804,7 +944,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(GeneralDiagnostics::Boo case EnumType::kSoftwareReset: return val; default: - return static_cast(7); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(GeneralDiagnostics::HardwareFaultEnum val) @@ -825,7 +965,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(GeneralDiagnostics::Har case EnumType::kTamperDetected: return val; default: - return static_cast(11); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(GeneralDiagnostics::InterfaceTypeEnum val) @@ -840,7 +980,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(GeneralDiagnostics::Int case EnumType::kThread: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(GeneralDiagnostics::NetworkFaultEnum val) @@ -854,7 +994,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(GeneralDiagnostics::Net case EnumType::kConnectionFailed: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(GeneralDiagnostics::RadioFaultEnum val) @@ -871,7 +1011,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(GeneralDiagnostics::Rad case EnumType::kEthernetFault: return val; default: - return static_cast(7); + return EnumType::kUnknownEnumValue; } } @@ -884,7 +1024,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ThreadNetworkDiagnostic case EnumType::kNotConnected: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(ThreadNetworkDiagnostics::NetworkFaultEnum val) @@ -898,7 +1038,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ThreadNetworkDiagnostic case EnumType::kNetworkJammed: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(ThreadNetworkDiagnostics::RoutingRoleEnum val) @@ -915,7 +1055,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ThreadNetworkDiagnostic case EnumType::kLeader: return val; default: - return static_cast(7); + return EnumType::kUnknownEnumValue; } } @@ -930,7 +1070,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(WiFiNetworkDiagnostics: case EnumType::kSsidNotFound: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(WiFiNetworkDiagnostics::ConnectionStatusEnum val) @@ -942,7 +1082,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(WiFiNetworkDiagnostics: case EnumType::kNotConnected: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(WiFiNetworkDiagnostics::SecurityTypeEnum val) @@ -958,7 +1098,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(WiFiNetworkDiagnostics: case EnumType::kWpa3: return val; default: - return static_cast(6); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(WiFiNetworkDiagnostics::WiFiVersionEnum val) @@ -975,7 +1115,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(WiFiNetworkDiagnostics: case EnumType::kAh: return val; default: - return static_cast(7); + return EnumType::kUnknownEnumValue; } } @@ -996,7 +1136,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(EthernetNetworkDiagnost case EnumType::kRate400G: return val; default: - return static_cast(10); + return EnumType::kUnknownEnumValue; } } @@ -1012,7 +1152,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(TimeSynchronization::Gr case EnumType::kMicrosecondsGranularity: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(TimeSynchronization::StatusCode val) @@ -1023,7 +1163,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(TimeSynchronization::St case EnumType::kTimeNotAccepted: return val; default: - return static_cast(0); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(TimeSynchronization::TimeSourceEnum val) @@ -1050,7 +1190,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(TimeSynchronization::Ti case EnumType::kGnss: return val; default: - return static_cast(17); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(TimeSynchronization::TimeZoneDatabaseEnum val) @@ -1063,7 +1203,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(TimeSynchronization::Ti case EnumType::kNone: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } @@ -1095,7 +1235,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(BridgedDeviceBasicInfor case EnumType::kGold: return val; default: - return static_cast(21); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(BridgedDeviceBasicInformation::ProductFinishEnum val) @@ -1111,7 +1251,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(BridgedDeviceBasicInfor case EnumType::kFabric: return val; default: - return static_cast(6); + return EnumType::kUnknownEnumValue; } } @@ -1125,7 +1265,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(AdministratorCommission case EnumType::kBasicWindowOpen: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(AdministratorCommissioning::StatusCode val) @@ -1138,7 +1278,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(AdministratorCommission case EnumType::kWindowNotOpen: return val; default: - return static_cast(0); + return EnumType::kUnknownEnumValue; } } @@ -1151,7 +1291,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OperationalCredentials: case EnumType::kPAICertificate: return val; default: - return static_cast(0); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(OperationalCredentials::NodeOperationalCertStatusEnum val) @@ -1171,7 +1311,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OperationalCredentials: case EnumType::kInvalidFabricIndex: return val; default: - return static_cast(7); + return EnumType::kUnknownEnumValue; } } @@ -1184,7 +1324,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(GroupKeyManagement::Gro case EnumType::kCacheAndSync: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } @@ -1197,7 +1337,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(IcdManagement::Operatin case EnumType::kLit: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } @@ -1212,36 +1352,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Timer::TimerStatusEnum case EnumType::kReady: return val; default: - return static_cast(4); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(OvenCavityOperationalState::ErrorStateEnum val) -{ - using EnumType = OvenCavityOperationalState::ErrorStateEnum; - switch (val) - { - case EnumType::kNoError: - case EnumType::kUnableToStartOrResume: - case EnumType::kUnableToCompleteOperation: - case EnumType::kCommandInvalidInState: - return val; - default: - return static_cast(4); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(OvenCavityOperationalState::OperationalStateEnum val) -{ - using EnumType = OvenCavityOperationalState::OperationalStateEnum; - switch (val) - { - case EnumType::kStopped: - case EnumType::kRunning: - case EnumType::kPaused: - case EnumType::kError: - return val; - default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } @@ -1261,7 +1372,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OvenMode::ModeTag val) case EnumType::kProofing: return val; default: - return static_cast(0); + return EnumType::kUnknownEnumValue; } } @@ -1276,7 +1387,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(LaundryDryerControls::D case EnumType::kMax: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } @@ -1291,7 +1402,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(LaundryWasherControls:: case EnumType::kMax: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } @@ -1309,7 +1420,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(AirQuality::AirQualityE case EnumType::kExtremelyPoor: return val; default: - return static_cast(7); + return EnumType::kUnknownEnumValue; } } @@ -1323,7 +1434,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(SmokeCoAlarm::AlarmStat case EnumType::kCritical: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(SmokeCoAlarm::ContaminationStateEnum val) @@ -1337,7 +1448,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(SmokeCoAlarm::Contamina case EnumType::kCritical: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(SmokeCoAlarm::EndOfServiceEnum val) @@ -1349,7 +1460,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(SmokeCoAlarm::EndOfServ case EnumType::kExpired: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(SmokeCoAlarm::ExpressedStateEnum val) @@ -1368,7 +1479,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(SmokeCoAlarm::Expressed case EnumType::kInterconnectCO: return val; default: - return static_cast(9); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(SmokeCoAlarm::MuteStateEnum val) @@ -1380,7 +1491,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(SmokeCoAlarm::MuteState case EnumType::kMuted: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(SmokeCoAlarm::SensitivityEnum val) @@ -1393,7 +1504,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(SmokeCoAlarm::Sensitivi case EnumType::kLow: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } @@ -1406,118 +1517,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(MicrowaveOvenMode::Mode case EnumType::kDefrost: return val; default: - return static_cast(0); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(OperationalState::ErrorStateEnum val) -{ - using EnumType = OperationalState::ErrorStateEnum; - switch (val) - { - case EnumType::kNoError: - case EnumType::kUnableToStartOrResume: - case EnumType::kUnableToCompleteOperation: - case EnumType::kCommandInvalidInState: - return val; - default: - return static_cast(4); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(OperationalState::OperationalStateEnum val) -{ - using EnumType = OperationalState::OperationalStateEnum; - switch (val) - { - case EnumType::kStopped: - case EnumType::kRunning: - case EnumType::kPaused: - case EnumType::kError: - return val; - default: - return static_cast(4); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(HepaFilterMonitoring::ChangeIndicationEnum val) -{ - using EnumType = HepaFilterMonitoring::ChangeIndicationEnum; - switch (val) - { - case EnumType::kOk: - case EnumType::kWarning: - case EnumType::kCritical: - return val; - default: - return static_cast(3); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(HepaFilterMonitoring::DegradationDirectionEnum val) -{ - using EnumType = HepaFilterMonitoring::DegradationDirectionEnum; - switch (val) - { - case EnumType::kUp: - case EnumType::kDown: - return val; - default: - return static_cast(2); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(HepaFilterMonitoring::ProductIdentifierTypeEnum val) -{ - using EnumType = HepaFilterMonitoring::ProductIdentifierTypeEnum; - switch (val) - { - case EnumType::kUpc: - case EnumType::kGtin8: - case EnumType::kEan: - case EnumType::kGtin14: - case EnumType::kOem: - return val; - default: - return static_cast(5); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(ActivatedCarbonFilterMonitoring::ChangeIndicationEnum val) -{ - using EnumType = ActivatedCarbonFilterMonitoring::ChangeIndicationEnum; - switch (val) - { - case EnumType::kOk: - case EnumType::kWarning: - case EnumType::kCritical: - return val; - default: - return static_cast(3); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(ActivatedCarbonFilterMonitoring::DegradationDirectionEnum val) -{ - using EnumType = ActivatedCarbonFilterMonitoring::DegradationDirectionEnum; - switch (val) - { - case EnumType::kUp: - case EnumType::kDown: - return val; - default: - return static_cast(2); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(ActivatedCarbonFilterMonitoring::ProductIdentifierTypeEnum val) -{ - using EnumType = ActivatedCarbonFilterMonitoring::ProductIdentifierTypeEnum; - switch (val) - { - case EnumType::kUpc: - case EnumType::kGtin8: - case EnumType::kEan: - case EnumType::kGtin14: - case EnumType::kOem: - return val; - default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } @@ -1529,7 +1529,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ValveConfigurationAndCo case EnumType::kFailureDueToFault: return val; default: - return static_cast(0); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(ValveConfigurationAndControl::ValveStateEnum val) @@ -1542,33 +1542,21 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ValveConfigurationAndCo case EnumType::kTransitioning: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } -static auto __attribute__((unused)) EnsureKnownEnumValue(ElectricalEnergyMeasurement::MeasurementTypeEnum val) +static auto __attribute__((unused)) EnsureKnownEnumValue(ElectricalPowerMeasurement::PowerModeEnum val) { - using EnumType = ElectricalEnergyMeasurement::MeasurementTypeEnum; + using EnumType = ElectricalPowerMeasurement::PowerModeEnum; switch (val) { - case EnumType::kUnspecified: - case EnumType::kVoltage: - case EnumType::kActiveCurrent: - case EnumType::kReactiveCurrent: - case EnumType::kApparentCurrent: - case EnumType::kActivePower: - case EnumType::kReactivePower: - case EnumType::kApparentPower: - case EnumType::kRMSVoltage: - case EnumType::kRMSCurrent: - case EnumType::kRMSPower: - case EnumType::kFrequency: - case EnumType::kPowerFactor: - case EnumType::kNeutralCurrent: - case EnumType::kElectricalEnergy: + case EnumType::kUnknown: + case EnumType::kDc: + case EnumType::kAc: return val; default: - return static_cast(15); + return EnumType::kUnknownEnumValue; } } @@ -1589,7 +1577,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadContr case EnumType::kServiceDisconnect: return val; default: - return static_cast(10); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadControl::HeatingSourceEnum val) @@ -1602,7 +1590,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadContr case EnumType::kNonElectric: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadControl::LoadControlEventChangeSourceEnum val) @@ -1614,7 +1602,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadContr case EnumType::kUserAction: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadControl::LoadControlEventStatusEnum val) @@ -1637,7 +1625,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadContr case EnumType::kFailed: return val; default: - return static_cast(13); + return EnumType::kUnknownEnumValue; } } @@ -1653,7 +1641,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Messages::FutureMessage case EnumType::kBanned: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Messages::MessagePriorityEnum val) @@ -1667,7 +1655,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Messages::MessagePriori case EnumType::kCritical: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } @@ -1680,7 +1668,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement: case EnumType::kGridOptimization: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement::CauseEnum val) @@ -1695,7 +1683,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement: case EnumType::kCancelled: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement::CostTypeEnum val) @@ -1709,7 +1697,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement: case EnumType::kTemperature: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement::ESAStateEnum val) @@ -1724,7 +1712,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement: case EnumType::kPaused: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement::ESATypeEnum val) @@ -1749,7 +1737,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement: case EnumType::kOther: return val; default: - return static_cast(14); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement::ForecastUpdateReasonEnum val) @@ -1762,7 +1750,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement: case EnumType::kGridOptimization: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement::OptOutStateEnum val) @@ -1776,7 +1764,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement: case EnumType::kOptOut: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } @@ -1790,7 +1778,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(EnergyEvse::EnergyTrans case EnumType::kOther: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(EnergyEvse::FaultStateEnum val) @@ -1817,7 +1805,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(EnergyEvse::FaultStateE case EnumType::kOther: return val; default: - return static_cast(16); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(EnergyEvse::StateEnum val) @@ -1834,7 +1822,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(EnergyEvse::StateEnum v case EnumType::kFault: return val; default: - return static_cast(7); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(EnergyEvse::SupplyStateEnum val) @@ -1849,7 +1837,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(EnergyEvse::SupplyState case EnumType::kDisabledDiagnostics: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } @@ -1864,7 +1852,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(EnergyPreference::Energ case EnumType::kWaterConsumption: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } @@ -1883,7 +1871,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::AlarmCodeEnum case EnumType::kForcedUser: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::CredentialRuleEnum val) @@ -1896,7 +1884,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::CredentialRul case EnumType::kTri: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::CredentialTypeEnum val) @@ -1915,7 +1903,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::CredentialTyp case EnumType::kAliroNonEvictableEndpointKey: return val; default: - return static_cast(9); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DataOperationTypeEnum val) @@ -1928,7 +1916,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DataOperation case EnumType::kModify: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DlLockState val) @@ -1942,7 +1930,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DlLockState v case EnumType::kUnlatched: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DlLockType val) @@ -1964,7 +1952,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DlLockType va case EnumType::kEurocylinder: return val; default: - return static_cast(12); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DlStatus val) @@ -1981,7 +1969,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DlStatus val) case EnumType::kNotFound: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DoorLockOperationEventCode val) @@ -2006,7 +1994,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DoorLockOpera case EnumType::kManualUnlock: return val; default: - return static_cast(15); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DoorLockProgrammingEventCode val) @@ -2023,7 +2011,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DoorLockProgr case EnumType::kIdDeleted: return val; default: - return static_cast(7); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DoorLockSetPinOrIdStatus val) @@ -2037,7 +2025,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DoorLockSetPi case EnumType::kDuplicateCodeError: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DoorLockUserStatus val) @@ -2051,7 +2039,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DoorLockUserS case EnumType::kNotSupported: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DoorLockUserType val) @@ -2067,7 +2055,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DoorLockUserT case EnumType::kNotSupported: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DoorStateEnum val) @@ -2083,7 +2071,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::DoorStateEnum case EnumType::kDoorAjar: return val; default: - return static_cast(6); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::LockDataTypeEnum val) @@ -2107,7 +2095,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::LockDataTypeE case EnumType::kAliroNonEvictableEndpointKey: return val; default: - return static_cast(14); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::LockOperationTypeEnum val) @@ -2122,7 +2110,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::LockOperation case EnumType::kUnlatch: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::OperatingModeEnum val) @@ -2137,7 +2125,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::OperatingMode case EnumType::kPassage: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::OperationErrorEnum val) @@ -2152,7 +2140,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::OperationErro case EnumType::kInsufficientBattery: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::OperationSourceEnum val) @@ -2173,7 +2161,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::OperationSour case EnumType::kAliro: return val; default: - return static_cast(11); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::UserStatusEnum val) @@ -2186,7 +2174,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::UserStatusEnu case EnumType::kOccupiedDisabled: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::UserTypeEnum val) @@ -2206,7 +2194,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::UserTypeEnum case EnumType::kRemoteOnlyUser: return val; default: - return static_cast(10); + return EnumType::kUnknownEnumValue; } } @@ -2242,7 +2230,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(WindowCovering::EndProd case EnumType::kUnknown: return val; default: - return static_cast(24); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(WindowCovering::Type val) @@ -2263,7 +2251,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(WindowCovering::Type va case EnumType::kUnknown: return val; default: - return static_cast(10); + return EnumType::kUnknownEnumValue; } } @@ -2280,7 +2268,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(PumpConfigurationAndCon case EnumType::kAutomatic: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(PumpConfigurationAndControl::OperationModeEnum val) @@ -2294,7 +2282,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(PumpConfigurationAndCon case EnumType::kLocal: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } @@ -2306,7 +2294,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::ACCapacityF case EnumType::kBTUh: return val; default: - return static_cast(1); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::ACCompressorTypeEnum val) @@ -2320,7 +2308,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::ACCompresso case EnumType::kT3: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::ACLouverPositionEnum val) @@ -2335,7 +2323,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::ACLouverPos case EnumType::kThreeQuarters: return val; default: - return static_cast(0); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::ACRefrigerantTypeEnum val) @@ -2349,7 +2337,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::ACRefrigera case EnumType::kR407c: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::ACTypeEnum val) @@ -2364,7 +2352,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::ACTypeEnum case EnumType::kHeatPumpInverter: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::ControlSequenceOfOperationEnum val) @@ -2380,7 +2368,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::ControlSequ case EnumType::kCoolingAndHeatingWithReheat: return val; default: - return static_cast(6); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::PresetScenarioEnum val) @@ -2397,7 +2385,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::PresetScena case EnumType::kUserDefined: return val; default: - return static_cast(7); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::SetpointChangeSourceEnum val) @@ -2410,7 +2398,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::SetpointCha case EnumType::kExternal: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::SetpointRaiseLowerModeEnum val) @@ -2423,7 +2411,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::SetpointRai case EnumType::kBoth: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::StartOfWeekEnum val) @@ -2440,7 +2428,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::StartOfWeek case EnumType::kSaturday: return val; default: - return static_cast(7); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::SystemModeEnum val) @@ -2459,7 +2447,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::SystemModeE case EnumType::kSleep: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::TemperatureSetpointHoldEnum val) @@ -2471,7 +2459,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::Temperature case EnumType::kSetpointHoldOn: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::ThermostatRunningModeEnum val) @@ -2484,7 +2472,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Thermostat::ThermostatR case EnumType::kHeat: return val; default: - return static_cast(1); + return EnumType::kUnknownEnumValue; } } @@ -2497,7 +2485,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(FanControl::AirflowDire case EnumType::kReverse: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(FanControl::FanModeEnum val) @@ -2514,7 +2502,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(FanControl::FanModeEnum case EnumType::kSmart: return val; default: - return static_cast(7); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(FanControl::FanModeSequenceEnum val) @@ -2530,7 +2518,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(FanControl::FanModeSequ case EnumType::kOffHigh: return val; default: - return static_cast(6); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(FanControl::StepDirectionEnum val) @@ -2542,7 +2530,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(FanControl::StepDirecti case EnumType::kDecrease: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } @@ -2559,7 +2547,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ThermostatUserInterface case EnumType::kLockout5: return val; default: - return static_cast(6); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) @@ -2572,7 +2560,7 @@ EnsureKnownEnumValue(ThermostatUserInterfaceConfiguration::ScheduleProgrammingVi case EnumType::kScheduleProgrammingDenied: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(ThermostatUserInterfaceConfiguration::TemperatureDisplayModeEnum val) @@ -2584,7 +2572,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ThermostatUserInterface case EnumType::kFahrenheit: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } @@ -2598,7 +2586,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::ColorLoop case EnumType::kActivateFromEnhancedCurrentHue: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::ColorLoopDirection val) @@ -2610,7 +2598,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::ColorLoop case EnumType::kIncrementHue: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::ColorMode val) @@ -2623,7 +2611,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::ColorMode case EnumType::kColorTemperature: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::HueDirection val) @@ -2637,7 +2625,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::HueDirect case EnumType::kDown: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::HueMoveMode val) @@ -2650,7 +2638,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::HueMoveMo case EnumType::kDown: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::HueStepMode val) @@ -2662,7 +2650,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::HueStepMo case EnumType::kDown: return val; default: - return static_cast(0); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::SaturationMoveMode val) @@ -2675,7 +2663,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::Saturatio case EnumType::kDown: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::SaturationStepMode val) @@ -2687,7 +2675,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::Saturatio case EnumType::kDown: return val; default: - return static_cast(0); + return EnumType::kUnknownEnumValue; } } @@ -2700,7 +2688,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(IlluminanceMeasurement: case EnumType::kCmos: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } @@ -2715,479 +2703,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OccupancySensing::Occup case EnumType::kPhysicalContact: return val; default: - return static_cast(4); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(CarbonMonoxideConcentrationMeasurement::LevelValueEnum val) -{ - using EnumType = CarbonMonoxideConcentrationMeasurement::LevelValueEnum; - switch (val) - { - case EnumType::kUnknown: - case EnumType::kLow: - case EnumType::kMedium: - case EnumType::kHigh: - case EnumType::kCritical: - return val; - default: - return static_cast(5); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(CarbonMonoxideConcentrationMeasurement::MeasurementMediumEnum val) -{ - using EnumType = CarbonMonoxideConcentrationMeasurement::MeasurementMediumEnum; - switch (val) - { - case EnumType::kAir: - case EnumType::kWater: - case EnumType::kSoil: - return val; - default: - return static_cast(3); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(CarbonMonoxideConcentrationMeasurement::MeasurementUnitEnum val) -{ - using EnumType = CarbonMonoxideConcentrationMeasurement::MeasurementUnitEnum; - switch (val) - { - case EnumType::kPpm: - case EnumType::kPpb: - case EnumType::kPpt: - case EnumType::kMgm3: - case EnumType::kUgm3: - case EnumType::kNgm3: - case EnumType::kPm3: - case EnumType::kBqm3: - return val; - default: - return static_cast(8); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(CarbonDioxideConcentrationMeasurement::LevelValueEnum val) -{ - using EnumType = CarbonDioxideConcentrationMeasurement::LevelValueEnum; - switch (val) - { - case EnumType::kUnknown: - case EnumType::kLow: - case EnumType::kMedium: - case EnumType::kHigh: - case EnumType::kCritical: - return val; - default: - return static_cast(5); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(CarbonDioxideConcentrationMeasurement::MeasurementMediumEnum val) -{ - using EnumType = CarbonDioxideConcentrationMeasurement::MeasurementMediumEnum; - switch (val) - { - case EnumType::kAir: - case EnumType::kWater: - case EnumType::kSoil: - return val; - default: - return static_cast(3); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(CarbonDioxideConcentrationMeasurement::MeasurementUnitEnum val) -{ - using EnumType = CarbonDioxideConcentrationMeasurement::MeasurementUnitEnum; - switch (val) - { - case EnumType::kPpm: - case EnumType::kPpb: - case EnumType::kPpt: - case EnumType::kMgm3: - case EnumType::kUgm3: - case EnumType::kNgm3: - case EnumType::kPm3: - case EnumType::kBqm3: - return val; - default: - return static_cast(8); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(NitrogenDioxideConcentrationMeasurement::LevelValueEnum val) -{ - using EnumType = NitrogenDioxideConcentrationMeasurement::LevelValueEnum; - switch (val) - { - case EnumType::kUnknown: - case EnumType::kLow: - case EnumType::kMedium: - case EnumType::kHigh: - case EnumType::kCritical: - return val; - default: - return static_cast(5); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(NitrogenDioxideConcentrationMeasurement::MeasurementMediumEnum val) -{ - using EnumType = NitrogenDioxideConcentrationMeasurement::MeasurementMediumEnum; - switch (val) - { - case EnumType::kAir: - case EnumType::kWater: - case EnumType::kSoil: - return val; - default: - return static_cast(3); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(NitrogenDioxideConcentrationMeasurement::MeasurementUnitEnum val) -{ - using EnumType = NitrogenDioxideConcentrationMeasurement::MeasurementUnitEnum; - switch (val) - { - case EnumType::kPpm: - case EnumType::kPpb: - case EnumType::kPpt: - case EnumType::kMgm3: - case EnumType::kUgm3: - case EnumType::kNgm3: - case EnumType::kPm3: - case EnumType::kBqm3: - return val; - default: - return static_cast(8); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(OzoneConcentrationMeasurement::LevelValueEnum val) -{ - using EnumType = OzoneConcentrationMeasurement::LevelValueEnum; - switch (val) - { - case EnumType::kUnknown: - case EnumType::kLow: - case EnumType::kMedium: - case EnumType::kHigh: - case EnumType::kCritical: - return val; - default: - return static_cast(5); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(OzoneConcentrationMeasurement::MeasurementMediumEnum val) -{ - using EnumType = OzoneConcentrationMeasurement::MeasurementMediumEnum; - switch (val) - { - case EnumType::kAir: - case EnumType::kWater: - case EnumType::kSoil: - return val; - default: - return static_cast(3); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(OzoneConcentrationMeasurement::MeasurementUnitEnum val) -{ - using EnumType = OzoneConcentrationMeasurement::MeasurementUnitEnum; - switch (val) - { - case EnumType::kPpm: - case EnumType::kPpb: - case EnumType::kPpt: - case EnumType::kMgm3: - case EnumType::kUgm3: - case EnumType::kNgm3: - case EnumType::kPm3: - case EnumType::kBqm3: - return val; - default: - return static_cast(8); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(Pm25ConcentrationMeasurement::LevelValueEnum val) -{ - using EnumType = Pm25ConcentrationMeasurement::LevelValueEnum; - switch (val) - { - case EnumType::kUnknown: - case EnumType::kLow: - case EnumType::kMedium: - case EnumType::kHigh: - case EnumType::kCritical: - return val; - default: - return static_cast(5); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(Pm25ConcentrationMeasurement::MeasurementMediumEnum val) -{ - using EnumType = Pm25ConcentrationMeasurement::MeasurementMediumEnum; - switch (val) - { - case EnumType::kAir: - case EnumType::kWater: - case EnumType::kSoil: - return val; - default: - return static_cast(3); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(Pm25ConcentrationMeasurement::MeasurementUnitEnum val) -{ - using EnumType = Pm25ConcentrationMeasurement::MeasurementUnitEnum; - switch (val) - { - case EnumType::kPpm: - case EnumType::kPpb: - case EnumType::kPpt: - case EnumType::kMgm3: - case EnumType::kUgm3: - case EnumType::kNgm3: - case EnumType::kPm3: - case EnumType::kBqm3: - return val; - default: - return static_cast(8); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(FormaldehydeConcentrationMeasurement::LevelValueEnum val) -{ - using EnumType = FormaldehydeConcentrationMeasurement::LevelValueEnum; - switch (val) - { - case EnumType::kUnknown: - case EnumType::kLow: - case EnumType::kMedium: - case EnumType::kHigh: - case EnumType::kCritical: - return val; - default: - return static_cast(5); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(FormaldehydeConcentrationMeasurement::MeasurementMediumEnum val) -{ - using EnumType = FormaldehydeConcentrationMeasurement::MeasurementMediumEnum; - switch (val) - { - case EnumType::kAir: - case EnumType::kWater: - case EnumType::kSoil: - return val; - default: - return static_cast(3); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(FormaldehydeConcentrationMeasurement::MeasurementUnitEnum val) -{ - using EnumType = FormaldehydeConcentrationMeasurement::MeasurementUnitEnum; - switch (val) - { - case EnumType::kPpm: - case EnumType::kPpb: - case EnumType::kPpt: - case EnumType::kMgm3: - case EnumType::kUgm3: - case EnumType::kNgm3: - case EnumType::kPm3: - case EnumType::kBqm3: - return val; - default: - return static_cast(8); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(Pm1ConcentrationMeasurement::LevelValueEnum val) -{ - using EnumType = Pm1ConcentrationMeasurement::LevelValueEnum; - switch (val) - { - case EnumType::kUnknown: - case EnumType::kLow: - case EnumType::kMedium: - case EnumType::kHigh: - case EnumType::kCritical: - return val; - default: - return static_cast(5); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(Pm1ConcentrationMeasurement::MeasurementMediumEnum val) -{ - using EnumType = Pm1ConcentrationMeasurement::MeasurementMediumEnum; - switch (val) - { - case EnumType::kAir: - case EnumType::kWater: - case EnumType::kSoil: - return val; - default: - return static_cast(3); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(Pm1ConcentrationMeasurement::MeasurementUnitEnum val) -{ - using EnumType = Pm1ConcentrationMeasurement::MeasurementUnitEnum; - switch (val) - { - case EnumType::kPpm: - case EnumType::kPpb: - case EnumType::kPpt: - case EnumType::kMgm3: - case EnumType::kUgm3: - case EnumType::kNgm3: - case EnumType::kPm3: - case EnumType::kBqm3: - return val; - default: - return static_cast(8); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(Pm10ConcentrationMeasurement::LevelValueEnum val) -{ - using EnumType = Pm10ConcentrationMeasurement::LevelValueEnum; - switch (val) - { - case EnumType::kUnknown: - case EnumType::kLow: - case EnumType::kMedium: - case EnumType::kHigh: - case EnumType::kCritical: - return val; - default: - return static_cast(5); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(Pm10ConcentrationMeasurement::MeasurementMediumEnum val) -{ - using EnumType = Pm10ConcentrationMeasurement::MeasurementMediumEnum; - switch (val) - { - case EnumType::kAir: - case EnumType::kWater: - case EnumType::kSoil: - return val; - default: - return static_cast(3); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(Pm10ConcentrationMeasurement::MeasurementUnitEnum val) -{ - using EnumType = Pm10ConcentrationMeasurement::MeasurementUnitEnum; - switch (val) - { - case EnumType::kPpm: - case EnumType::kPpb: - case EnumType::kPpt: - case EnumType::kMgm3: - case EnumType::kUgm3: - case EnumType::kNgm3: - case EnumType::kPm3: - case EnumType::kBqm3: - return val; - default: - return static_cast(8); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(TotalVolatileOrganicCompoundsConcentrationMeasurement::LevelValueEnum val) -{ - using EnumType = TotalVolatileOrganicCompoundsConcentrationMeasurement::LevelValueEnum; - switch (val) - { - case EnumType::kUnknown: - case EnumType::kLow: - case EnumType::kMedium: - case EnumType::kHigh: - case EnumType::kCritical: - return val; - default: - return static_cast(5); - } -} -static auto __attribute__((unused)) -EnsureKnownEnumValue(TotalVolatileOrganicCompoundsConcentrationMeasurement::MeasurementMediumEnum val) -{ - using EnumType = TotalVolatileOrganicCompoundsConcentrationMeasurement::MeasurementMediumEnum; - switch (val) - { - case EnumType::kAir: - case EnumType::kWater: - case EnumType::kSoil: - return val; - default: - return static_cast(3); - } -} -static auto __attribute__((unused)) -EnsureKnownEnumValue(TotalVolatileOrganicCompoundsConcentrationMeasurement::MeasurementUnitEnum val) -{ - using EnumType = TotalVolatileOrganicCompoundsConcentrationMeasurement::MeasurementUnitEnum; - switch (val) - { - case EnumType::kPpm: - case EnumType::kPpb: - case EnumType::kPpt: - case EnumType::kMgm3: - case EnumType::kUgm3: - case EnumType::kNgm3: - case EnumType::kPm3: - case EnumType::kBqm3: - return val; - default: - return static_cast(8); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(RadonConcentrationMeasurement::LevelValueEnum val) -{ - using EnumType = RadonConcentrationMeasurement::LevelValueEnum; - switch (val) - { - case EnumType::kUnknown: - case EnumType::kLow: - case EnumType::kMedium: - case EnumType::kHigh: - case EnumType::kCritical: - return val; - default: - return static_cast(5); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(RadonConcentrationMeasurement::MeasurementMediumEnum val) -{ - using EnumType = RadonConcentrationMeasurement::MeasurementMediumEnum; - switch (val) - { - case EnumType::kAir: - case EnumType::kWater: - case EnumType::kSoil: - return val; - default: - return static_cast(3); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(RadonConcentrationMeasurement::MeasurementUnitEnum val) -{ - using EnumType = RadonConcentrationMeasurement::MeasurementUnitEnum; - switch (val) - { - case EnumType::kPpm: - case EnumType::kPpb: - case EnumType::kPpt: - case EnumType::kMgm3: - case EnumType::kUgm3: - case EnumType::kNgm3: - case EnumType::kPm3: - case EnumType::kBqm3: - return val; - default: - return static_cast(8); + return EnumType::kUnknownEnumValue; } } @@ -3202,7 +2718,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Channel::ChannelTypeEnu case EnumType::kOtt: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Channel::LineupInfoTypeEnum val) @@ -3213,7 +2729,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Channel::LineupInfoType case EnumType::kMso: return val; default: - return static_cast(1); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(Channel::StatusEnum val) @@ -3226,7 +2742,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Channel::StatusEnum val case EnumType::kNoMatches: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } @@ -3240,7 +2756,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(TargetNavigator::Status case EnumType::kNotAllowed: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } @@ -3269,7 +2785,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(MediaPlayback::Characte case EnumType::kKaraoke: return val; default: - return static_cast(18); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(MediaPlayback::PlaybackStateEnum val) @@ -3283,7 +2799,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(MediaPlayback::Playback case EnumType::kBuffering: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(MediaPlayback::StatusEnum val) @@ -3299,7 +2815,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(MediaPlayback::StatusEn case EnumType::kSeekOutOfRange: return val; default: - return static_cast(6); + return EnumType::kUnknownEnumValue; } } @@ -3322,7 +2838,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(MediaInput::InputTypeEn case EnumType::kOther: return val; default: - return static_cast(12); + return EnumType::kUnknownEnumValue; } } @@ -3419,7 +2935,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(KeypadInput::CECKeyCode case EnumType::kData: return val; default: - return static_cast(14); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(KeypadInput::StatusEnum val) @@ -3432,7 +2948,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(KeypadInput::StatusEnum case EnumType::kInvalidKeyInCurrentState: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } @@ -3461,7 +2977,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ContentLauncher::Charac case EnumType::kKaraoke: return val; default: - return static_cast(18); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(ContentLauncher::MetricTypeEnum val) @@ -3473,7 +2989,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ContentLauncher::Metric case EnumType::kPercentage: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(ContentLauncher::ParameterEnum val) @@ -3500,7 +3016,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ContentLauncher::Parame case EnumType::kAny: return val; default: - return static_cast(17); + return EnumType::kUnknownEnumValue; } } static auto __attribute__((unused)) EnsureKnownEnumValue(ContentLauncher::StatusEnum val) @@ -3515,7 +3031,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ContentLauncher::Status case EnumType::kAudioTrackNotAvailable: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } @@ -3532,7 +3048,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(AudioOutput::OutputType case EnumType::kOther: return val; default: - return static_cast(6); + return EnumType::kUnknownEnumValue; } } @@ -3546,7 +3062,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ApplicationLauncher::St case EnumType::kSystemBusy: return val; default: - return static_cast(3); + return EnumType::kUnknownEnumValue; } } @@ -3561,7 +3077,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ApplicationBasic::Appli case EnumType::kActiveVisibleNotFocus: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } @@ -3574,7 +3090,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ContentAppObserver::Sta case EnumType::kUnexpectedData: return val; default: - return static_cast(2); + return EnumType::kUnknownEnumValue; } } @@ -3589,7 +3105,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(UnitTesting::SimpleEnum case EnumType::kValueC: return val; default: - return static_cast(4); + return EnumType::kUnknownEnumValue; } } @@ -3605,7 +3121,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(FaultInjection::FaultTy case EnumType::kCertFault: return val; default: - return static_cast(5); + return EnumType::kUnknownEnumValue; } } diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index 585d9fe8b8f1e6..4f7102dbffcae3 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -25,6 +25,152 @@ namespace chip { namespace app { namespace Clusters { +namespace detail { +// Enums shared across multiple clusters. + +// Enum for ChangeIndicationEnum +enum class ChangeIndicationEnum : uint8_t +{ + kOk = 0x00, + kWarning = 0x01, + kCritical = 0x02, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 3, +}; + +// Enum for DegradationDirectionEnum +enum class DegradationDirectionEnum : uint8_t +{ + kUp = 0x00, + kDown = 0x01, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 2, +}; + +// Enum for ErrorStateEnum +enum class ErrorStateEnum : uint8_t +{ + kNoError = 0x00, + kUnableToStartOrResume = 0x01, + kUnableToCompleteOperation = 0x02, + kCommandInvalidInState = 0x03, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 4, +}; + +// Enum for LevelValueEnum +enum class LevelValueEnum : uint8_t +{ + kUnknown = 0x00, + kLow = 0x01, + kMedium = 0x02, + kHigh = 0x03, + kCritical = 0x04, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 5, +}; + +// Enum for MeasurementMediumEnum +enum class MeasurementMediumEnum : uint8_t +{ + kAir = 0x00, + kWater = 0x01, + kSoil = 0x02, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 3, +}; + +// Enum for MeasurementTypeEnum +enum class MeasurementTypeEnum : uint16_t +{ + kUnspecified = 0x00, + kVoltage = 0x01, + kActiveCurrent = 0x02, + kReactiveCurrent = 0x03, + kApparentCurrent = 0x04, + kActivePower = 0x05, + kReactivePower = 0x06, + kApparentPower = 0x07, + kRMSVoltage = 0x08, + kRMSCurrent = 0x09, + kRMSPower = 0x0A, + kFrequency = 0x0B, + kPowerFactor = 0x0C, + kNeutralCurrent = 0x0D, + kElectricalEnergy = 0x0E, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 15, +}; + +// Enum for MeasurementUnitEnum +enum class MeasurementUnitEnum : uint8_t +{ + kPpm = 0x00, + kPpb = 0x01, + kPpt = 0x02, + kMgm3 = 0x03, + kUgm3 = 0x04, + kNgm3 = 0x05, + kPm3 = 0x06, + kBqm3 = 0x07, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 8, +}; + +// Enum for OperationalStateEnum +enum class OperationalStateEnum : uint8_t +{ + kStopped = 0x00, + kRunning = 0x01, + kPaused = 0x02, + kError = 0x03, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 4, +}; + +// Enum for ProductIdentifierTypeEnum +enum class ProductIdentifierTypeEnum : uint8_t +{ + kUpc = 0x00, + kGtin8 = 0x01, + kEan = 0x02, + kGtin14 = 0x03, + kOem = 0x04, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 5, +}; + +// Bitmaps shared across multiple clusters. + +} // namespace detail + namespace Identify { // Enum for EffectIdentifierEnum @@ -1037,6 +1183,12 @@ enum class RadioFaultEnum : uint8_t // enum value. This specific should never be transmitted. kUnknownEnumValue = 7, }; + +// Bitmap for Feature +enum class Feature : uint32_t +{ + kDataModelTest = 0x1, +}; } // namespace GeneralDiagnostics namespace SoftwareDiagnostics { @@ -1516,33 +1668,9 @@ enum class Feature : uint32_t namespace OvenCavityOperationalState { -// Enum for ErrorStateEnum -enum class ErrorStateEnum : uint8_t -{ - kNoError = 0x00, - kUnableToStartOrResume = 0x01, - kUnableToCompleteOperation = 0x02, - kCommandInvalidInState = 0x03, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 4, -}; +using ErrorStateEnum = Clusters::detail::ErrorStateEnum; -// Enum for OperationalStateEnum -enum class OperationalStateEnum : uint8_t -{ - kStopped = 0x00, - kRunning = 0x01, - kPaused = 0x02, - kError = 0x03, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 4, -}; +using OperationalStateEnum = Clusters::detail::OperationalStateEnum; } // namespace OvenCavityOperationalState namespace OvenMode { @@ -1958,33 +2086,9 @@ enum class Feature : uint32_t namespace OperationalState { -// Enum for ErrorStateEnum -enum class ErrorStateEnum : uint8_t -{ - kNoError = 0x00, - kUnableToStartOrResume = 0x01, - kUnableToCompleteOperation = 0x02, - kCommandInvalidInState = 0x03, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 4, -}; +using ErrorStateEnum = Clusters::detail::ErrorStateEnum; -// Enum for OperationalStateEnum -enum class OperationalStateEnum : uint8_t -{ - kStopped = 0x00, - kRunning = 0x01, - kPaused = 0x02, - kError = 0x03, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 4, -}; +using OperationalStateEnum = Clusters::detail::OperationalStateEnum; } // namespace OperationalState namespace RvcOperationalState { @@ -2038,45 +2142,11 @@ enum class Feature : uint32_t namespace HepaFilterMonitoring { -// Enum for ChangeIndicationEnum -enum class ChangeIndicationEnum : uint8_t -{ - kOk = 0x00, - kWarning = 0x01, - kCritical = 0x02, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 3, -}; +using ChangeIndicationEnum = Clusters::detail::ChangeIndicationEnum; -// Enum for DegradationDirectionEnum -enum class DegradationDirectionEnum : uint8_t -{ - kUp = 0x00, - kDown = 0x01, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 2, -}; +using DegradationDirectionEnum = Clusters::detail::DegradationDirectionEnum; -// Enum for ProductIdentifierTypeEnum -enum class ProductIdentifierTypeEnum : uint8_t -{ - kUpc = 0x00, - kGtin8 = 0x01, - kEan = 0x02, - kGtin14 = 0x03, - kOem = 0x04, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 5, -}; +using ProductIdentifierTypeEnum = Clusters::detail::ProductIdentifierTypeEnum; // Bitmap for Feature enum class Feature : uint32_t @@ -2089,54 +2159,20 @@ enum class Feature : uint32_t namespace ActivatedCarbonFilterMonitoring { -// Enum for ChangeIndicationEnum -enum class ChangeIndicationEnum : uint8_t +using ChangeIndicationEnum = Clusters::detail::ChangeIndicationEnum; + +using DegradationDirectionEnum = Clusters::detail::DegradationDirectionEnum; + +using ProductIdentifierTypeEnum = Clusters::detail::ProductIdentifierTypeEnum; + +// Bitmap for Feature +enum class Feature : uint32_t { - kOk = 0x00, - kWarning = 0x01, - kCritical = 0x02, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 3, + kCondition = 0x1, + kWarning = 0x2, + kReplacementProductList = 0x4, }; - -// Enum for DegradationDirectionEnum -enum class DegradationDirectionEnum : uint8_t -{ - kUp = 0x00, - kDown = 0x01, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 2, -}; - -// Enum for ProductIdentifierTypeEnum -enum class ProductIdentifierTypeEnum : uint8_t -{ - kUpc = 0x00, - kGtin8 = 0x01, - kEan = 0x02, - kGtin14 = 0x03, - kOem = 0x04, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 5, -}; - -// Bitmap for Feature -enum class Feature : uint32_t -{ - kCondition = 0x1, - kWarning = 0x2, - kReplacementProductList = 0x4, -}; -} // namespace ActivatedCarbonFilterMonitoring +} // namespace ActivatedCarbonFilterMonitoring namespace BooleanStateConfiguration { @@ -2208,33 +2244,38 @@ enum class ValveFaultBitmap : uint16_t }; } // namespace ValveConfigurationAndControl -namespace ElectricalEnergyMeasurement { +namespace ElectricalPowerMeasurement { -// Enum for MeasurementTypeEnum -enum class MeasurementTypeEnum : uint16_t +using MeasurementTypeEnum = Clusters::detail::MeasurementTypeEnum; + +// Enum for PowerModeEnum +enum class PowerModeEnum : uint8_t { - kUnspecified = 0x00, - kVoltage = 0x01, - kActiveCurrent = 0x02, - kReactiveCurrent = 0x03, - kApparentCurrent = 0x04, - kActivePower = 0x05, - kReactivePower = 0x06, - kApparentPower = 0x07, - kRMSVoltage = 0x08, - kRMSCurrent = 0x09, - kRMSPower = 0x0A, - kFrequency = 0x0B, - kPowerFactor = 0x0C, - kNeutralCurrent = 0x0D, - kElectricalEnergy = 0x0E, + kUnknown = 0x00, + kDc = 0x01, + kAc = 0x02, // All received enum values that are not listed above will be mapped // to kUnknownEnumValue. This is a helper enum value that should only // be used by code to process how it handles receiving and unknown // enum value. This specific should never be transmitted. - kUnknownEnumValue = 15, + kUnknownEnumValue = 3, }; +// Bitmap for Feature +enum class Feature : uint32_t +{ + kDirectCurrent = 0x1, + kAlternatingCurrent = 0x2, + kPolyphasePower = 0x4, + kHarmonics = 0x8, + kPowerQuality = 0x10, +}; +} // namespace ElectricalPowerMeasurement + +namespace ElectricalEnergyMeasurement { + +using MeasurementTypeEnum = Clusters::detail::MeasurementTypeEnum; + // Bitmap for Feature enum class Feature : uint32_t { @@ -2664,6 +2705,18 @@ enum class Feature : uint32_t }; } // namespace EnergyPreference +namespace PowerTopology { + +// Bitmap for Feature +enum class Feature : uint32_t +{ + kNodeTopology = 0x1, + kTreeTopology = 0x2, + kSetTopology = 0x4, + kDynamicPowerFlow = 0x8, +}; +} // namespace PowerTopology + namespace EnergyEvseMode { // Enum for ModeTag @@ -4058,51 +4111,11 @@ enum class OccupancySensorTypeBitmap : uint8_t namespace CarbonMonoxideConcentrationMeasurement { -// Enum for LevelValueEnum -enum class LevelValueEnum : uint8_t -{ - kUnknown = 0x00, - kLow = 0x01, - kMedium = 0x02, - kHigh = 0x03, - kCritical = 0x04, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 5, -}; +using LevelValueEnum = Clusters::detail::LevelValueEnum; -// Enum for MeasurementMediumEnum -enum class MeasurementMediumEnum : uint8_t -{ - kAir = 0x00, - kWater = 0x01, - kSoil = 0x02, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 3, -}; +using MeasurementMediumEnum = Clusters::detail::MeasurementMediumEnum; -// Enum for MeasurementUnitEnum -enum class MeasurementUnitEnum : uint8_t -{ - kPpm = 0x00, - kPpb = 0x01, - kPpt = 0x02, - kMgm3 = 0x03, - kUgm3 = 0x04, - kNgm3 = 0x05, - kPm3 = 0x06, - kBqm3 = 0x07, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 8, -}; +using MeasurementUnitEnum = Clusters::detail::MeasurementUnitEnum; // Bitmap for Feature enum class Feature : uint32_t @@ -4118,51 +4131,11 @@ enum class Feature : uint32_t namespace CarbonDioxideConcentrationMeasurement { -// Enum for LevelValueEnum -enum class LevelValueEnum : uint8_t -{ - kUnknown = 0x00, - kLow = 0x01, - kMedium = 0x02, - kHigh = 0x03, - kCritical = 0x04, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 5, -}; +using LevelValueEnum = Clusters::detail::LevelValueEnum; -// Enum for MeasurementMediumEnum -enum class MeasurementMediumEnum : uint8_t -{ - kAir = 0x00, - kWater = 0x01, - kSoil = 0x02, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 3, -}; +using MeasurementMediumEnum = Clusters::detail::MeasurementMediumEnum; -// Enum for MeasurementUnitEnum -enum class MeasurementUnitEnum : uint8_t -{ - kPpm = 0x00, - kPpb = 0x01, - kPpt = 0x02, - kMgm3 = 0x03, - kUgm3 = 0x04, - kNgm3 = 0x05, - kPm3 = 0x06, - kBqm3 = 0x07, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 8, -}; +using MeasurementUnitEnum = Clusters::detail::MeasurementUnitEnum; // Bitmap for Feature enum class Feature : uint32_t @@ -4178,51 +4151,11 @@ enum class Feature : uint32_t namespace NitrogenDioxideConcentrationMeasurement { -// Enum for LevelValueEnum -enum class LevelValueEnum : uint8_t -{ - kUnknown = 0x00, - kLow = 0x01, - kMedium = 0x02, - kHigh = 0x03, - kCritical = 0x04, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 5, -}; +using LevelValueEnum = Clusters::detail::LevelValueEnum; -// Enum for MeasurementMediumEnum -enum class MeasurementMediumEnum : uint8_t -{ - kAir = 0x00, - kWater = 0x01, - kSoil = 0x02, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 3, -}; +using MeasurementMediumEnum = Clusters::detail::MeasurementMediumEnum; -// Enum for MeasurementUnitEnum -enum class MeasurementUnitEnum : uint8_t -{ - kPpm = 0x00, - kPpb = 0x01, - kPpt = 0x02, - kMgm3 = 0x03, - kUgm3 = 0x04, - kNgm3 = 0x05, - kPm3 = 0x06, - kBqm3 = 0x07, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 8, -}; +using MeasurementUnitEnum = Clusters::detail::MeasurementUnitEnum; // Bitmap for Feature enum class Feature : uint32_t @@ -4238,51 +4171,11 @@ enum class Feature : uint32_t namespace OzoneConcentrationMeasurement { -// Enum for LevelValueEnum -enum class LevelValueEnum : uint8_t -{ - kUnknown = 0x00, - kLow = 0x01, - kMedium = 0x02, - kHigh = 0x03, - kCritical = 0x04, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 5, -}; +using LevelValueEnum = Clusters::detail::LevelValueEnum; -// Enum for MeasurementMediumEnum -enum class MeasurementMediumEnum : uint8_t -{ - kAir = 0x00, - kWater = 0x01, - kSoil = 0x02, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 3, -}; +using MeasurementMediumEnum = Clusters::detail::MeasurementMediumEnum; -// Enum for MeasurementUnitEnum -enum class MeasurementUnitEnum : uint8_t -{ - kPpm = 0x00, - kPpb = 0x01, - kPpt = 0x02, - kMgm3 = 0x03, - kUgm3 = 0x04, - kNgm3 = 0x05, - kPm3 = 0x06, - kBqm3 = 0x07, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 8, -}; +using MeasurementUnitEnum = Clusters::detail::MeasurementUnitEnum; // Bitmap for Feature enum class Feature : uint32_t @@ -4298,51 +4191,11 @@ enum class Feature : uint32_t namespace Pm25ConcentrationMeasurement { -// Enum for LevelValueEnum -enum class LevelValueEnum : uint8_t -{ - kUnknown = 0x00, - kLow = 0x01, - kMedium = 0x02, - kHigh = 0x03, - kCritical = 0x04, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 5, -}; +using LevelValueEnum = Clusters::detail::LevelValueEnum; -// Enum for MeasurementMediumEnum -enum class MeasurementMediumEnum : uint8_t -{ - kAir = 0x00, - kWater = 0x01, - kSoil = 0x02, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 3, -}; +using MeasurementMediumEnum = Clusters::detail::MeasurementMediumEnum; -// Enum for MeasurementUnitEnum -enum class MeasurementUnitEnum : uint8_t -{ - kPpm = 0x00, - kPpb = 0x01, - kPpt = 0x02, - kMgm3 = 0x03, - kUgm3 = 0x04, - kNgm3 = 0x05, - kPm3 = 0x06, - kBqm3 = 0x07, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 8, -}; +using MeasurementUnitEnum = Clusters::detail::MeasurementUnitEnum; // Bitmap for Feature enum class Feature : uint32_t @@ -4358,51 +4211,11 @@ enum class Feature : uint32_t namespace FormaldehydeConcentrationMeasurement { -// Enum for LevelValueEnum -enum class LevelValueEnum : uint8_t -{ - kUnknown = 0x00, - kLow = 0x01, - kMedium = 0x02, - kHigh = 0x03, - kCritical = 0x04, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 5, -}; +using LevelValueEnum = Clusters::detail::LevelValueEnum; -// Enum for MeasurementMediumEnum -enum class MeasurementMediumEnum : uint8_t -{ - kAir = 0x00, - kWater = 0x01, - kSoil = 0x02, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 3, -}; +using MeasurementMediumEnum = Clusters::detail::MeasurementMediumEnum; -// Enum for MeasurementUnitEnum -enum class MeasurementUnitEnum : uint8_t -{ - kPpm = 0x00, - kPpb = 0x01, - kPpt = 0x02, - kMgm3 = 0x03, - kUgm3 = 0x04, - kNgm3 = 0x05, - kPm3 = 0x06, - kBqm3 = 0x07, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 8, -}; +using MeasurementUnitEnum = Clusters::detail::MeasurementUnitEnum; // Bitmap for Feature enum class Feature : uint32_t @@ -4418,51 +4231,11 @@ enum class Feature : uint32_t namespace Pm1ConcentrationMeasurement { -// Enum for LevelValueEnum -enum class LevelValueEnum : uint8_t -{ - kUnknown = 0x00, - kLow = 0x01, - kMedium = 0x02, - kHigh = 0x03, - kCritical = 0x04, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 5, -}; +using LevelValueEnum = Clusters::detail::LevelValueEnum; -// Enum for MeasurementMediumEnum -enum class MeasurementMediumEnum : uint8_t -{ - kAir = 0x00, - kWater = 0x01, - kSoil = 0x02, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 3, -}; +using MeasurementMediumEnum = Clusters::detail::MeasurementMediumEnum; -// Enum for MeasurementUnitEnum -enum class MeasurementUnitEnum : uint8_t -{ - kPpm = 0x00, - kPpb = 0x01, - kPpt = 0x02, - kMgm3 = 0x03, - kUgm3 = 0x04, - kNgm3 = 0x05, - kPm3 = 0x06, - kBqm3 = 0x07, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 8, -}; +using MeasurementUnitEnum = Clusters::detail::MeasurementUnitEnum; // Bitmap for Feature enum class Feature : uint32_t @@ -4478,51 +4251,11 @@ enum class Feature : uint32_t namespace Pm10ConcentrationMeasurement { -// Enum for LevelValueEnum -enum class LevelValueEnum : uint8_t -{ - kUnknown = 0x00, - kLow = 0x01, - kMedium = 0x02, - kHigh = 0x03, - kCritical = 0x04, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 5, -}; +using LevelValueEnum = Clusters::detail::LevelValueEnum; -// Enum for MeasurementMediumEnum -enum class MeasurementMediumEnum : uint8_t -{ - kAir = 0x00, - kWater = 0x01, - kSoil = 0x02, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 3, -}; +using MeasurementMediumEnum = Clusters::detail::MeasurementMediumEnum; -// Enum for MeasurementUnitEnum -enum class MeasurementUnitEnum : uint8_t -{ - kPpm = 0x00, - kPpb = 0x01, - kPpt = 0x02, - kMgm3 = 0x03, - kUgm3 = 0x04, - kNgm3 = 0x05, - kPm3 = 0x06, - kBqm3 = 0x07, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 8, -}; +using MeasurementUnitEnum = Clusters::detail::MeasurementUnitEnum; // Bitmap for Feature enum class Feature : uint32_t @@ -4538,51 +4271,11 @@ enum class Feature : uint32_t namespace TotalVolatileOrganicCompoundsConcentrationMeasurement { -// Enum for LevelValueEnum -enum class LevelValueEnum : uint8_t -{ - kUnknown = 0x00, - kLow = 0x01, - kMedium = 0x02, - kHigh = 0x03, - kCritical = 0x04, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 5, -}; +using LevelValueEnum = Clusters::detail::LevelValueEnum; -// Enum for MeasurementMediumEnum -enum class MeasurementMediumEnum : uint8_t -{ - kAir = 0x00, - kWater = 0x01, - kSoil = 0x02, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 3, -}; +using MeasurementMediumEnum = Clusters::detail::MeasurementMediumEnum; -// Enum for MeasurementUnitEnum -enum class MeasurementUnitEnum : uint8_t -{ - kPpm = 0x00, - kPpb = 0x01, - kPpt = 0x02, - kMgm3 = 0x03, - kUgm3 = 0x04, - kNgm3 = 0x05, - kPm3 = 0x06, - kBqm3 = 0x07, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 8, -}; +using MeasurementUnitEnum = Clusters::detail::MeasurementUnitEnum; // Bitmap for Feature enum class Feature : uint32_t @@ -4598,51 +4291,11 @@ enum class Feature : uint32_t namespace RadonConcentrationMeasurement { -// Enum for LevelValueEnum -enum class LevelValueEnum : uint8_t -{ - kUnknown = 0x00, - kLow = 0x01, - kMedium = 0x02, - kHigh = 0x03, - kCritical = 0x04, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 5, -}; +using LevelValueEnum = Clusters::detail::LevelValueEnum; -// Enum for MeasurementMediumEnum -enum class MeasurementMediumEnum : uint8_t -{ - kAir = 0x00, - kWater = 0x01, - kSoil = 0x02, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 3, -}; +using MeasurementMediumEnum = Clusters::detail::MeasurementMediumEnum; -// Enum for MeasurementUnitEnum -enum class MeasurementUnitEnum : uint8_t -{ - kPpm = 0x00, - kPpb = 0x01, - kPpt = 0x02, - kMgm3 = 0x03, - kUgm3 = 0x04, - kNgm3 = 0x05, - kPm3 = 0x06, - kBqm3 = 0x07, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 8, -}; +using MeasurementUnitEnum = Clusters::detail::MeasurementUnitEnum; // Bitmap for Feature enum class Feature : uint32_t diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index c19ff038dfffbf..fc5a2bd789227b 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -167,6 +167,133 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } // namespace ModeOptionStruct +namespace MeasurementAccuracyRangeStruct { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kRangeMin), rangeMin); + encoder.Encode(to_underlying(Fields::kRangeMax), rangeMax); + encoder.Encode(to_underlying(Fields::kPercentMax), percentMax); + encoder.Encode(to_underlying(Fields::kPercentMin), percentMin); + encoder.Encode(to_underlying(Fields::kPercentTypical), percentTypical); + encoder.Encode(to_underlying(Fields::kFixedMax), fixedMax); + encoder.Encode(to_underlying(Fields::kFixedMin), fixedMin); + encoder.Encode(to_underlying(Fields::kFixedTypical), fixedTypical); + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kRangeMin)) + { + err = DataModel::Decode(reader, rangeMin); + } + else if (__context_tag == to_underlying(Fields::kRangeMax)) + { + err = DataModel::Decode(reader, rangeMax); + } + else if (__context_tag == to_underlying(Fields::kPercentMax)) + { + err = DataModel::Decode(reader, percentMax); + } + else if (__context_tag == to_underlying(Fields::kPercentMin)) + { + err = DataModel::Decode(reader, percentMin); + } + else if (__context_tag == to_underlying(Fields::kPercentTypical)) + { + err = DataModel::Decode(reader, percentTypical); + } + else if (__context_tag == to_underlying(Fields::kFixedMax)) + { + err = DataModel::Decode(reader, fixedMax); + } + else if (__context_tag == to_underlying(Fields::kFixedMin)) + { + err = DataModel::Decode(reader, fixedMin); + } + else if (__context_tag == to_underlying(Fields::kFixedTypical)) + { + err = DataModel::Decode(reader, fixedTypical); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} + +} // namespace MeasurementAccuracyRangeStruct + +namespace MeasurementAccuracyStruct { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kMeasurementType), measurementType); + encoder.Encode(to_underlying(Fields::kMeasured), measured); + encoder.Encode(to_underlying(Fields::kMinMeasuredValue), minMeasuredValue); + encoder.Encode(to_underlying(Fields::kMaxMeasuredValue), maxMeasuredValue); + encoder.Encode(to_underlying(Fields::kAccuracyRanges), accuracyRanges); + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kMeasurementType)) + { + err = DataModel::Decode(reader, measurementType); + } + else if (__context_tag == to_underlying(Fields::kMeasured)) + { + err = DataModel::Decode(reader, measured); + } + else if (__context_tag == to_underlying(Fields::kMinMeasuredValue)) + { + err = DataModel::Decode(reader, minMeasuredValue); + } + else if (__context_tag == to_underlying(Fields::kMaxMeasuredValue)) + { + err = DataModel::Decode(reader, maxMeasuredValue); + } + else if (__context_tag == to_underlying(Fields::kAccuracyRanges)) + { + err = DataModel::Decode(reader, accuracyRanges); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} + +} // namespace MeasurementAccuracyStruct + namespace ApplicationStruct { CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { @@ -5646,6 +5773,84 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } } } // namespace TimeSnapshotResponse. +namespace PayloadTestRequest { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kEnableKey), enableKey); + encoder.Encode(to_underlying(Fields::kValue), value); + encoder.Encode(to_underlying(Fields::kCount), count); + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kEnableKey)) + { + err = DataModel::Decode(reader, enableKey); + } + else if (__context_tag == to_underlying(Fields::kValue)) + { + err = DataModel::Decode(reader, value); + } + else if (__context_tag == to_underlying(Fields::kCount)) + { + err = DataModel::Decode(reader, count); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} +} // namespace PayloadTestRequest. +namespace PayloadTestResponse { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kPayload), payload); + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kPayload)) + { + err = DataModel::Decode(reader, payload); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} +} // namespace PayloadTestResponse. } // namespace Commands namespace Attributes { @@ -13818,21 +14023,15 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } // namespace Events } // namespace ValveConfigurationAndControl -namespace ElectricalEnergyMeasurement { +namespace ElectricalPowerMeasurement { namespace Structs { -namespace MeasurementAccuracyRangeStruct { +namespace HarmonicMeasurementStruct { CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; - encoder.Encode(to_underlying(Fields::kRangeMin), rangeMin); - encoder.Encode(to_underlying(Fields::kRangeMax), rangeMax); - encoder.Encode(to_underlying(Fields::kPercentMax), percentMax); - encoder.Encode(to_underlying(Fields::kPercentMin), percentMin); - encoder.Encode(to_underlying(Fields::kPercentTypical), percentTypical); - encoder.Encode(to_underlying(Fields::kFixedMax), fixedMax); - encoder.Encode(to_underlying(Fields::kFixedMin), fixedMin); - encoder.Encode(to_underlying(Fields::kFixedTypical), fixedTypical); + encoder.Encode(to_underlying(Fields::kOrder), order); + encoder.Encode(to_underlying(Fields::kMeasurement), measurement); return encoder.Finalize(); } @@ -13850,37 +14049,99 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) CHIP_ERROR err = CHIP_NO_ERROR; const uint8_t __context_tag = std::get(__element); - if (__context_tag == to_underlying(Fields::kRangeMin)) + if (__context_tag == to_underlying(Fields::kOrder)) { - err = DataModel::Decode(reader, rangeMin); + err = DataModel::Decode(reader, order); } - else if (__context_tag == to_underlying(Fields::kRangeMax)) + else if (__context_tag == to_underlying(Fields::kMeasurement)) { - err = DataModel::Decode(reader, rangeMax); + err = DataModel::Decode(reader, measurement); } - else if (__context_tag == to_underlying(Fields::kPercentMax)) + else { - err = DataModel::Decode(reader, percentMax); } - else if (__context_tag == to_underlying(Fields::kPercentMin)) + + ReturnErrorOnFailure(err); + } +} + +} // namespace HarmonicMeasurementStruct + +namespace MeasurementRangeStruct { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kMeasurementType), measurementType); + encoder.Encode(to_underlying(Fields::kMin), min); + encoder.Encode(to_underlying(Fields::kMax), max); + encoder.Encode(to_underlying(Fields::kStartTimestamp), startTimestamp); + encoder.Encode(to_underlying(Fields::kEndTimestamp), endTimestamp); + encoder.Encode(to_underlying(Fields::kMinTimestamp), minTimestamp); + encoder.Encode(to_underlying(Fields::kMaxTimestamp), maxTimestamp); + encoder.Encode(to_underlying(Fields::kStartSystime), startSystime); + encoder.Encode(to_underlying(Fields::kEndSystime), endSystime); + encoder.Encode(to_underlying(Fields::kMinSystime), minSystime); + encoder.Encode(to_underlying(Fields::kMaxSystime), maxSystime); + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) { - err = DataModel::Decode(reader, percentMin); + return std::get(__element); } - else if (__context_tag == to_underlying(Fields::kPercentTypical)) + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kMeasurementType)) { - err = DataModel::Decode(reader, percentTypical); + err = DataModel::Decode(reader, measurementType); } - else if (__context_tag == to_underlying(Fields::kFixedMax)) + else if (__context_tag == to_underlying(Fields::kMin)) { - err = DataModel::Decode(reader, fixedMax); + err = DataModel::Decode(reader, min); } - else if (__context_tag == to_underlying(Fields::kFixedMin)) + else if (__context_tag == to_underlying(Fields::kMax)) { - err = DataModel::Decode(reader, fixedMin); + err = DataModel::Decode(reader, max); } - else if (__context_tag == to_underlying(Fields::kFixedTypical)) + else if (__context_tag == to_underlying(Fields::kStartTimestamp)) { - err = DataModel::Decode(reader, fixedTypical); + err = DataModel::Decode(reader, startTimestamp); + } + else if (__context_tag == to_underlying(Fields::kEndTimestamp)) + { + err = DataModel::Decode(reader, endTimestamp); + } + else if (__context_tag == to_underlying(Fields::kMinTimestamp)) + { + err = DataModel::Decode(reader, minTimestamp); + } + else if (__context_tag == to_underlying(Fields::kMaxTimestamp)) + { + err = DataModel::Decode(reader, maxTimestamp); + } + else if (__context_tag == to_underlying(Fields::kStartSystime)) + { + err = DataModel::Decode(reader, startSystime); + } + else if (__context_tag == to_underlying(Fields::kEndSystime)) + { + err = DataModel::Decode(reader, endSystime); + } + else if (__context_tag == to_underlying(Fields::kMinSystime)) + { + err = DataModel::Decode(reader, minSystime); + } + else if (__context_tag == to_underlying(Fields::kMaxSystime)) + { + err = DataModel::Decode(reader, maxSystime); } else { @@ -13890,18 +14151,80 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } } -} // namespace MeasurementAccuracyRangeStruct +} // namespace MeasurementRangeStruct +} // namespace Structs -namespace MeasurementAccuracyStruct { +namespace Commands {} // namespace Commands + +namespace Attributes { +CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const ConcreteAttributePath & path) +{ + switch (path.mAttributeId) + { + case Attributes::PowerMode::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, powerMode); + case Attributes::NumberOfMeasurementTypes::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, numberOfMeasurementTypes); + case Attributes::Accuracy::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, accuracy); + case Attributes::Ranges::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, ranges); + case Attributes::Voltage::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, voltage); + case Attributes::ActiveCurrent::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, activeCurrent); + case Attributes::ReactiveCurrent::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, reactiveCurrent); + case Attributes::ApparentCurrent::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, apparentCurrent); + case Attributes::ActivePower::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, activePower); + case Attributes::ReactivePower::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, reactivePower); + case Attributes::ApparentPower::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, apparentPower); + case Attributes::RMSVoltage::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, RMSVoltage); + case Attributes::RMSCurrent::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, RMSCurrent); + case Attributes::RMSPower::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, RMSPower); + case Attributes::Frequency::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, frequency); + case Attributes::HarmonicCurrents::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, harmonicCurrents); + case Attributes::HarmonicPhases::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, harmonicPhases); + case Attributes::PowerFactor::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, powerFactor); + case Attributes::NeutralCurrent::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, neutralCurrent); + case Attributes::GeneratedCommandList::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, generatedCommandList); + case Attributes::AcceptedCommandList::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, acceptedCommandList); + case Attributes::EventList::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, eventList); + case Attributes::AttributeList::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, attributeList); + case Attributes::FeatureMap::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, featureMap); + case Attributes::ClusterRevision::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, clusterRevision); + default: + return CHIP_NO_ERROR; + } +} +} // namespace Attributes + +namespace Events { +namespace MeasurementPeriodRanges { CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { - DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; - encoder.Encode(to_underlying(Fields::kMeasurementType), measurementType); - encoder.Encode(to_underlying(Fields::kMeasured), measured); - encoder.Encode(to_underlying(Fields::kMinMeasuredValue), minMeasuredValue); - encoder.Encode(to_underlying(Fields::kMaxMeasuredValue), maxMeasuredValue); - encoder.Encode(to_underlying(Fields::kAccuracyRanges), accuracyRanges); - return encoder.Finalize(); + TLV::TLVType outer; + ReturnErrorOnFailure(aWriter.StartContainer(aTag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(aWriter, TLV::ContextTag(Fields::kRanges), ranges)); + return aWriter.EndContainer(outer); } CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) @@ -13918,25 +14241,64 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) CHIP_ERROR err = CHIP_NO_ERROR; const uint8_t __context_tag = std::get(__element); - if (__context_tag == to_underlying(Fields::kMeasurementType)) + if (__context_tag == to_underlying(Fields::kRanges)) { - err = DataModel::Decode(reader, measurementType); + err = DataModel::Decode(reader, ranges); } - else if (__context_tag == to_underlying(Fields::kMeasured)) + else { - err = DataModel::Decode(reader, measured); } - else if (__context_tag == to_underlying(Fields::kMinMeasuredValue)) + + ReturnErrorOnFailure(err); + } +} +} // namespace MeasurementPeriodRanges. +} // namespace Events + +} // namespace ElectricalPowerMeasurement +namespace ElectricalEnergyMeasurement { +namespace Structs { + +namespace CumulativeEnergyResetStruct { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kImportedResetTimestamp), importedResetTimestamp); + encoder.Encode(to_underlying(Fields::kExportedResetTimestamp), exportedResetTimestamp); + encoder.Encode(to_underlying(Fields::kImportedResetSystime), importedResetSystime); + encoder.Encode(to_underlying(Fields::kExportedResetSystime), exportedResetSystime); + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) { - err = DataModel::Decode(reader, minMeasuredValue); + return std::get(__element); } - else if (__context_tag == to_underlying(Fields::kMaxMeasuredValue)) + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kImportedResetTimestamp)) { - err = DataModel::Decode(reader, maxMeasuredValue); + err = DataModel::Decode(reader, importedResetTimestamp); } - else if (__context_tag == to_underlying(Fields::kAccuracyRanges)) + else if (__context_tag == to_underlying(Fields::kExportedResetTimestamp)) { - err = DataModel::Decode(reader, accuracyRanges); + err = DataModel::Decode(reader, exportedResetTimestamp); + } + else if (__context_tag == to_underlying(Fields::kImportedResetSystime)) + { + err = DataModel::Decode(reader, importedResetSystime); + } + else if (__context_tag == to_underlying(Fields::kExportedResetSystime)) + { + err = DataModel::Decode(reader, exportedResetSystime); } else { @@ -13946,7 +14308,7 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } } -} // namespace MeasurementAccuracyStruct +} // namespace CumulativeEnergyResetStruct namespace EnergyMeasurementStruct { CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const @@ -14022,6 +14384,8 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre return DataModel::Decode(reader, periodicEnergyImported); case Attributes::PeriodicEnergyExported::TypeInfo::GetAttributeId(): return DataModel::Decode(reader, periodicEnergyExported); + case Attributes::CumulativeEnergyReset::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, cumulativeEnergyReset); case Attributes::GeneratedCommandList::TypeInfo::GetAttributeId(): return DataModel::Decode(reader, generatedCommandList); case Attributes::AcceptedCommandList::TypeInfo::GetAttributeId(): @@ -16755,6 +17119,40 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre namespace Events {} // namespace Events } // namespace EnergyPreference +namespace PowerTopology { + +namespace Commands {} // namespace Commands + +namespace Attributes { +CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const ConcreteAttributePath & path) +{ + switch (path.mAttributeId) + { + case Attributes::AvailableEndpoints::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, availableEndpoints); + case Attributes::ActiveEndpoints::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, activeEndpoints); + case Attributes::GeneratedCommandList::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, generatedCommandList); + case Attributes::AcceptedCommandList::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, acceptedCommandList); + case Attributes::EventList::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, eventList); + case Attributes::AttributeList::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, attributeList); + case Attributes::FeatureMap::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, featureMap); + case Attributes::ClusterRevision::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, clusterRevision); + default: + return CHIP_NO_ERROR; + } +} +} // namespace Attributes + +namespace Events {} // namespace Events + +} // namespace PowerTopology namespace EnergyEvseMode { namespace Structs {} // namespace Structs diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index 84960c16a477f2..99e6e3bb1d63f7 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -42,6 +42,7 @@ namespace Clusters { namespace detail { // Structs shared across multiple clusters. namespace Structs { + namespace ModeTagStruct { enum class Fields : uint8_t { @@ -98,6 +99,80 @@ struct DecodableType }; } // namespace ModeOptionStruct +namespace MeasurementAccuracyRangeStruct { +enum class Fields : uint8_t +{ + kRangeMin = 0, + kRangeMax = 1, + kPercentMax = 2, + kPercentMin = 3, + kPercentTypical = 4, + kFixedMax = 5, + kFixedMin = 6, + kFixedTypical = 7, +}; + +struct Type +{ +public: + int64_t rangeMin = static_cast(0); + int64_t rangeMax = static_cast(0); + Optional percentMax; + Optional percentMin; + Optional percentTypical; + Optional fixedMax; + Optional fixedMin; + Optional fixedTypical; + + CHIP_ERROR Decode(TLV::TLVReader & reader); + + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; +}; + +using DecodableType = Type; + +} // namespace MeasurementAccuracyRangeStruct +namespace MeasurementAccuracyStruct { +enum class Fields : uint8_t +{ + kMeasurementType = 0, + kMeasured = 1, + kMinMeasuredValue = 2, + kMaxMeasuredValue = 3, + kAccuracyRanges = 4, +}; + +struct Type +{ +public: + MeasurementTypeEnum measurementType = static_cast(0); + bool measured = static_cast(0); + int64_t minMeasuredValue = static_cast(0); + int64_t maxMeasuredValue = static_cast(0); + DataModel::List accuracyRanges; + + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; +}; + +struct DecodableType +{ +public: + MeasurementTypeEnum measurementType = static_cast(0); + bool measured = static_cast(0); + int64_t minMeasuredValue = static_cast(0); + int64_t maxMeasuredValue = static_cast(0); + DataModel::DecodableList accuracyRanges; + + CHIP_ERROR Decode(TLV::TLVReader & reader); + + static constexpr bool kIsFabricScoped = false; +}; + +} // namespace MeasurementAccuracyStruct namespace ApplicationStruct { enum class Fields : uint8_t { @@ -7255,6 +7330,16 @@ struct Type; struct DecodableType; } // namespace TimeSnapshotResponse +namespace PayloadTestRequest { +struct Type; +struct DecodableType; +} // namespace PayloadTestRequest + +namespace PayloadTestResponse { +struct Type; +struct DecodableType; +} // namespace PayloadTestResponse + } // namespace Commands namespace Commands { @@ -7356,6 +7441,76 @@ struct DecodableType CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace TimeSnapshotResponse +namespace PayloadTestRequest { +enum class Fields : uint8_t +{ + kEnableKey = 0, + kValue = 1, + kCount = 2, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::PayloadTestRequest::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::GeneralDiagnostics::Id; } + + chip::ByteSpan enableKey; + uint8_t value = static_cast(0); + uint16_t count = static_cast(0); + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; + + using ResponseType = Clusters::GeneralDiagnostics::Commands::PayloadTestResponse::DecodableType; + + static constexpr bool MustUseTimedInvoke() { return false; } +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return Commands::PayloadTestRequest::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::GeneralDiagnostics::Id; } + + chip::ByteSpan enableKey; + uint8_t value = static_cast(0); + uint16_t count = static_cast(0); + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace PayloadTestRequest +namespace PayloadTestResponse { +enum class Fields : uint8_t +{ + kPayload = 0, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::PayloadTestResponse::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::GeneralDiagnostics::Id; } + + chip::ByteSpan payload; + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; + + using ResponseType = DataModel::NullObjectType; + + static constexpr bool MustUseTimedInvoke() { return false; } +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return Commands::PayloadTestResponse::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::GeneralDiagnostics::Id; } + + chip::ByteSpan payload; + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace PayloadTestResponse } // namespace Commands namespace Attributes { @@ -19949,32 +20104,22 @@ struct DecodableType } // namespace ValveFault } // namespace Events } // namespace ValveConfigurationAndControl -namespace ElectricalEnergyMeasurement { +namespace ElectricalPowerMeasurement { namespace Structs { -namespace MeasurementAccuracyRangeStruct { +namespace MeasurementAccuracyRangeStruct = Clusters::detail::Structs::MeasurementAccuracyRangeStruct; +namespace MeasurementAccuracyStruct = Clusters::detail::Structs::MeasurementAccuracyStruct; +namespace HarmonicMeasurementStruct { enum class Fields : uint8_t { - kRangeMin = 0, - kRangeMax = 1, - kPercentMax = 2, - kPercentMin = 3, - kPercentTypical = 4, - kFixedMax = 5, - kFixedMin = 6, - kFixedTypical = 7, + kOrder = 0, + kMeasurement = 1, }; struct Type { public: - int64_t rangeMin = static_cast(0); - int64_t rangeMax = static_cast(0); - Optional percentMax; - Optional percentMin; - Optional percentTypical; - Optional fixedMax; - Optional fixedMin; - Optional fixedTypical; + uint8_t order = static_cast(0); + DataModel::Nullable measurement; CHIP_ERROR Decode(TLV::TLVReader & reader); @@ -19985,46 +20130,433 @@ struct Type using DecodableType = Type; -} // namespace MeasurementAccuracyRangeStruct -namespace MeasurementAccuracyStruct { +} // namespace HarmonicMeasurementStruct +namespace MeasurementRangeStruct { enum class Fields : uint8_t { - kMeasurementType = 0, - kMeasured = 1, - kMinMeasuredValue = 2, - kMaxMeasuredValue = 3, - kAccuracyRanges = 4, + kMeasurementType = 0, + kMin = 1, + kMax = 2, + kStartTimestamp = 3, + kEndTimestamp = 4, + kMinTimestamp = 5, + kMaxTimestamp = 6, + kStartSystime = 7, + kEndSystime = 8, + kMinSystime = 9, + kMaxSystime = 10, }; struct Type { public: MeasurementTypeEnum measurementType = static_cast(0); - bool measured = static_cast(0); - int64_t minMeasuredValue = static_cast(0); - int64_t maxMeasuredValue = static_cast(0); - DataModel::List accuracyRanges; + int64_t min = static_cast(0); + int64_t max = static_cast(0); + Optional startTimestamp; + Optional endTimestamp; + Optional minTimestamp; + Optional maxTimestamp; + Optional startSystime; + Optional endSystime; + Optional minSystime; + Optional maxSystime; + + CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; }; +using DecodableType = Type; + +} // namespace MeasurementRangeStruct +} // namespace Structs + +namespace Attributes { + +namespace PowerMode { +struct TypeInfo +{ + using Type = chip::app::Clusters::ElectricalPowerMeasurement::PowerModeEnum; + using DecodableType = chip::app::Clusters::ElectricalPowerMeasurement::PowerModeEnum; + using DecodableArgType = chip::app::Clusters::ElectricalPowerMeasurement::PowerModeEnum; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::PowerMode::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace PowerMode +namespace NumberOfMeasurementTypes { +struct TypeInfo +{ + using Type = uint8_t; + using DecodableType = uint8_t; + using DecodableArgType = uint8_t; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::NumberOfMeasurementTypes::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace NumberOfMeasurementTypes +namespace Accuracy { +struct TypeInfo +{ + using Type = + chip::app::DataModel::List; + using DecodableType = chip::app::DataModel::DecodableList< + chip::app::Clusters::ElectricalPowerMeasurement::Structs::MeasurementAccuracyStruct::DecodableType>; + using DecodableArgType = const chip::app::DataModel::DecodableList< + chip::app::Clusters::ElectricalPowerMeasurement::Structs::MeasurementAccuracyStruct::DecodableType> &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::Accuracy::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace Accuracy +namespace Ranges { +struct TypeInfo +{ + using Type = + chip::app::DataModel::List; + using DecodableType = chip::app::DataModel::DecodableList< + chip::app::Clusters::ElectricalPowerMeasurement::Structs::MeasurementRangeStruct::DecodableType>; + using DecodableArgType = const chip::app::DataModel::DecodableList< + chip::app::Clusters::ElectricalPowerMeasurement::Structs::MeasurementRangeStruct::DecodableType> &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::Ranges::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace Ranges +namespace Voltage { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::Voltage::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace Voltage +namespace ActiveCurrent { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::ActiveCurrent::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace ActiveCurrent +namespace ReactiveCurrent { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::ReactiveCurrent::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace ReactiveCurrent +namespace ApparentCurrent { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::ApparentCurrent::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace ApparentCurrent +namespace ActivePower { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::ActivePower::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace ActivePower +namespace ReactivePower { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::ReactivePower::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace ReactivePower +namespace ApparentPower { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::ApparentPower::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace ApparentPower +namespace RMSVoltage { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::RMSVoltage::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace RMSVoltage +namespace RMSCurrent { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::RMSCurrent::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace RMSCurrent +namespace RMSPower { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::RMSPower::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace RMSPower +namespace Frequency { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::Frequency::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace Frequency +namespace HarmonicCurrents { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable>; + using DecodableType = chip::app::DataModel::Nullable>; + using DecodableArgType = const chip::app::DataModel::Nullable> &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::HarmonicCurrents::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace HarmonicCurrents +namespace HarmonicPhases { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable>; + using DecodableType = chip::app::DataModel::Nullable>; + using DecodableArgType = const chip::app::DataModel::Nullable> &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::HarmonicPhases::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace HarmonicPhases +namespace PowerFactor { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::PowerFactor::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace PowerFactor +namespace NeutralCurrent { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::NeutralCurrent::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace NeutralCurrent +namespace GeneratedCommandList { +struct TypeInfo : public Clusters::Globals::Attributes::GeneratedCommandList::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } +}; +} // namespace GeneratedCommandList +namespace AcceptedCommandList { +struct TypeInfo : public Clusters::Globals::Attributes::AcceptedCommandList::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } +}; +} // namespace AcceptedCommandList +namespace EventList { +struct TypeInfo : public Clusters::Globals::Attributes::EventList::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } +}; +} // namespace EventList +namespace AttributeList { +struct TypeInfo : public Clusters::Globals::Attributes::AttributeList::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } +}; +} // namespace AttributeList +namespace FeatureMap { +struct TypeInfo : public Clusters::Globals::Attributes::FeatureMap::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } +}; +} // namespace FeatureMap +namespace ClusterRevision { +struct TypeInfo : public Clusters::Globals::Attributes::ClusterRevision::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } +}; +} // namespace ClusterRevision + +struct TypeInfo +{ + struct DecodableType + { + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + + CHIP_ERROR Decode(TLV::TLVReader & reader, const ConcreteAttributePath & path); + + Attributes::PowerMode::TypeInfo::DecodableType powerMode = + static_cast(0); + Attributes::NumberOfMeasurementTypes::TypeInfo::DecodableType numberOfMeasurementTypes = static_cast(0); + Attributes::Accuracy::TypeInfo::DecodableType accuracy; + Attributes::Ranges::TypeInfo::DecodableType ranges; + Attributes::Voltage::TypeInfo::DecodableType voltage; + Attributes::ActiveCurrent::TypeInfo::DecodableType activeCurrent; + Attributes::ReactiveCurrent::TypeInfo::DecodableType reactiveCurrent; + Attributes::ApparentCurrent::TypeInfo::DecodableType apparentCurrent; + Attributes::ActivePower::TypeInfo::DecodableType activePower; + Attributes::ReactivePower::TypeInfo::DecodableType reactivePower; + Attributes::ApparentPower::TypeInfo::DecodableType apparentPower; + Attributes::RMSVoltage::TypeInfo::DecodableType RMSVoltage; + Attributes::RMSCurrent::TypeInfo::DecodableType RMSCurrent; + Attributes::RMSPower::TypeInfo::DecodableType RMSPower; + Attributes::Frequency::TypeInfo::DecodableType frequency; + Attributes::HarmonicCurrents::TypeInfo::DecodableType harmonicCurrents; + Attributes::HarmonicPhases::TypeInfo::DecodableType harmonicPhases; + Attributes::PowerFactor::TypeInfo::DecodableType powerFactor; + Attributes::NeutralCurrent::TypeInfo::DecodableType neutralCurrent; + Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; + Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; + Attributes::EventList::TypeInfo::DecodableType eventList; + Attributes::AttributeList::TypeInfo::DecodableType attributeList; + Attributes::FeatureMap::TypeInfo::DecodableType featureMap = static_cast(0); + Attributes::ClusterRevision::TypeInfo::DecodableType clusterRevision = static_cast(0); + }; +}; +} // namespace Attributes +namespace Events { +namespace MeasurementPeriodRanges { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; + +enum class Fields : uint8_t +{ + kRanges = 0, +}; + +struct Type +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::MeasurementPeriodRanges::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + static constexpr bool kIsFabricScoped = false; + + DataModel::List ranges; + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; +}; + struct DecodableType { public: - MeasurementTypeEnum measurementType = static_cast(0); - bool measured = static_cast(0); - int64_t minMeasuredValue = static_cast(0); - int64_t maxMeasuredValue = static_cast(0); - DataModel::DecodableList accuracyRanges; + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::MeasurementPeriodRanges::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalPowerMeasurement::Id; } + + DataModel::DecodableList ranges; + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace MeasurementPeriodRanges +} // namespace Events +} // namespace ElectricalPowerMeasurement +namespace ElectricalEnergyMeasurement { +namespace Structs { +namespace MeasurementAccuracyRangeStruct = Clusters::detail::Structs::MeasurementAccuracyRangeStruct; +namespace MeasurementAccuracyStruct = Clusters::detail::Structs::MeasurementAccuracyStruct; +namespace CumulativeEnergyResetStruct { +enum class Fields : uint8_t +{ + kImportedResetTimestamp = 0, + kExportedResetTimestamp = 1, + kImportedResetSystime = 2, + kExportedResetSystime = 3, +}; + +struct Type +{ +public: + Optional> importedResetTimestamp; + Optional> exportedResetTimestamp; + Optional> importedResetSystime; + Optional> exportedResetSystime; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; }; -} // namespace MeasurementAccuracyStruct +using DecodableType = Type; + +} // namespace CumulativeEnergyResetStruct namespace EnergyMeasurementStruct { enum class Fields : uint8_t { @@ -20131,6 +20663,21 @@ struct TypeInfo static constexpr bool MustUseTimedWrite() { return false; } }; } // namespace PeriodicEnergyExported +namespace CumulativeEnergyReset { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::CumulativeEnergyResetStruct::Type>; + using DecodableType = chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::CumulativeEnergyResetStruct::DecodableType>; + using DecodableArgType = const chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::CumulativeEnergyResetStruct::DecodableType> &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::CumulativeEnergyReset::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace CumulativeEnergyReset namespace GeneratedCommandList { struct TypeInfo : public Clusters::Globals::Attributes::GeneratedCommandList::TypeInfo { @@ -20181,6 +20728,7 @@ struct TypeInfo Attributes::CumulativeEnergyExported::TypeInfo::DecodableType cumulativeEnergyExported; Attributes::PeriodicEnergyImported::TypeInfo::DecodableType periodicEnergyImported; Attributes::PeriodicEnergyExported::TypeInfo::DecodableType periodicEnergyExported; + Attributes::CumulativeEnergyReset::TypeInfo::DecodableType cumulativeEnergyReset; Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; Attributes::EventList::TypeInfo::DecodableType eventList; @@ -23238,6 +23786,91 @@ struct TypeInfo }; } // namespace Attributes } // namespace EnergyPreference +namespace PowerTopology { + +namespace Attributes { + +namespace AvailableEndpoints { +struct TypeInfo +{ + using Type = chip::app::DataModel::List; + using DecodableType = chip::app::DataModel::DecodableList; + using DecodableArgType = const chip::app::DataModel::DecodableList &; + + static constexpr ClusterId GetClusterId() { return Clusters::PowerTopology::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::AvailableEndpoints::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace AvailableEndpoints +namespace ActiveEndpoints { +struct TypeInfo +{ + using Type = chip::app::DataModel::List; + using DecodableType = chip::app::DataModel::DecodableList; + using DecodableArgType = const chip::app::DataModel::DecodableList &; + + static constexpr ClusterId GetClusterId() { return Clusters::PowerTopology::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::ActiveEndpoints::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace ActiveEndpoints +namespace GeneratedCommandList { +struct TypeInfo : public Clusters::Globals::Attributes::GeneratedCommandList::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::PowerTopology::Id; } +}; +} // namespace GeneratedCommandList +namespace AcceptedCommandList { +struct TypeInfo : public Clusters::Globals::Attributes::AcceptedCommandList::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::PowerTopology::Id; } +}; +} // namespace AcceptedCommandList +namespace EventList { +struct TypeInfo : public Clusters::Globals::Attributes::EventList::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::PowerTopology::Id; } +}; +} // namespace EventList +namespace AttributeList { +struct TypeInfo : public Clusters::Globals::Attributes::AttributeList::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::PowerTopology::Id; } +}; +} // namespace AttributeList +namespace FeatureMap { +struct TypeInfo : public Clusters::Globals::Attributes::FeatureMap::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::PowerTopology::Id; } +}; +} // namespace FeatureMap +namespace ClusterRevision { +struct TypeInfo : public Clusters::Globals::Attributes::ClusterRevision::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::PowerTopology::Id; } +}; +} // namespace ClusterRevision + +struct TypeInfo +{ + struct DecodableType + { + static constexpr ClusterId GetClusterId() { return Clusters::PowerTopology::Id; } + + CHIP_ERROR Decode(TLV::TLVReader & reader, const ConcreteAttributePath & path); + + Attributes::AvailableEndpoints::TypeInfo::DecodableType availableEndpoints; + Attributes::ActiveEndpoints::TypeInfo::DecodableType activeEndpoints; + Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; + Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; + Attributes::EventList::TypeInfo::DecodableType eventList; + Attributes::AttributeList::TypeInfo::DecodableType attributeList; + Attributes::FeatureMap::TypeInfo::DecodableType featureMap = static_cast(0); + Attributes::ClusterRevision::TypeInfo::DecodableType clusterRevision = static_cast(0); + }; +}; +} // namespace Attributes +} // namespace PowerTopology namespace EnergyEvseMode { namespace Structs { namespace ModeTagStruct = Clusters::detail::Structs::ModeTagStruct; diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h index 10696149992bc5..8ff6313abe5940 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h @@ -3641,6 +3641,112 @@ static constexpr AttributeId Id = Globals::Attributes::ClusterRevision::Id; } // namespace Attributes } // namespace ValveConfigurationAndControl +namespace ElectricalPowerMeasurement { +namespace Attributes { + +namespace PowerMode { +static constexpr AttributeId Id = 0x00000000; +} // namespace PowerMode + +namespace NumberOfMeasurementTypes { +static constexpr AttributeId Id = 0x00000001; +} // namespace NumberOfMeasurementTypes + +namespace Accuracy { +static constexpr AttributeId Id = 0x00000002; +} // namespace Accuracy + +namespace Ranges { +static constexpr AttributeId Id = 0x00000003; +} // namespace Ranges + +namespace Voltage { +static constexpr AttributeId Id = 0x00000004; +} // namespace Voltage + +namespace ActiveCurrent { +static constexpr AttributeId Id = 0x00000005; +} // namespace ActiveCurrent + +namespace ReactiveCurrent { +static constexpr AttributeId Id = 0x00000006; +} // namespace ReactiveCurrent + +namespace ApparentCurrent { +static constexpr AttributeId Id = 0x00000007; +} // namespace ApparentCurrent + +namespace ActivePower { +static constexpr AttributeId Id = 0x00000008; +} // namespace ActivePower + +namespace ReactivePower { +static constexpr AttributeId Id = 0x00000009; +} // namespace ReactivePower + +namespace ApparentPower { +static constexpr AttributeId Id = 0x0000000A; +} // namespace ApparentPower + +namespace RMSVoltage { +static constexpr AttributeId Id = 0x0000000B; +} // namespace RMSVoltage + +namespace RMSCurrent { +static constexpr AttributeId Id = 0x0000000C; +} // namespace RMSCurrent + +namespace RMSPower { +static constexpr AttributeId Id = 0x0000000D; +} // namespace RMSPower + +namespace Frequency { +static constexpr AttributeId Id = 0x0000000E; +} // namespace Frequency + +namespace HarmonicCurrents { +static constexpr AttributeId Id = 0x0000000F; +} // namespace HarmonicCurrents + +namespace HarmonicPhases { +static constexpr AttributeId Id = 0x00000010; +} // namespace HarmonicPhases + +namespace PowerFactor { +static constexpr AttributeId Id = 0x00000011; +} // namespace PowerFactor + +namespace NeutralCurrent { +static constexpr AttributeId Id = 0x00000012; +} // namespace NeutralCurrent + +namespace GeneratedCommandList { +static constexpr AttributeId Id = Globals::Attributes::GeneratedCommandList::Id; +} // namespace GeneratedCommandList + +namespace AcceptedCommandList { +static constexpr AttributeId Id = Globals::Attributes::AcceptedCommandList::Id; +} // namespace AcceptedCommandList + +namespace EventList { +static constexpr AttributeId Id = Globals::Attributes::EventList::Id; +} // namespace EventList + +namespace AttributeList { +static constexpr AttributeId Id = Globals::Attributes::AttributeList::Id; +} // namespace AttributeList + +namespace FeatureMap { +static constexpr AttributeId Id = Globals::Attributes::FeatureMap::Id; +} // namespace FeatureMap + +namespace ClusterRevision { +static constexpr AttributeId Id = Globals::Attributes::ClusterRevision::Id; +} // namespace ClusterRevision + +} // namespace Attributes +} // namespace ElectricalPowerMeasurement + namespace ElectricalEnergyMeasurement { namespace Attributes { @@ -3664,6 +3770,10 @@ namespace PeriodicEnergyExported { static constexpr AttributeId Id = 0x00000004; } // namespace PeriodicEnergyExported +namespace CumulativeEnergyReset { +static constexpr AttributeId Id = 0x00000005; +} // namespace CumulativeEnergyReset + namespace GeneratedCommandList { static constexpr AttributeId Id = Globals::Attributes::GeneratedCommandList::Id; } // namespace GeneratedCommandList @@ -4025,6 +4135,44 @@ static constexpr AttributeId Id = Globals::Attributes::ClusterRevision::Id; } // namespace Attributes } // namespace EnergyPreference +namespace PowerTopology { +namespace Attributes { + +namespace AvailableEndpoints { +static constexpr AttributeId Id = 0x00000000; +} // namespace AvailableEndpoints + +namespace ActiveEndpoints { +static constexpr AttributeId Id = 0x00000001; +} // namespace ActiveEndpoints + +namespace GeneratedCommandList { +static constexpr AttributeId Id = Globals::Attributes::GeneratedCommandList::Id; +} // namespace GeneratedCommandList + +namespace AcceptedCommandList { +static constexpr AttributeId Id = Globals::Attributes::AcceptedCommandList::Id; +} // namespace AcceptedCommandList + +namespace EventList { +static constexpr AttributeId Id = Globals::Attributes::EventList::Id; +} // namespace EventList + +namespace AttributeList { +static constexpr AttributeId Id = Globals::Attributes::AttributeList::Id; +} // namespace AttributeList + +namespace FeatureMap { +static constexpr AttributeId Id = Globals::Attributes::FeatureMap::Id; +} // namespace FeatureMap + +namespace ClusterRevision { +static constexpr AttributeId Id = Globals::Attributes::ClusterRevision::Id; +} // namespace ClusterRevision + +} // namespace Attributes +} // namespace PowerTopology + namespace EnergyEvseMode { namespace Attributes { diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Clusters.h b/zzz_generated/app-common/app-common/zap-generated/ids/Clusters.h index 6fabd081faaa7f..f457887220abad 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Clusters.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Clusters.h @@ -220,6 +220,9 @@ static constexpr ClusterId Id = 0x00000080; namespace ValveConfigurationAndControl { static constexpr ClusterId Id = 0x00000081; } // namespace ValveConfigurationAndControl +namespace ElectricalPowerMeasurement { +static constexpr ClusterId Id = 0x00000090; +} // namespace ElectricalPowerMeasurement namespace ElectricalEnergyMeasurement { static constexpr ClusterId Id = 0x00000091; } // namespace ElectricalEnergyMeasurement @@ -238,6 +241,9 @@ static constexpr ClusterId Id = 0x00000099; namespace EnergyPreference { static constexpr ClusterId Id = 0x0000009B; } // namespace EnergyPreference +namespace PowerTopology { +static constexpr ClusterId Id = 0x0000009C; +} // namespace PowerTopology namespace EnergyEvseMode { static constexpr ClusterId Id = 0x0000009D; } // namespace EnergyEvseMode diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h b/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h index 6093139e72464d..da8b04c98c1963 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h @@ -368,6 +368,14 @@ namespace TimeSnapshotResponse { static constexpr CommandId Id = 0x00000002; } // namespace TimeSnapshotResponse +namespace PayloadTestRequest { +static constexpr CommandId Id = 0x00000003; +} // namespace PayloadTestRequest + +namespace PayloadTestResponse { +static constexpr CommandId Id = 0x00000004; +} // namespace PayloadTestResponse + } // namespace Commands } // namespace GeneralDiagnostics diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Events.h b/zzz_generated/app-common/app-common/zap-generated/ids/Events.h index ffc9326338b763..28e5799188e843 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Events.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Events.h @@ -407,6 +407,16 @@ static constexpr EventId Id = 0x00000001; } // namespace Events } // namespace ValveConfigurationAndControl +namespace ElectricalPowerMeasurement { +namespace Events { + +namespace MeasurementPeriodRanges { +static constexpr EventId Id = 0x00000000; +} // namespace MeasurementPeriodRanges + +} // namespace Events +} // namespace ElectricalPowerMeasurement + namespace ElectricalEnergyMeasurement { namespace Events { diff --git a/zzz_generated/app-common/app-common/zap-generated/print-cluster.h b/zzz_generated/app-common/app-common/zap-generated/print-cluster.h index 56d3b193f69f35..a6af06565cf074 100644 --- a/zzz_generated/app-common/app-common/zap-generated/print-cluster.h +++ b/zzz_generated/app-common/app-common/zap-generated/print-cluster.h @@ -443,6 +443,13 @@ #define CHIP_PRINTCLUSTER_VALVE_CONFIGURATION_AND_CONTROL_CLUSTER #endif +#if defined(ZCL_USING_ELECTRICAL_POWER_MEASUREMENT_CLUSTER_SERVER) || defined(ZCL_USING_ELECTRICAL_POWER_MEASUREMENT_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_ELECTRICAL_POWER_MEASUREMENT_CLUSTER \ + { chip::app::Clusters::ElectricalPowerMeasurement::Id, "Electrical Power Measurement" }, +#else +#define CHIP_PRINTCLUSTER_ELECTRICAL_POWER_MEASUREMENT_CLUSTER +#endif + #if defined(ZCL_USING_ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_SERVER) || \ defined(ZCL_USING_ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER \ @@ -483,6 +490,12 @@ #define CHIP_PRINTCLUSTER_ENERGY_PREFERENCE_CLUSTER #endif +#if defined(ZCL_USING_POWER_TOPOLOGY_CLUSTER_SERVER) || defined(ZCL_USING_POWER_TOPOLOGY_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_POWER_TOPOLOGY_CLUSTER { chip::app::Clusters::PowerTopology::Id, "Power Topology" }, +#else +#define CHIP_PRINTCLUSTER_POWER_TOPOLOGY_CLUSTER +#endif + #if defined(ZCL_USING_ENERGY_EVSE_MODE_CLUSTER_SERVER) || defined(ZCL_USING_ENERGY_EVSE_MODE_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_ENERGY_EVSE_MODE_CLUSTER { chip::app::Clusters::EnergyEvseMode::Id, "Energy EVSE Mode" }, #else @@ -851,12 +864,14 @@ CHIP_PRINTCLUSTER_ACTIVATED_CARBON_FILTER_MONITORING_CLUSTER \ CHIP_PRINTCLUSTER_BOOLEAN_STATE_CONFIGURATION_CLUSTER \ CHIP_PRINTCLUSTER_VALVE_CONFIGURATION_AND_CONTROL_CLUSTER \ + CHIP_PRINTCLUSTER_ELECTRICAL_POWER_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER \ CHIP_PRINTCLUSTER_MESSAGES_CLUSTER \ CHIP_PRINTCLUSTER_DEVICE_ENERGY_MANAGEMENT_CLUSTER \ CHIP_PRINTCLUSTER_ENERGY_EVSE_CLUSTER \ CHIP_PRINTCLUSTER_ENERGY_PREFERENCE_CLUSTER \ + CHIP_PRINTCLUSTER_POWER_TOPOLOGY_CLUSTER \ CHIP_PRINTCLUSTER_ENERGY_EVSE_MODE_CLUSTER \ CHIP_PRINTCLUSTER_DEVICE_ENERGY_MANAGEMENT_MODE_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index eb333b055a0469..3a7a4e981629b6 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -100,12 +100,14 @@ | ActivatedCarbonFilterMonitoring | 0x0072 | | BooleanStateConfiguration | 0x0080 | | ValveConfigurationAndControl | 0x0081 | +| ElectricalPowerMeasurement | 0x0090 | | ElectricalEnergyMeasurement | 0x0091 | | DemandResponseLoadControl | 0x0096 | | Messages | 0x0097 | | DeviceEnergyManagement | 0x0098 | | EnergyEvse | 0x0099 | | EnergyPreference | 0x009B | +| PowerTopology | 0x009C | | EnergyEvseMode | 0x009D | | DeviceEnergyManagementMode | 0x009F | | DoorLock | 0x0101 | @@ -2689,6 +2691,7 @@ class DiagnosticLogsRetrieveLogsRequest : public ClusterCommand | Commands: | | | * TestEventTrigger | 0x00 | | * TimeSnapshot | 0x01 | +| * PayloadTestRequest | 0x03 | |------------------------------------------------------------------------------| | Attributes: | | | * NetworkInterfaces | 0x0000 | @@ -2790,6 +2793,46 @@ class GeneralDiagnosticsTimeSnapshot : public ClusterCommand chip::app::Clusters::GeneralDiagnostics::Commands::TimeSnapshot::Type mRequest; }; +/* + * Command PayloadTestRequest + */ +class GeneralDiagnosticsPayloadTestRequest : public ClusterCommand +{ +public: + GeneralDiagnosticsPayloadTestRequest(CredentialIssuerCommands * credsIssuerConfig) : + ClusterCommand("payload-test-request", credsIssuerConfig) + { + AddArgument("EnableKey", &mRequest.enableKey); + AddArgument("Value", 0, UINT8_MAX, &mRequest.value); + AddArgument("Count", 0, UINT16_MAX, &mRequest.count); + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::GeneralDiagnostics::Id; + constexpr chip::CommandId commandId = chip::app::Clusters::GeneralDiagnostics::Commands::PayloadTestRequest::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") command (0x%08" PRIX32 ") on endpoint %u", clusterId, + commandId, endpointIds.at(0)); + return ClusterCommand::SendCommand(device, endpointIds.at(0), clusterId, commandId, mRequest); + } + + CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::GeneralDiagnostics::Id; + constexpr chip::CommandId commandId = chip::app::Clusters::GeneralDiagnostics::Commands::PayloadTestRequest::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") command (0x%08" PRIX32 ") on Group %u", clusterId, commandId, + groupId); + + return ClusterCommand::SendGroupCommand(groupId, fabricIndex, clusterId, commandId, mRequest); + } + +private: + chip::app::Clusters::GeneralDiagnostics::Commands::PayloadTestRequest::Type mRequest; +}; + /*----------------------------------------------------------------------------*\ | Cluster SoftwareDiagnostics | 0x0034 | |------------------------------------------------------------------------------| @@ -6464,6 +6507,42 @@ class ValveConfigurationAndControlClose : public ClusterCommand chip::app::Clusters::ValveConfigurationAndControl::Commands::Close::Type mRequest; }; +/*----------------------------------------------------------------------------*\ +| Cluster ElectricalPowerMeasurement | 0x0090 | +|------------------------------------------------------------------------------| +| Commands: | | +|------------------------------------------------------------------------------| +| Attributes: | | +| * PowerMode | 0x0000 | +| * NumberOfMeasurementTypes | 0x0001 | +| * Accuracy | 0x0002 | +| * Ranges | 0x0003 | +| * Voltage | 0x0004 | +| * ActiveCurrent | 0x0005 | +| * ReactiveCurrent | 0x0006 | +| * ApparentCurrent | 0x0007 | +| * ActivePower | 0x0008 | +| * ReactivePower | 0x0009 | +| * ApparentPower | 0x000A | +| * RMSVoltage | 0x000B | +| * RMSCurrent | 0x000C | +| * RMSPower | 0x000D | +| * Frequency | 0x000E | +| * HarmonicCurrents | 0x000F | +| * HarmonicPhases | 0x0010 | +| * PowerFactor | 0x0011 | +| * NeutralCurrent | 0x0012 | +| * GeneratedCommandList | 0xFFF8 | +| * AcceptedCommandList | 0xFFF9 | +| * EventList | 0xFFFA | +| * AttributeList | 0xFFFB | +| * FeatureMap | 0xFFFC | +| * ClusterRevision | 0xFFFD | +|------------------------------------------------------------------------------| +| Events: | | +| * MeasurementPeriodRanges | 0x0000 | +\*----------------------------------------------------------------------------*/ + /*----------------------------------------------------------------------------*\ | Cluster ElectricalEnergyMeasurement | 0x0091 | |------------------------------------------------------------------------------| @@ -6475,6 +6554,7 @@ class ValveConfigurationAndControlClose : public ClusterCommand | * CumulativeEnergyExported | 0x0002 | | * PeriodicEnergyImported | 0x0003 | | * PeriodicEnergyExported | 0x0004 | +| * CumulativeEnergyReset | 0x0005 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -7519,6 +7599,24 @@ class EnergyEvseClearTargets : public ClusterCommand | Events: | | \*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*\ +| Cluster PowerTopology | 0x009C | +|------------------------------------------------------------------------------| +| Commands: | | +|------------------------------------------------------------------------------| +| Attributes: | | +| * AvailableEndpoints | 0x0000 | +| * ActiveEndpoints | 0x0001 | +| * GeneratedCommandList | 0xFFF8 | +| * AcceptedCommandList | 0xFFF9 | +| * EventList | 0xFFFA | +| * AttributeList | 0xFFFB | +| * FeatureMap | 0xFFFC | +| * ClusterRevision | 0xFFFD | +|------------------------------------------------------------------------------| +| Events: | | +\*----------------------------------------------------------------------------*/ + /*----------------------------------------------------------------------------*\ | Cluster EnergyEvseMode | 0x009D | |------------------------------------------------------------------------------| @@ -16413,9 +16511,10 @@ void registerClusterGeneralDiagnostics(Commands & commands, CredentialIssuerComm // // Commands // - make_unique(Id, credsIssuerConfig), // - make_unique(credsIssuerConfig), // - make_unique(credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // // // Attributes // @@ -20039,6 +20138,152 @@ void registerClusterValveConfigurationAndControl(Commands & commands, Credential commands.RegisterCluster(clusterName, clusterCommands); } +void registerClusterElectricalPowerMeasurement(Commands & commands, CredentialIssuerCommands * credsIssuerConfig) +{ + using namespace chip::app::Clusters::ElectricalPowerMeasurement; + + const char * clusterName = "ElectricalPowerMeasurement"; + + commands_list clusterCommands = { + // + // Commands + // + make_unique(Id, credsIssuerConfig), // + // + // Attributes + // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "power-mode", Attributes::PowerMode::Id, credsIssuerConfig), // + make_unique(Id, "number-of-measurement-types", Attributes::NumberOfMeasurementTypes::Id, + credsIssuerConfig), // + make_unique(Id, "accuracy", Attributes::Accuracy::Id, credsIssuerConfig), // + make_unique(Id, "ranges", Attributes::Ranges::Id, credsIssuerConfig), // + make_unique(Id, "voltage", Attributes::Voltage::Id, credsIssuerConfig), // + make_unique(Id, "active-current", Attributes::ActiveCurrent::Id, credsIssuerConfig), // + make_unique(Id, "reactive-current", Attributes::ReactiveCurrent::Id, credsIssuerConfig), // + make_unique(Id, "apparent-current", Attributes::ApparentCurrent::Id, credsIssuerConfig), // + make_unique(Id, "active-power", Attributes::ActivePower::Id, credsIssuerConfig), // + make_unique(Id, "reactive-power", Attributes::ReactivePower::Id, credsIssuerConfig), // + make_unique(Id, "apparent-power", Attributes::ApparentPower::Id, credsIssuerConfig), // + make_unique(Id, "rmsvoltage", Attributes::RMSVoltage::Id, credsIssuerConfig), // + make_unique(Id, "rmscurrent", Attributes::RMSCurrent::Id, credsIssuerConfig), // + make_unique(Id, "rmspower", Attributes::RMSPower::Id, credsIssuerConfig), // + make_unique(Id, "frequency", Attributes::Frequency::Id, credsIssuerConfig), // + make_unique(Id, "harmonic-currents", Attributes::HarmonicCurrents::Id, credsIssuerConfig), // + make_unique(Id, "harmonic-phases", Attributes::HarmonicPhases::Id, credsIssuerConfig), // + make_unique(Id, "power-factor", Attributes::PowerFactor::Id, credsIssuerConfig), // + make_unique(Id, "neutral-current", Attributes::NeutralCurrent::Id, credsIssuerConfig), // + make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // + make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // + make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // + make_unique(Id, "attribute-list", Attributes::AttributeList::Id, credsIssuerConfig), // + make_unique(Id, "feature-map", Attributes::FeatureMap::Id, credsIssuerConfig), // + make_unique(Id, "cluster-revision", Attributes::ClusterRevision::Id, credsIssuerConfig), // + make_unique>(Id, credsIssuerConfig), // + make_unique>( + Id, "power-mode", 0, UINT8_MAX, Attributes::PowerMode::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>(Id, "number-of-measurement-types", 0, UINT8_MAX, + Attributes::NumberOfMeasurementTypes::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // + make_unique>>( + Id, "accuracy", Attributes::Accuracy::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "ranges", Attributes::Ranges::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "voltage", INT64_MIN, INT64_MAX, Attributes::Voltage::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>(Id, "active-current", INT64_MIN, INT64_MAX, + Attributes::ActiveCurrent::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>(Id, "reactive-current", INT64_MIN, INT64_MAX, + Attributes::ReactiveCurrent::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>(Id, "apparent-current", INT64_MIN, INT64_MAX, + Attributes::ApparentCurrent::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>(Id, "active-power", INT64_MIN, INT64_MAX, + Attributes::ActivePower::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>(Id, "reactive-power", INT64_MIN, INT64_MAX, + Attributes::ReactivePower::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>(Id, "apparent-power", INT64_MIN, INT64_MAX, + Attributes::ApparentPower::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>(Id, "rmsvoltage", INT64_MIN, INT64_MAX, + Attributes::RMSVoltage::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>(Id, "rmscurrent", INT64_MIN, INT64_MAX, + Attributes::RMSCurrent::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "rmspower", INT64_MIN, INT64_MAX, Attributes::RMSPower::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "frequency", INT64_MIN, INT64_MAX, Attributes::Frequency::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>>( + Id, "harmonic-currents", Attributes::HarmonicCurrents::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>>( + Id, "harmonic-phases", Attributes::HarmonicPhases::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>(Id, "power-factor", INT64_MIN, INT64_MAX, + Attributes::PowerFactor::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>(Id, "neutral-current", INT64_MIN, INT64_MAX, + Attributes::NeutralCurrent::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "generated-command-list", Attributes::GeneratedCommandList::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // + make_unique>>( + Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "event-list", Attributes::EventList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "attribute-list", Attributes::AttributeList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>(Id, "feature-map", 0, UINT32_MAX, Attributes::FeatureMap::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>(Id, "cluster-revision", 0, UINT16_MAX, Attributes::ClusterRevision::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "power-mode", Attributes::PowerMode::Id, credsIssuerConfig), // + make_unique(Id, "number-of-measurement-types", Attributes::NumberOfMeasurementTypes::Id, + credsIssuerConfig), // + make_unique(Id, "accuracy", Attributes::Accuracy::Id, credsIssuerConfig), // + make_unique(Id, "ranges", Attributes::Ranges::Id, credsIssuerConfig), // + make_unique(Id, "voltage", Attributes::Voltage::Id, credsIssuerConfig), // + make_unique(Id, "active-current", Attributes::ActiveCurrent::Id, credsIssuerConfig), // + make_unique(Id, "reactive-current", Attributes::ReactiveCurrent::Id, credsIssuerConfig), // + make_unique(Id, "apparent-current", Attributes::ApparentCurrent::Id, credsIssuerConfig), // + make_unique(Id, "active-power", Attributes::ActivePower::Id, credsIssuerConfig), // + make_unique(Id, "reactive-power", Attributes::ReactivePower::Id, credsIssuerConfig), // + make_unique(Id, "apparent-power", Attributes::ApparentPower::Id, credsIssuerConfig), // + make_unique(Id, "rmsvoltage", Attributes::RMSVoltage::Id, credsIssuerConfig), // + make_unique(Id, "rmscurrent", Attributes::RMSCurrent::Id, credsIssuerConfig), // + make_unique(Id, "rmspower", Attributes::RMSPower::Id, credsIssuerConfig), // + make_unique(Id, "frequency", Attributes::Frequency::Id, credsIssuerConfig), // + make_unique(Id, "harmonic-currents", Attributes::HarmonicCurrents::Id, credsIssuerConfig), // + make_unique(Id, "harmonic-phases", Attributes::HarmonicPhases::Id, credsIssuerConfig), // + make_unique(Id, "power-factor", Attributes::PowerFactor::Id, credsIssuerConfig), // + make_unique(Id, "neutral-current", Attributes::NeutralCurrent::Id, credsIssuerConfig), // + make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // + make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // + make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // + make_unique(Id, "attribute-list", Attributes::AttributeList::Id, credsIssuerConfig), // + make_unique(Id, "feature-map", Attributes::FeatureMap::Id, credsIssuerConfig), // + make_unique(Id, "cluster-revision", Attributes::ClusterRevision::Id, credsIssuerConfig), // + // + // Events + // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "measurement-period-ranges", Events::MeasurementPeriodRanges::Id, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "measurement-period-ranges", Events::MeasurementPeriodRanges::Id, credsIssuerConfig), // + }; + + commands.RegisterCluster(clusterName, clusterCommands); +} void registerClusterElectricalEnergyMeasurement(Commands & commands, CredentialIssuerCommands * credsIssuerConfig) { using namespace chip::app::Clusters::ElectricalEnergyMeasurement; @@ -20061,6 +20306,7 @@ void registerClusterElectricalEnergyMeasurement(Commands & commands, CredentialI credsIssuerConfig), // make_unique(Id, "periodic-energy-imported", Attributes::PeriodicEnergyImported::Id, credsIssuerConfig), // make_unique(Id, "periodic-energy-exported", Attributes::PeriodicEnergyExported::Id, credsIssuerConfig), // + make_unique(Id, "cumulative-energy-reset", Attributes::CumulativeEnergyReset::Id, credsIssuerConfig), // make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // @@ -20087,6 +20333,10 @@ void registerClusterElectricalEnergyMeasurement(Commands & commands, CredentialI chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::Type>>>( Id, "periodic-energy-exported", Attributes::PeriodicEnergyExported::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "cumulative-energy-reset", Attributes::CumulativeEnergyReset::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // make_unique>>( Id, "generated-command-list", Attributes::GeneratedCommandList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // @@ -20109,13 +20359,14 @@ void registerClusterElectricalEnergyMeasurement(Commands & commands, CredentialI make_unique(Id, "periodic-energy-imported", Attributes::PeriodicEnergyImported::Id, credsIssuerConfig), // make_unique(Id, "periodic-energy-exported", Attributes::PeriodicEnergyExported::Id, - credsIssuerConfig), // - make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // - make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // - make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // - make_unique(Id, "attribute-list", Attributes::AttributeList::Id, credsIssuerConfig), // - make_unique(Id, "feature-map", Attributes::FeatureMap::Id, credsIssuerConfig), // - make_unique(Id, "cluster-revision", Attributes::ClusterRevision::Id, credsIssuerConfig), // + credsIssuerConfig), // + make_unique(Id, "cumulative-energy-reset", Attributes::CumulativeEnergyReset::Id, credsIssuerConfig), // + make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // + make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // + make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // + make_unique(Id, "attribute-list", Attributes::AttributeList::Id, credsIssuerConfig), // + make_unique(Id, "feature-map", Attributes::FeatureMap::Id, credsIssuerConfig), // + make_unique(Id, "cluster-revision", Attributes::ClusterRevision::Id, credsIssuerConfig), // // // Events // @@ -20671,6 +20922,65 @@ void registerClusterEnergyPreference(Commands & commands, CredentialIssuerComman commands.RegisterCluster(clusterName, clusterCommands); } +void registerClusterPowerTopology(Commands & commands, CredentialIssuerCommands * credsIssuerConfig) +{ + using namespace chip::app::Clusters::PowerTopology; + + const char * clusterName = "PowerTopology"; + + commands_list clusterCommands = { + // + // Commands + // + make_unique(Id, credsIssuerConfig), // + // + // Attributes + // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "available-endpoints", Attributes::AvailableEndpoints::Id, credsIssuerConfig), // + make_unique(Id, "active-endpoints", Attributes::ActiveEndpoints::Id, credsIssuerConfig), // + make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // + make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // + make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // + make_unique(Id, "attribute-list", Attributes::AttributeList::Id, credsIssuerConfig), // + make_unique(Id, "feature-map", Attributes::FeatureMap::Id, credsIssuerConfig), // + make_unique(Id, "cluster-revision", Attributes::ClusterRevision::Id, credsIssuerConfig), // + make_unique>(Id, credsIssuerConfig), // + make_unique>>( + Id, "available-endpoints", Attributes::AvailableEndpoints::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "active-endpoints", Attributes::ActiveEndpoints::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "generated-command-list", Attributes::GeneratedCommandList::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // + make_unique>>( + Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "event-list", Attributes::EventList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "attribute-list", Attributes::AttributeList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>(Id, "feature-map", 0, UINT32_MAX, Attributes::FeatureMap::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>(Id, "cluster-revision", 0, UINT16_MAX, Attributes::ClusterRevision::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "available-endpoints", Attributes::AvailableEndpoints::Id, credsIssuerConfig), // + make_unique(Id, "active-endpoints", Attributes::ActiveEndpoints::Id, credsIssuerConfig), // + make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // + make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // + make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // + make_unique(Id, "attribute-list", Attributes::AttributeList::Id, credsIssuerConfig), // + make_unique(Id, "feature-map", Attributes::FeatureMap::Id, credsIssuerConfig), // + make_unique(Id, "cluster-revision", Attributes::ClusterRevision::Id, credsIssuerConfig), // + // + // Events + // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + }; + + commands.RegisterCluster(clusterName, clusterCommands); +} void registerClusterEnergyEvseMode(Commands & commands, CredentialIssuerCommands * credsIssuerConfig) { using namespace chip::app::Clusters::EnergyEvseMode; @@ -26515,12 +26825,14 @@ void registerClusters(Commands & commands, CredentialIssuerCommands * credsIssue registerClusterActivatedCarbonFilterMonitoring(commands, credsIssuerConfig); registerClusterBooleanStateConfiguration(commands, credsIssuerConfig); registerClusterValveConfigurationAndControl(commands, credsIssuerConfig); + registerClusterElectricalPowerMeasurement(commands, credsIssuerConfig); registerClusterElectricalEnergyMeasurement(commands, credsIssuerConfig); registerClusterDemandResponseLoadControl(commands, credsIssuerConfig); registerClusterMessages(commands, credsIssuerConfig); registerClusterDeviceEnergyManagement(commands, credsIssuerConfig); registerClusterEnergyEvse(commands, credsIssuerConfig); registerClusterEnergyPreference(commands, credsIssuerConfig); + registerClusterPowerTopology(commands, credsIssuerConfig); registerClusterEnergyEvseMode(commands, credsIssuerConfig); registerClusterDeviceEnergyManagementMode(commands, credsIssuerConfig); registerClusterDoorLock(commands, credsIssuerConfig); diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp index 5813b0e5b12105..89f34d0cee3714 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp @@ -86,6 +86,139 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::detail::Structs::ModeO ComplexArgumentParser::Finalize(request.modeTags); } +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::detail::Structs::MeasurementAccuracyRangeStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyRangeStruct.rangeMin", "rangeMin", + value.isMember("rangeMin"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyRangeStruct.rangeMax", "rangeMax", + value.isMember("rangeMax"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rangeMin"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rangeMin, value["rangeMin"])); + valueCopy.removeMember("rangeMin"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rangeMax"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rangeMax, value["rangeMax"])); + valueCopy.removeMember("rangeMax"); + + if (value.isMember("percentMax")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "percentMax"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.percentMax, value["percentMax"])); + } + valueCopy.removeMember("percentMax"); + + if (value.isMember("percentMin")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "percentMin"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.percentMin, value["percentMin"])); + } + valueCopy.removeMember("percentMin"); + + if (value.isMember("percentTypical")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "percentTypical"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.percentTypical, value["percentTypical"])); + } + valueCopy.removeMember("percentTypical"); + + if (value.isMember("fixedMax")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fixedMax"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fixedMax, value["fixedMax"])); + } + valueCopy.removeMember("fixedMax"); + + if (value.isMember("fixedMin")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fixedMin"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fixedMin, value["fixedMin"])); + } + valueCopy.removeMember("fixedMin"); + + if (value.isMember("fixedTypical")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fixedTypical"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fixedTypical, value["fixedTypical"])); + } + valueCopy.removeMember("fixedTypical"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::detail::Structs::MeasurementAccuracyRangeStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.rangeMin); + ComplexArgumentParser::Finalize(request.rangeMax); + ComplexArgumentParser::Finalize(request.percentMax); + ComplexArgumentParser::Finalize(request.percentMin); + ComplexArgumentParser::Finalize(request.percentTypical); + ComplexArgumentParser::Finalize(request.fixedMax); + ComplexArgumentParser::Finalize(request.fixedMin); + ComplexArgumentParser::Finalize(request.fixedTypical); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::detail::Structs::MeasurementAccuracyStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyStruct.measurementType", "measurementType", + value.isMember("measurementType"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyStruct.measured", "measured", value.isMember("measured"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyStruct.minMeasuredValue", "minMeasuredValue", + value.isMember("minMeasuredValue"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyStruct.maxMeasuredValue", "maxMeasuredValue", + value.isMember("maxMeasuredValue"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyStruct.accuracyRanges", "accuracyRanges", + value.isMember("accuracyRanges"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "measurementType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.measurementType, value["measurementType"])); + valueCopy.removeMember("measurementType"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "measured"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.measured, value["measured"])); + valueCopy.removeMember("measured"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "minMeasuredValue"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.minMeasuredValue, value["minMeasuredValue"])); + valueCopy.removeMember("minMeasuredValue"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "maxMeasuredValue"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.maxMeasuredValue, value["maxMeasuredValue"])); + valueCopy.removeMember("maxMeasuredValue"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "accuracyRanges"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.accuracyRanges, value["accuracyRanges"])); + valueCopy.removeMember("accuracyRanges"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::detail::Structs::MeasurementAccuracyStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.measurementType); + ComplexArgumentParser::Finalize(request.measured); + ComplexArgumentParser::Finalize(request.minMeasuredValue); + ComplexArgumentParser::Finalize(request.maxMeasuredValue); + ComplexArgumentParser::Finalize(request.accuracyRanges); +} + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request, Json::Value & value) { @@ -2223,90 +2356,146 @@ void ComplexArgumentParser::Finalize( ComplexArgumentParser::Finalize(request.productIdentifierValue); } -CHIP_ERROR ComplexArgumentParser::Setup( - const char * label, chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::Type & request, - Json::Value & value) +CHIP_ERROR +ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::ElectricalPowerMeasurement::Structs::HarmonicMeasurementStruct::Type & request, + Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyRangeStruct.rangeMin", "rangeMin", - value.isMember("rangeMin"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyRangeStruct.rangeMax", "rangeMax", - value.isMember("rangeMax"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("HarmonicMeasurementStruct.order", "order", value.isMember("order"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("HarmonicMeasurementStruct.measurement", "measurement", + value.isMember("measurement"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rangeMin"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rangeMin, value["rangeMin"])); - valueCopy.removeMember("rangeMin"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "order"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.order, value["order"])); + valueCopy.removeMember("order"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rangeMax"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rangeMax, value["rangeMax"])); - valueCopy.removeMember("rangeMax"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "measurement"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.measurement, value["measurement"])); + valueCopy.removeMember("measurement"); - if (value.isMember("percentMax")) + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize( + chip::app::Clusters::ElectricalPowerMeasurement::Structs::HarmonicMeasurementStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.order); + ComplexArgumentParser::Finalize(request.measurement); +} + +CHIP_ERROR +ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::ElectricalPowerMeasurement::Structs::MeasurementRangeStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementRangeStruct.measurementType", "measurementType", + value.isMember("measurementType"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementRangeStruct.min", "min", value.isMember("min"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementRangeStruct.max", "max", value.isMember("max"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "measurementType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.measurementType, value["measurementType"])); + valueCopy.removeMember("measurementType"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "min"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.min, value["min"])); + valueCopy.removeMember("min"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "max"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.max, value["max"])); + valueCopy.removeMember("max"); + + if (value.isMember("startTimestamp")) { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "percentMax"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.percentMax, value["percentMax"])); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "startTimestamp"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.startTimestamp, value["startTimestamp"])); } - valueCopy.removeMember("percentMax"); + valueCopy.removeMember("startTimestamp"); - if (value.isMember("percentMin")) + if (value.isMember("endTimestamp")) { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "percentMin"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.percentMin, value["percentMin"])); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endTimestamp"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endTimestamp, value["endTimestamp"])); } - valueCopy.removeMember("percentMin"); + valueCopy.removeMember("endTimestamp"); - if (value.isMember("percentTypical")) + if (value.isMember("minTimestamp")) { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "percentTypical"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.percentTypical, value["percentTypical"])); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "minTimestamp"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.minTimestamp, value["minTimestamp"])); } - valueCopy.removeMember("percentTypical"); + valueCopy.removeMember("minTimestamp"); - if (value.isMember("fixedMax")) + if (value.isMember("maxTimestamp")) { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fixedMax"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fixedMax, value["fixedMax"])); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "maxTimestamp"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.maxTimestamp, value["maxTimestamp"])); } - valueCopy.removeMember("fixedMax"); + valueCopy.removeMember("maxTimestamp"); - if (value.isMember("fixedMin")) + if (value.isMember("startSystime")) { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fixedMin"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fixedMin, value["fixedMin"])); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "startSystime"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.startSystime, value["startSystime"])); } - valueCopy.removeMember("fixedMin"); + valueCopy.removeMember("startSystime"); - if (value.isMember("fixedTypical")) + if (value.isMember("endSystime")) { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fixedTypical"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fixedTypical, value["fixedTypical"])); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endSystime"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endSystime, value["endSystime"])); } - valueCopy.removeMember("fixedTypical"); + valueCopy.removeMember("endSystime"); + + if (value.isMember("minSystime")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "minSystime"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.minSystime, value["minSystime"])); + } + valueCopy.removeMember("minSystime"); + + if (value.isMember("maxSystime")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "maxSystime"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.maxSystime, value["maxSystime"])); + } + valueCopy.removeMember("maxSystime"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } void ComplexArgumentParser::Finalize( - chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::Type & request) + chip::app::Clusters::ElectricalPowerMeasurement::Structs::MeasurementRangeStruct::Type & request) { - ComplexArgumentParser::Finalize(request.rangeMin); - ComplexArgumentParser::Finalize(request.rangeMax); - ComplexArgumentParser::Finalize(request.percentMax); - ComplexArgumentParser::Finalize(request.percentMin); - ComplexArgumentParser::Finalize(request.percentTypical); - ComplexArgumentParser::Finalize(request.fixedMax); - ComplexArgumentParser::Finalize(request.fixedMin); - ComplexArgumentParser::Finalize(request.fixedTypical); + ComplexArgumentParser::Finalize(request.measurementType); + ComplexArgumentParser::Finalize(request.min); + ComplexArgumentParser::Finalize(request.max); + ComplexArgumentParser::Finalize(request.startTimestamp); + ComplexArgumentParser::Finalize(request.endTimestamp); + ComplexArgumentParser::Finalize(request.minTimestamp); + ComplexArgumentParser::Finalize(request.maxTimestamp); + ComplexArgumentParser::Finalize(request.startSystime); + ComplexArgumentParser::Finalize(request.endSystime); + ComplexArgumentParser::Finalize(request.minSystime); + ComplexArgumentParser::Finalize(request.maxSystime); } CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::Type & request, + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::CumulativeEnergyResetStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2314,49 +2503,49 @@ ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyStruct.measurementType", "measurementType", - value.isMember("measurementType"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyStruct.measured", "measured", value.isMember("measured"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyStruct.minMeasuredValue", "minMeasuredValue", - value.isMember("minMeasuredValue"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyStruct.maxMeasuredValue", "maxMeasuredValue", - value.isMember("maxMeasuredValue"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyStruct.accuracyRanges", "accuracyRanges", - value.isMember("accuracyRanges"))); - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "measurementType"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.measurementType, value["measurementType"])); - valueCopy.removeMember("measurementType"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "measured"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.measured, value["measured"])); - valueCopy.removeMember("measured"); + if (value.isMember("importedResetTimestamp")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "importedResetTimestamp"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.importedResetTimestamp, value["importedResetTimestamp"])); + } + valueCopy.removeMember("importedResetTimestamp"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "minMeasuredValue"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.minMeasuredValue, value["minMeasuredValue"])); - valueCopy.removeMember("minMeasuredValue"); + if (value.isMember("exportedResetTimestamp")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "exportedResetTimestamp"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.exportedResetTimestamp, value["exportedResetTimestamp"])); + } + valueCopy.removeMember("exportedResetTimestamp"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "maxMeasuredValue"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.maxMeasuredValue, value["maxMeasuredValue"])); - valueCopy.removeMember("maxMeasuredValue"); + if (value.isMember("importedResetSystime")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "importedResetSystime"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.importedResetSystime, value["importedResetSystime"])); + } + valueCopy.removeMember("importedResetSystime"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "accuracyRanges"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.accuracyRanges, value["accuracyRanges"])); - valueCopy.removeMember("accuracyRanges"); + if (value.isMember("exportedResetSystime")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "exportedResetSystime"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.exportedResetSystime, value["exportedResetSystime"])); + } + valueCopy.removeMember("exportedResetSystime"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } void ComplexArgumentParser::Finalize( - chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::Type & request) + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::CumulativeEnergyResetStruct::Type & request) { - ComplexArgumentParser::Finalize(request.measurementType); - ComplexArgumentParser::Finalize(request.measured); - ComplexArgumentParser::Finalize(request.minMeasuredValue); - ComplexArgumentParser::Finalize(request.maxMeasuredValue); - ComplexArgumentParser::Finalize(request.accuracyRanges); + ComplexArgumentParser::Finalize(request.importedResetTimestamp); + ComplexArgumentParser::Finalize(request.exportedResetTimestamp); + ComplexArgumentParser::Finalize(request.importedResetSystime); + ComplexArgumentParser::Finalize(request.exportedResetSystime); } CHIP_ERROR diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h index 5a049d98f82048..a9ac94c6cecb77 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h @@ -32,6 +32,16 @@ static CHIP_ERROR Setup(const char * label, chip::app::Clusters::detail::Structs static void Finalize(chip::app::Clusters::detail::Structs::ModeOptionStruct::Type & request); +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::detail::Structs::MeasurementAccuracyRangeStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::detail::Structs::MeasurementAccuracyRangeStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::detail::Structs::MeasurementAccuracyStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::detail::Structs::MeasurementAccuracyStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request, Json::Value & value); @@ -277,16 +287,22 @@ static CHIP_ERROR Setup(const char * label, static void Finalize(chip::app::Clusters::ActivatedCarbonFilterMonitoring::Structs::ReplacementProductStruct::Type & request); static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::Type & request, + chip::app::Clusters::ElectricalPowerMeasurement::Structs::HarmonicMeasurementStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::ElectricalPowerMeasurement::Structs::HarmonicMeasurementStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::ElectricalPowerMeasurement::Structs::MeasurementRangeStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::Type & request); +static void Finalize(chip::app::Clusters::ElectricalPowerMeasurement::Structs::MeasurementRangeStruct::Type & request); static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::Type & request, + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::CumulativeEnergyResetStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::Type & request); +static void Finalize(chip::app::Clusters::ElectricalEnergyMeasurement::Structs::CumulativeEnergyResetStruct::Type & request); static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::Type & request, diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index 1c88685f924640..fde5089bab8a7c 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -79,6 +79,129 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::detail::Structs::MeasurementAccuracyRangeStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("RangeMin", indent + 1, value.rangeMin); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RangeMin'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("RangeMax", indent + 1, value.rangeMax); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RangeMax'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("PercentMax", indent + 1, value.percentMax); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PercentMax'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("PercentMin", indent + 1, value.percentMin); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PercentMin'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("PercentTypical", indent + 1, value.percentTypical); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PercentTypical'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("FixedMax", indent + 1, value.fixedMax); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FixedMax'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("FixedMin", indent + 1, value.fixedMin); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FixedMin'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("FixedTypical", indent + 1, value.fixedTypical); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FixedTypical'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::detail::Structs::MeasurementAccuracyStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("MeasurementType", indent + 1, value.measurementType); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MeasurementType'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("Measured", indent + 1, value.measured); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Measured'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("MinMeasuredValue", indent + 1, value.minMeasuredValue); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MinMeasuredValue'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("MaxMeasuredValue", indent + 1, value.maxMeasuredValue); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MaxMeasuredValue'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("AccuracyRanges", indent + 1, value.accuracyRanges); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AccuracyRanges'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::detail::Structs::ApplicationStruct::DecodableType & value) { @@ -1988,70 +2111,120 @@ CHIP_ERROR DataModelLogger::LogValue( CHIP_ERROR DataModelLogger::LogValue( const char * label, size_t indent, - const chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::DecodableType & value) + const chip::app::Clusters::ElectricalPowerMeasurement::Structs::HarmonicMeasurementStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("RangeMin", indent + 1, value.rangeMin); + CHIP_ERROR err = LogValue("Order", indent + 1, value.order); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RangeMin'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Order'"); return err; } } { - CHIP_ERROR err = LogValue("RangeMax", indent + 1, value.rangeMax); + CHIP_ERROR err = LogValue("Measurement", indent + 1, value.measurement); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RangeMax'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Measurement'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue( + const char * label, size_t indent, + const chip::app::Clusters::ElectricalPowerMeasurement::Structs::MeasurementRangeStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("PercentMax", indent + 1, value.percentMax); + CHIP_ERROR err = LogValue("MeasurementType", indent + 1, value.measurementType); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PercentMax'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MeasurementType'"); return err; } } { - CHIP_ERROR err = LogValue("PercentMin", indent + 1, value.percentMin); + CHIP_ERROR err = LogValue("Min", indent + 1, value.min); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PercentMin'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Min'"); return err; } } { - CHIP_ERROR err = LogValue("PercentTypical", indent + 1, value.percentTypical); + CHIP_ERROR err = LogValue("Max", indent + 1, value.max); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PercentTypical'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Max'"); return err; } } { - CHIP_ERROR err = LogValue("FixedMax", indent + 1, value.fixedMax); + CHIP_ERROR err = LogValue("StartTimestamp", indent + 1, value.startTimestamp); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FixedMax'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StartTimestamp'"); return err; } } { - CHIP_ERROR err = LogValue("FixedMin", indent + 1, value.fixedMin); + CHIP_ERROR err = LogValue("EndTimestamp", indent + 1, value.endTimestamp); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FixedMin'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EndTimestamp'"); return err; } } { - CHIP_ERROR err = LogValue("FixedTypical", indent + 1, value.fixedTypical); + CHIP_ERROR err = LogValue("MinTimestamp", indent + 1, value.minTimestamp); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FixedTypical'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MinTimestamp'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("MaxTimestamp", indent + 1, value.maxTimestamp); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MaxTimestamp'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("StartSystime", indent + 1, value.startSystime); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StartSystime'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("EndSystime", indent + 1, value.endSystime); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EndSystime'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("MinSystime", indent + 1, value.minSystime); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MinSystime'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("MaxSystime", indent + 1, value.maxSystime); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MaxSystime'"); return err; } } @@ -2062,46 +2235,38 @@ CHIP_ERROR DataModelLogger::LogValue( CHIP_ERROR DataModelLogger::LogValue( const char * label, size_t indent, - const chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::DecodableType & value) + const chip::app::Clusters::ElectricalEnergyMeasurement::Structs::CumulativeEnergyResetStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("MeasurementType", indent + 1, value.measurementType); + CHIP_ERROR err = LogValue("ImportedResetTimestamp", indent + 1, value.importedResetTimestamp); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MeasurementType'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ImportedResetTimestamp'"); return err; } } { - CHIP_ERROR err = LogValue("Measured", indent + 1, value.measured); + CHIP_ERROR err = LogValue("ExportedResetTimestamp", indent + 1, value.exportedResetTimestamp); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Measured'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExportedResetTimestamp'"); return err; } } { - CHIP_ERROR err = LogValue("MinMeasuredValue", indent + 1, value.minMeasuredValue); + CHIP_ERROR err = LogValue("ImportedResetSystime", indent + 1, value.importedResetSystime); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MinMeasuredValue'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ImportedResetSystime'"); return err; } } { - CHIP_ERROR err = LogValue("MaxMeasuredValue", indent + 1, value.maxMeasuredValue); + CHIP_ERROR err = LogValue("ExportedResetSystime", indent + 1, value.exportedResetSystime); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MaxMeasuredValue'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("AccuracyRanges", indent + 1, value.accuracyRanges); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AccuracyRanges'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExportedResetSystime'"); return err; } } @@ -5974,6 +6139,22 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const ElectricalPowerMeasurement::Events::MeasurementPeriodRanges::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = DataModelLogger::LogValue("Ranges", indent + 1, value.ranges); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'Ranges'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const ElectricalEnergyMeasurement::Events::CumulativeEnergyMeasured::DecodableType & value) { @@ -7186,6 +7367,14 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, DataModelLogger::LogString(indent, "}"); return CHIP_NO_ERROR; } +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const GeneralDiagnostics::Commands::PayloadTestResponse::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + ReturnErrorOnFailure(DataModelLogger::LogValue("payload", indent + 1, value.payload)); + DataModelLogger::LogString(indent, "}"); + return CHIP_NO_ERROR; +} CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType & value) { @@ -12245,6 +12434,145 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP } break; } + case ElectricalPowerMeasurement::Id: { + switch (path.mAttributeId) + { + case ElectricalPowerMeasurement::Attributes::PowerMode::Id: { + chip::app::Clusters::ElectricalPowerMeasurement::PowerModeEnum value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("PowerMode", 1, value); + } + case ElectricalPowerMeasurement::Attributes::NumberOfMeasurementTypes::Id: { + uint8_t value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("NumberOfMeasurementTypes", 1, value); + } + case ElectricalPowerMeasurement::Attributes::Accuracy::Id: { + chip::app::DataModel::DecodableList< + chip::app::Clusters::ElectricalPowerMeasurement::Structs::MeasurementAccuracyStruct::DecodableType> + value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("Accuracy", 1, value); + } + case ElectricalPowerMeasurement::Attributes::Ranges::Id: { + chip::app::DataModel::DecodableList< + chip::app::Clusters::ElectricalPowerMeasurement::Structs::MeasurementRangeStruct::DecodableType> + value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("Ranges", 1, value); + } + case ElectricalPowerMeasurement::Attributes::Voltage::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("Voltage", 1, value); + } + case ElectricalPowerMeasurement::Attributes::ActiveCurrent::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("ActiveCurrent", 1, value); + } + case ElectricalPowerMeasurement::Attributes::ReactiveCurrent::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("ReactiveCurrent", 1, value); + } + case ElectricalPowerMeasurement::Attributes::ApparentCurrent::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("ApparentCurrent", 1, value); + } + case ElectricalPowerMeasurement::Attributes::ActivePower::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("ActivePower", 1, value); + } + case ElectricalPowerMeasurement::Attributes::ReactivePower::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("ReactivePower", 1, value); + } + case ElectricalPowerMeasurement::Attributes::ApparentPower::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("ApparentPower", 1, value); + } + case ElectricalPowerMeasurement::Attributes::RMSVoltage::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("RMSVoltage", 1, value); + } + case ElectricalPowerMeasurement::Attributes::RMSCurrent::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("RMSCurrent", 1, value); + } + case ElectricalPowerMeasurement::Attributes::RMSPower::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("RMSPower", 1, value); + } + case ElectricalPowerMeasurement::Attributes::Frequency::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("Frequency", 1, value); + } + case ElectricalPowerMeasurement::Attributes::HarmonicCurrents::Id: { + chip::app::DataModel::Nullable> + value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("HarmonicCurrents", 1, value); + } + case ElectricalPowerMeasurement::Attributes::HarmonicPhases::Id: { + chip::app::DataModel::Nullable> + value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("HarmonicPhases", 1, value); + } + case ElectricalPowerMeasurement::Attributes::PowerFactor::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("PowerFactor", 1, value); + } + case ElectricalPowerMeasurement::Attributes::NeutralCurrent::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("NeutralCurrent", 1, value); + } + case ElectricalPowerMeasurement::Attributes::GeneratedCommandList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("GeneratedCommandList", 1, value); + } + case ElectricalPowerMeasurement::Attributes::AcceptedCommandList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("AcceptedCommandList", 1, value); + } + case ElectricalPowerMeasurement::Attributes::EventList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("EventList", 1, value); + } + case ElectricalPowerMeasurement::Attributes::AttributeList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("AttributeList", 1, value); + } + case ElectricalPowerMeasurement::Attributes::FeatureMap::Id: { + uint32_t value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("FeatureMap", 1, value); + } + case ElectricalPowerMeasurement::Attributes::ClusterRevision::Id: { + uint16_t value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("ClusterRevision", 1, value); + } + } + break; + } case ElectricalEnergyMeasurement::Id: { switch (path.mAttributeId) { @@ -12281,6 +12609,13 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("PeriodicEnergyExported", 1, value); } + case ElectricalEnergyMeasurement::Attributes::CumulativeEnergyReset::Id: { + chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::CumulativeEnergyResetStruct::DecodableType> + value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("CumulativeEnergyReset", 1, value); + } case ElectricalEnergyMeasurement::Attributes::GeneratedCommandList::Id: { chip::app::DataModel::DecodableList value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); @@ -12733,6 +13068,52 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP } break; } + case PowerTopology::Id: { + switch (path.mAttributeId) + { + case PowerTopology::Attributes::AvailableEndpoints::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("AvailableEndpoints", 1, value); + } + case PowerTopology::Attributes::ActiveEndpoints::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("ActiveEndpoints", 1, value); + } + case PowerTopology::Attributes::GeneratedCommandList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("GeneratedCommandList", 1, value); + } + case PowerTopology::Attributes::AcceptedCommandList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("AcceptedCommandList", 1, value); + } + case PowerTopology::Attributes::EventList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("EventList", 1, value); + } + case PowerTopology::Attributes::AttributeList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("AttributeList", 1, value); + } + case PowerTopology::Attributes::FeatureMap::Id: { + uint32_t value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("FeatureMap", 1, value); + } + case PowerTopology::Attributes::ClusterRevision::Id: { + uint16_t value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("ClusterRevision", 1, value); + } + } + break; + } case EnergyEvseMode::Id: { switch (path.mAttributeId) { @@ -17760,6 +18141,11 @@ CHIP_ERROR DataModelLogger::LogCommand(const chip::app::ConcreteCommandPath & pa ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("TimeSnapshotResponse", 1, value); } + case GeneralDiagnostics::Commands::PayloadTestResponse::Id: { + GeneralDiagnostics::Commands::PayloadTestResponse::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("PayloadTestResponse", 1, value); + } } break; } @@ -18740,6 +19126,17 @@ CHIP_ERROR DataModelLogger::LogEvent(const chip::app::EventHeader & header, chip } break; } + case ElectricalPowerMeasurement::Id: { + switch (header.mPath.mEventId) + { + case ElectricalPowerMeasurement::Events::MeasurementPeriodRanges::Id: { + chip::app::Clusters::ElectricalPowerMeasurement::Events::MeasurementPeriodRanges::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("MeasurementPeriodRanges", 1, value); + } + } + break; + } case ElectricalEnergyMeasurement::Id: { switch (header.mPath.mEventId) { diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h index fd4d6895f7ea44..1c790b5e002039 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -26,6 +26,12 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::detail::Structs::ModeOptionStruct::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::detail::Structs::MeasurementAccuracyRangeStruct::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::detail::Structs::MeasurementAccuracyStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::detail::Structs::ApplicationStruct::DecodableType & value); @@ -175,11 +181,15 @@ LogValue(const char * label, size_t indent, static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::DecodableType & value); + const chip::app::Clusters::ElectricalPowerMeasurement::Structs::HarmonicMeasurementStruct::DecodableType & value); + +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::ElectricalPowerMeasurement::Structs::MeasurementRangeStruct::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::DecodableType & value); + const chip::app::Clusters::ElectricalEnergyMeasurement::Structs::CumulativeEnergyResetStruct::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, @@ -502,6 +512,9 @@ LogValue(const char * label, size_t indent, static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::ValveConfigurationAndControl::Events::ValveFault::DecodableType & value); static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::ElectricalPowerMeasurement::Events::MeasurementPeriodRanges::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::ElectricalEnergyMeasurement::Events::CumulativeEnergyMeasured::DecodableType & value); static CHIP_ERROR @@ -641,6 +654,8 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsResponse::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::GeneralDiagnostics::Commands::TimeSnapshotResponse::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::GeneralDiagnostics::Commands::PayloadTestResponse::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, diff --git a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h index 3a487ec7d0ddeb..9a1389e416deb4 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -102,12 +102,14 @@ | ActivatedCarbonFilterMonitoring | 0x0072 | | BooleanStateConfiguration | 0x0080 | | ValveConfigurationAndControl | 0x0081 | +| ElectricalPowerMeasurement | 0x0090 | | ElectricalEnergyMeasurement | 0x0091 | | DemandResponseLoadControl | 0x0096 | | Messages | 0x0097 | | DeviceEnergyManagement | 0x0098 | | EnergyEvse | 0x0099 | | EnergyPreference | 0x009B | +| PowerTopology | 0x009C | | EnergyEvseMode | 0x009D | | DeviceEnergyManagementMode | 0x009F | | DoorLock | 0x0101 | @@ -26424,6 +26426,7 @@ class SubscribeAttributeDiagnosticLogsClusterRevision : public SubscribeAttribut | Commands: | | | * TestEventTrigger | 0x00 | | * TimeSnapshot | 0x01 | +| * PayloadTestRequest | 0x03 | |------------------------------------------------------------------------------| | Attributes: | | | * NetworkInterfaces | 0x0000 | @@ -26549,6 +26552,77 @@ class GeneralDiagnosticsTimeSnapshot : public ClusterCommand { private: }; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL +/* + * Command PayloadTestRequest + */ +class GeneralDiagnosticsPayloadTestRequest : public ClusterCommand { +public: + GeneralDiagnosticsPayloadTestRequest() + : ClusterCommand("payload-test-request") + { +#if MTR_ENABLE_PROVISIONAL + AddArgument("EnableKey", &mRequest.enableKey); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("Value", 0, UINT8_MAX, &mRequest.value); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("Count", 0, UINT16_MAX, &mRequest.count); +#endif // MTR_ENABLE_PROVISIONAL + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::GeneralDiagnostics::Id; + constexpr chip::CommandId commandId = chip::app::Clusters::GeneralDiagnostics::Commands::PayloadTestRequest::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") command (0x%08" PRIX32 ") on endpoint %u", clusterId, commandId, endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRGeneralDiagnosticsClusterPayloadTestRequestParams alloc] init]; + params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; +#if MTR_ENABLE_PROVISIONAL + params.enableKey = [NSData dataWithBytes:mRequest.enableKey.data() length:mRequest.enableKey.size()]; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.value = [NSNumber numberWithUnsignedChar:mRequest.value]; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.count = [NSNumber numberWithUnsignedShort:mRequest.count]; +#endif // MTR_ENABLE_PROVISIONAL + uint16_t repeatCount = mRepeatCount.ValueOr(1); + uint16_t __block responsesNeeded = repeatCount; + while (repeatCount--) { + [cluster payloadTestRequestWithParams:params completion: + ^(MTRGeneralDiagnosticsClusterPayloadTestResponseParams * _Nullable values, NSError * _Nullable error) { + NSLog(@"Values: %@", values); + if (error == nil) { + constexpr chip::CommandId responseId = chip::app::Clusters::GeneralDiagnostics::Commands::PayloadTestResponse::Id; + RemoteDataModelLogger::LogCommandAsJSON(@(endpointId), @(clusterId), @(responseId), values); + } + responsesNeeded--; + if (error != nil) { + mError = error; + LogNSError("Error", error); + constexpr chip::CommandId responseId = chip::app::Clusters::GeneralDiagnostics::Commands::PayloadTestResponse::Id; + RemoteDataModelLogger::LogCommandErrorAsJSON(@(endpointId), @(clusterId), @(responseId), error); + } + if (responsesNeeded == 0) { + SetCommandExitStatus(mError); + } + }]; + } + return CHIP_NO_ERROR; + } + +private: + chip::app::Clusters::GeneralDiagnostics::Commands::PayloadTestRequest::Type mRequest; +}; + #endif // MTR_ENABLE_PROVISIONAL /* @@ -76026,6 +76100,2169 @@ class SubscribeAttributeValveConfigurationAndControlClusterRevision : public Sub } }; +#endif // MTR_ENABLE_PROVISIONAL +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL +/*----------------------------------------------------------------------------*\ +| Cluster ElectricalPowerMeasurement | 0x0090 | +|------------------------------------------------------------------------------| +| Commands: | | +|------------------------------------------------------------------------------| +| Attributes: | | +| * PowerMode | 0x0000 | +| * NumberOfMeasurementTypes | 0x0001 | +| * Accuracy | 0x0002 | +| * Ranges | 0x0003 | +| * Voltage | 0x0004 | +| * ActiveCurrent | 0x0005 | +| * ReactiveCurrent | 0x0006 | +| * ApparentCurrent | 0x0007 | +| * ActivePower | 0x0008 | +| * ReactivePower | 0x0009 | +| * ApparentPower | 0x000A | +| * RMSVoltage | 0x000B | +| * RMSCurrent | 0x000C | +| * RMSPower | 0x000D | +| * Frequency | 0x000E | +| * HarmonicCurrents | 0x000F | +| * HarmonicPhases | 0x0010 | +| * PowerFactor | 0x0011 | +| * NeutralCurrent | 0x0012 | +| * GeneratedCommandList | 0xFFF8 | +| * AcceptedCommandList | 0xFFF9 | +| * EventList | 0xFFFA | +| * AttributeList | 0xFFFB | +| * FeatureMap | 0xFFFC | +| * ClusterRevision | 0xFFFD | +|------------------------------------------------------------------------------| +| Events: | | +| * MeasurementPeriodRanges | 0x0000 | +\*----------------------------------------------------------------------------*/ + +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute PowerMode + */ +class ReadElectricalPowerMeasurementPowerMode : public ReadAttribute { +public: + ReadElectricalPowerMeasurementPowerMode() + : ReadAttribute("power-mode") + { + } + + ~ReadElectricalPowerMeasurementPowerMode() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::PowerMode::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributePowerModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.PowerMode response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement PowerMode read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementPowerMode : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementPowerMode() + : SubscribeAttribute("power-mode") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementPowerMode() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::PowerMode::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributePowerModeWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.PowerMode response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute NumberOfMeasurementTypes + */ +class ReadElectricalPowerMeasurementNumberOfMeasurementTypes : public ReadAttribute { +public: + ReadElectricalPowerMeasurementNumberOfMeasurementTypes() + : ReadAttribute("number-of-measurement-types") + { + } + + ~ReadElectricalPowerMeasurementNumberOfMeasurementTypes() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::NumberOfMeasurementTypes::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeNumberOfMeasurementTypesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.NumberOfMeasurementTypes response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement NumberOfMeasurementTypes read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementNumberOfMeasurementTypes : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementNumberOfMeasurementTypes() + : SubscribeAttribute("number-of-measurement-types") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementNumberOfMeasurementTypes() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::NumberOfMeasurementTypes::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeNumberOfMeasurementTypesWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.NumberOfMeasurementTypes response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute Accuracy + */ +class ReadElectricalPowerMeasurementAccuracy : public ReadAttribute { +public: + ReadElectricalPowerMeasurementAccuracy() + : ReadAttribute("accuracy") + { + } + + ~ReadElectricalPowerMeasurementAccuracy() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::Accuracy::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeAccuracyWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.Accuracy response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement Accuracy read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementAccuracy : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementAccuracy() + : SubscribeAttribute("accuracy") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementAccuracy() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::Accuracy::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeAccuracyWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.Accuracy response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute Ranges + */ +class ReadElectricalPowerMeasurementRanges : public ReadAttribute { +public: + ReadElectricalPowerMeasurementRanges() + : ReadAttribute("ranges") + { + } + + ~ReadElectricalPowerMeasurementRanges() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::Ranges::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeRangesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.Ranges response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement Ranges read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementRanges : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementRanges() + : SubscribeAttribute("ranges") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementRanges() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::Ranges::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeRangesWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.Ranges response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute Voltage + */ +class ReadElectricalPowerMeasurementVoltage : public ReadAttribute { +public: + ReadElectricalPowerMeasurementVoltage() + : ReadAttribute("voltage") + { + } + + ~ReadElectricalPowerMeasurementVoltage() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::Voltage::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeVoltageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.Voltage response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement Voltage read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementVoltage : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementVoltage() + : SubscribeAttribute("voltage") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementVoltage() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::Voltage::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeVoltageWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.Voltage response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute ActiveCurrent + */ +class ReadElectricalPowerMeasurementActiveCurrent : public ReadAttribute { +public: + ReadElectricalPowerMeasurementActiveCurrent() + : ReadAttribute("active-current") + { + } + + ~ReadElectricalPowerMeasurementActiveCurrent() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::ActiveCurrent::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeActiveCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.ActiveCurrent response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement ActiveCurrent read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementActiveCurrent : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementActiveCurrent() + : SubscribeAttribute("active-current") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementActiveCurrent() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::ActiveCurrent::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeActiveCurrentWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.ActiveCurrent response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute ReactiveCurrent + */ +class ReadElectricalPowerMeasurementReactiveCurrent : public ReadAttribute { +public: + ReadElectricalPowerMeasurementReactiveCurrent() + : ReadAttribute("reactive-current") + { + } + + ~ReadElectricalPowerMeasurementReactiveCurrent() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::ReactiveCurrent::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeReactiveCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.ReactiveCurrent response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement ReactiveCurrent read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementReactiveCurrent : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementReactiveCurrent() + : SubscribeAttribute("reactive-current") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementReactiveCurrent() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::ReactiveCurrent::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeReactiveCurrentWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.ReactiveCurrent response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute ApparentCurrent + */ +class ReadElectricalPowerMeasurementApparentCurrent : public ReadAttribute { +public: + ReadElectricalPowerMeasurementApparentCurrent() + : ReadAttribute("apparent-current") + { + } + + ~ReadElectricalPowerMeasurementApparentCurrent() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::ApparentCurrent::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeApparentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.ApparentCurrent response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement ApparentCurrent read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementApparentCurrent : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementApparentCurrent() + : SubscribeAttribute("apparent-current") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementApparentCurrent() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::ApparentCurrent::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeApparentCurrentWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.ApparentCurrent response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute ActivePower + */ +class ReadElectricalPowerMeasurementActivePower : public ReadAttribute { +public: + ReadElectricalPowerMeasurementActivePower() + : ReadAttribute("active-power") + { + } + + ~ReadElectricalPowerMeasurementActivePower() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::ActivePower::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeActivePowerWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.ActivePower response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement ActivePower read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementActivePower : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementActivePower() + : SubscribeAttribute("active-power") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementActivePower() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::ActivePower::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeActivePowerWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.ActivePower response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute ReactivePower + */ +class ReadElectricalPowerMeasurementReactivePower : public ReadAttribute { +public: + ReadElectricalPowerMeasurementReactivePower() + : ReadAttribute("reactive-power") + { + } + + ~ReadElectricalPowerMeasurementReactivePower() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::ReactivePower::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeReactivePowerWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.ReactivePower response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement ReactivePower read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementReactivePower : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementReactivePower() + : SubscribeAttribute("reactive-power") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementReactivePower() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::ReactivePower::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeReactivePowerWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.ReactivePower response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute ApparentPower + */ +class ReadElectricalPowerMeasurementApparentPower : public ReadAttribute { +public: + ReadElectricalPowerMeasurementApparentPower() + : ReadAttribute("apparent-power") + { + } + + ~ReadElectricalPowerMeasurementApparentPower() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::ApparentPower::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeApparentPowerWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.ApparentPower response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement ApparentPower read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementApparentPower : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementApparentPower() + : SubscribeAttribute("apparent-power") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementApparentPower() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::ApparentPower::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeApparentPowerWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.ApparentPower response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute RMSVoltage + */ +class ReadElectricalPowerMeasurementRMSVoltage : public ReadAttribute { +public: + ReadElectricalPowerMeasurementRMSVoltage() + : ReadAttribute("rmsvoltage") + { + } + + ~ReadElectricalPowerMeasurementRMSVoltage() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::RMSVoltage::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeRMSVoltageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.RMSVoltage response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement RMSVoltage read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementRMSVoltage : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementRMSVoltage() + : SubscribeAttribute("rmsvoltage") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementRMSVoltage() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::RMSVoltage::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeRMSVoltageWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.RMSVoltage response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute RMSCurrent + */ +class ReadElectricalPowerMeasurementRMSCurrent : public ReadAttribute { +public: + ReadElectricalPowerMeasurementRMSCurrent() + : ReadAttribute("rmscurrent") + { + } + + ~ReadElectricalPowerMeasurementRMSCurrent() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::RMSCurrent::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeRMSCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.RMSCurrent response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement RMSCurrent read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementRMSCurrent : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementRMSCurrent() + : SubscribeAttribute("rmscurrent") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementRMSCurrent() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::RMSCurrent::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeRMSCurrentWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.RMSCurrent response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute RMSPower + */ +class ReadElectricalPowerMeasurementRMSPower : public ReadAttribute { +public: + ReadElectricalPowerMeasurementRMSPower() + : ReadAttribute("rmspower") + { + } + + ~ReadElectricalPowerMeasurementRMSPower() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::RMSPower::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeRMSPowerWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.RMSPower response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement RMSPower read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementRMSPower : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementRMSPower() + : SubscribeAttribute("rmspower") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementRMSPower() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::RMSPower::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeRMSPowerWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.RMSPower response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute Frequency + */ +class ReadElectricalPowerMeasurementFrequency : public ReadAttribute { +public: + ReadElectricalPowerMeasurementFrequency() + : ReadAttribute("frequency") + { + } + + ~ReadElectricalPowerMeasurementFrequency() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::Frequency::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.Frequency response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement Frequency read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementFrequency : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementFrequency() + : SubscribeAttribute("frequency") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementFrequency() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::Frequency::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeFrequencyWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.Frequency response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute HarmonicCurrents + */ +class ReadElectricalPowerMeasurementHarmonicCurrents : public ReadAttribute { +public: + ReadElectricalPowerMeasurementHarmonicCurrents() + : ReadAttribute("harmonic-currents") + { + } + + ~ReadElectricalPowerMeasurementHarmonicCurrents() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::HarmonicCurrents::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeHarmonicCurrentsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.HarmonicCurrents response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement HarmonicCurrents read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementHarmonicCurrents : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementHarmonicCurrents() + : SubscribeAttribute("harmonic-currents") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementHarmonicCurrents() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::HarmonicCurrents::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeHarmonicCurrentsWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.HarmonicCurrents response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute HarmonicPhases + */ +class ReadElectricalPowerMeasurementHarmonicPhases : public ReadAttribute { +public: + ReadElectricalPowerMeasurementHarmonicPhases() + : ReadAttribute("harmonic-phases") + { + } + + ~ReadElectricalPowerMeasurementHarmonicPhases() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::HarmonicPhases::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeHarmonicPhasesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.HarmonicPhases response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement HarmonicPhases read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementHarmonicPhases : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementHarmonicPhases() + : SubscribeAttribute("harmonic-phases") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementHarmonicPhases() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::HarmonicPhases::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeHarmonicPhasesWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.HarmonicPhases response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute PowerFactor + */ +class ReadElectricalPowerMeasurementPowerFactor : public ReadAttribute { +public: + ReadElectricalPowerMeasurementPowerFactor() + : ReadAttribute("power-factor") + { + } + + ~ReadElectricalPowerMeasurementPowerFactor() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::PowerFactor::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributePowerFactorWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.PowerFactor response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement PowerFactor read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementPowerFactor : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementPowerFactor() + : SubscribeAttribute("power-factor") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementPowerFactor() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::PowerFactor::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributePowerFactorWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.PowerFactor response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute NeutralCurrent + */ +class ReadElectricalPowerMeasurementNeutralCurrent : public ReadAttribute { +public: + ReadElectricalPowerMeasurementNeutralCurrent() + : ReadAttribute("neutral-current") + { + } + + ~ReadElectricalPowerMeasurementNeutralCurrent() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::NeutralCurrent::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeNeutralCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.NeutralCurrent response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement NeutralCurrent read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementNeutralCurrent : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementNeutralCurrent() + : SubscribeAttribute("neutral-current") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementNeutralCurrent() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::NeutralCurrent::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeNeutralCurrentWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.NeutralCurrent response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute GeneratedCommandList + */ +class ReadElectricalPowerMeasurementGeneratedCommandList : public ReadAttribute { +public: + ReadElectricalPowerMeasurementGeneratedCommandList() + : ReadAttribute("generated-command-list") + { + } + + ~ReadElectricalPowerMeasurementGeneratedCommandList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::GeneratedCommandList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.GeneratedCommandList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement GeneratedCommandList read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementGeneratedCommandList : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementGeneratedCommandList() + : SubscribeAttribute("generated-command-list") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementGeneratedCommandList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::GeneratedCommandList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeGeneratedCommandListWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.GeneratedCommandList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute AcceptedCommandList + */ +class ReadElectricalPowerMeasurementAcceptedCommandList : public ReadAttribute { +public: + ReadElectricalPowerMeasurementAcceptedCommandList() + : ReadAttribute("accepted-command-list") + { + } + + ~ReadElectricalPowerMeasurementAcceptedCommandList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::AcceptedCommandList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.AcceptedCommandList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement AcceptedCommandList read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementAcceptedCommandList : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementAcceptedCommandList() + : SubscribeAttribute("accepted-command-list") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementAcceptedCommandList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::AcceptedCommandList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeAcceptedCommandListWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.AcceptedCommandList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute EventList + */ +class ReadElectricalPowerMeasurementEventList : public ReadAttribute { +public: + ReadElectricalPowerMeasurementEventList() + : ReadAttribute("event-list") + { + } + + ~ReadElectricalPowerMeasurementEventList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::EventList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeEventListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.EventList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement EventList read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementEventList : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementEventList() + : SubscribeAttribute("event-list") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementEventList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::EventList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeEventListWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.EventList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute AttributeList + */ +class ReadElectricalPowerMeasurementAttributeList : public ReadAttribute { +public: + ReadElectricalPowerMeasurementAttributeList() + : ReadAttribute("attribute-list") + { + } + + ~ReadElectricalPowerMeasurementAttributeList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::AttributeList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.AttributeList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement AttributeList read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementAttributeList : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementAttributeList() + : SubscribeAttribute("attribute-list") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementAttributeList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::AttributeList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeAttributeListWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.AttributeList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute FeatureMap + */ +class ReadElectricalPowerMeasurementFeatureMap : public ReadAttribute { +public: + ReadElectricalPowerMeasurementFeatureMap() + : ReadAttribute("feature-map") + { + } + + ~ReadElectricalPowerMeasurementFeatureMap() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::FeatureMap::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.FeatureMap response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement FeatureMap read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementFeatureMap : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementFeatureMap() + : SubscribeAttribute("feature-map") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementFeatureMap() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::FeatureMap::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeFeatureMapWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.FeatureMap response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute ClusterRevision + */ +class ReadElectricalPowerMeasurementClusterRevision : public ReadAttribute { +public: + ReadElectricalPowerMeasurementClusterRevision() + : ReadAttribute("cluster-revision") + { + } + + ~ReadElectricalPowerMeasurementClusterRevision() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::ClusterRevision::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.ClusterRevision response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalPowerMeasurement ClusterRevision read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalPowerMeasurementClusterRevision : public SubscribeAttribute { +public: + SubscribeAttributeElectricalPowerMeasurementClusterRevision() + : SubscribeAttribute("cluster-revision") + { + } + + ~SubscribeAttributeElectricalPowerMeasurementClusterRevision() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalPowerMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalPowerMeasurement::Attributes::ClusterRevision::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalPowerMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeClusterRevisionWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalPowerMeasurement.ClusterRevision response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + #endif // MTR_ENABLE_PROVISIONAL #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL @@ -76040,6 +78277,7 @@ class SubscribeAttributeValveConfigurationAndControlClusterRevision : public Sub | * CumulativeEnergyExported | 0x0002 | | * PeriodicEnergyImported | 0x0003 | | * PeriodicEnergyExported | 0x0004 | +| * CumulativeEnergyReset | 0x0005 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -76479,6 +78717,91 @@ class SubscribeAttributeElectricalEnergyMeasurementPeriodicEnergyExported : publ #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL +/* + * Attribute CumulativeEnergyReset + */ +class ReadElectricalEnergyMeasurementCumulativeEnergyReset : public ReadAttribute { +public: + ReadElectricalEnergyMeasurementCumulativeEnergyReset() + : ReadAttribute("cumulative-energy-reset") + { + } + + ~ReadElectricalEnergyMeasurementCumulativeEnergyReset() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::CumulativeEnergyReset::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeCumulativeEnergyResetWithCompletion:^(MTRElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.CumulativeEnergyReset response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalEnergyMeasurement CumulativeEnergyReset read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalEnergyMeasurementCumulativeEnergyReset : public SubscribeAttribute { +public: + SubscribeAttributeElectricalEnergyMeasurementCumulativeEnergyReset() + : SubscribeAttribute("cumulative-energy-reset") + { + } + + ~SubscribeAttributeElectricalEnergyMeasurementCumulativeEnergyReset() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::CumulativeEnergyReset::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeCumulativeEnergyResetWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(MTRElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.CumulativeEnergyReset response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + /* * Attribute GeneratedCommandList */ @@ -85367,6 +87690,706 @@ class SubscribeAttributeEnergyPreferenceClusterRevision : public SubscribeAttrib } }; +#endif // MTR_ENABLE_PROVISIONAL +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL +/*----------------------------------------------------------------------------*\ +| Cluster PowerTopology | 0x009C | +|------------------------------------------------------------------------------| +| Commands: | | +|------------------------------------------------------------------------------| +| Attributes: | | +| * AvailableEndpoints | 0x0000 | +| * ActiveEndpoints | 0x0001 | +| * GeneratedCommandList | 0xFFF8 | +| * AcceptedCommandList | 0xFFF9 | +| * EventList | 0xFFFA | +| * AttributeList | 0xFFFB | +| * FeatureMap | 0xFFFC | +| * ClusterRevision | 0xFFFD | +|------------------------------------------------------------------------------| +| Events: | | +\*----------------------------------------------------------------------------*/ + +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute AvailableEndpoints + */ +class ReadPowerTopologyAvailableEndpoints : public ReadAttribute { +public: + ReadPowerTopologyAvailableEndpoints() + : ReadAttribute("available-endpoints") + { + } + + ~ReadPowerTopologyAvailableEndpoints() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::PowerTopology::Attributes::AvailableEndpoints::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeAvailableEndpointsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.AvailableEndpoints response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("PowerTopology AvailableEndpoints read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributePowerTopologyAvailableEndpoints : public SubscribeAttribute { +public: + SubscribeAttributePowerTopologyAvailableEndpoints() + : SubscribeAttribute("available-endpoints") + { + } + + ~SubscribeAttributePowerTopologyAvailableEndpoints() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::PowerTopology::Attributes::AvailableEndpoints::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeAvailableEndpointsWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.AvailableEndpoints response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute ActiveEndpoints + */ +class ReadPowerTopologyActiveEndpoints : public ReadAttribute { +public: + ReadPowerTopologyActiveEndpoints() + : ReadAttribute("active-endpoints") + { + } + + ~ReadPowerTopologyActiveEndpoints() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::PowerTopology::Attributes::ActiveEndpoints::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeActiveEndpointsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.ActiveEndpoints response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("PowerTopology ActiveEndpoints read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributePowerTopologyActiveEndpoints : public SubscribeAttribute { +public: + SubscribeAttributePowerTopologyActiveEndpoints() + : SubscribeAttribute("active-endpoints") + { + } + + ~SubscribeAttributePowerTopologyActiveEndpoints() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::PowerTopology::Attributes::ActiveEndpoints::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeActiveEndpointsWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.ActiveEndpoints response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute GeneratedCommandList + */ +class ReadPowerTopologyGeneratedCommandList : public ReadAttribute { +public: + ReadPowerTopologyGeneratedCommandList() + : ReadAttribute("generated-command-list") + { + } + + ~ReadPowerTopologyGeneratedCommandList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::PowerTopology::Attributes::GeneratedCommandList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.GeneratedCommandList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("PowerTopology GeneratedCommandList read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributePowerTopologyGeneratedCommandList : public SubscribeAttribute { +public: + SubscribeAttributePowerTopologyGeneratedCommandList() + : SubscribeAttribute("generated-command-list") + { + } + + ~SubscribeAttributePowerTopologyGeneratedCommandList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::PowerTopology::Attributes::GeneratedCommandList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeGeneratedCommandListWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.GeneratedCommandList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute AcceptedCommandList + */ +class ReadPowerTopologyAcceptedCommandList : public ReadAttribute { +public: + ReadPowerTopologyAcceptedCommandList() + : ReadAttribute("accepted-command-list") + { + } + + ~ReadPowerTopologyAcceptedCommandList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::PowerTopology::Attributes::AcceptedCommandList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.AcceptedCommandList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("PowerTopology AcceptedCommandList read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributePowerTopologyAcceptedCommandList : public SubscribeAttribute { +public: + SubscribeAttributePowerTopologyAcceptedCommandList() + : SubscribeAttribute("accepted-command-list") + { + } + + ~SubscribeAttributePowerTopologyAcceptedCommandList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::PowerTopology::Attributes::AcceptedCommandList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeAcceptedCommandListWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.AcceptedCommandList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute EventList + */ +class ReadPowerTopologyEventList : public ReadAttribute { +public: + ReadPowerTopologyEventList() + : ReadAttribute("event-list") + { + } + + ~ReadPowerTopologyEventList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::PowerTopology::Attributes::EventList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeEventListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.EventList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("PowerTopology EventList read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributePowerTopologyEventList : public SubscribeAttribute { +public: + SubscribeAttributePowerTopologyEventList() + : SubscribeAttribute("event-list") + { + } + + ~SubscribeAttributePowerTopologyEventList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::PowerTopology::Attributes::EventList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeEventListWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.EventList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute AttributeList + */ +class ReadPowerTopologyAttributeList : public ReadAttribute { +public: + ReadPowerTopologyAttributeList() + : ReadAttribute("attribute-list") + { + } + + ~ReadPowerTopologyAttributeList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::PowerTopology::Attributes::AttributeList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.AttributeList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("PowerTopology AttributeList read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributePowerTopologyAttributeList : public SubscribeAttribute { +public: + SubscribeAttributePowerTopologyAttributeList() + : SubscribeAttribute("attribute-list") + { + } + + ~SubscribeAttributePowerTopologyAttributeList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::PowerTopology::Attributes::AttributeList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeAttributeListWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.AttributeList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute FeatureMap + */ +class ReadPowerTopologyFeatureMap : public ReadAttribute { +public: + ReadPowerTopologyFeatureMap() + : ReadAttribute("feature-map") + { + } + + ~ReadPowerTopologyFeatureMap() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::PowerTopology::Attributes::FeatureMap::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.FeatureMap response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("PowerTopology FeatureMap read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributePowerTopologyFeatureMap : public SubscribeAttribute { +public: + SubscribeAttributePowerTopologyFeatureMap() + : SubscribeAttribute("feature-map") + { + } + + ~SubscribeAttributePowerTopologyFeatureMap() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::PowerTopology::Attributes::FeatureMap::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeFeatureMapWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.FeatureMap response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute ClusterRevision + */ +class ReadPowerTopologyClusterRevision : public ReadAttribute { +public: + ReadPowerTopologyClusterRevision() + : ReadAttribute("cluster-revision") + { + } + + ~ReadPowerTopologyClusterRevision() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::PowerTopology::Attributes::ClusterRevision::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.ClusterRevision response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("PowerTopology ClusterRevision read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributePowerTopologyClusterRevision : public SubscribeAttribute { +public: + SubscribeAttributePowerTopologyClusterRevision() + : SubscribeAttribute("cluster-revision") + { + } + + ~SubscribeAttributePowerTopologyClusterRevision() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::PowerTopology::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::PowerTopology::Attributes::ClusterRevision::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterPowerTopology alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeClusterRevisionWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"PowerTopology.ClusterRevision response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + #endif // MTR_ENABLE_PROVISIONAL #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL @@ -180990,6 +184013,9 @@ void registerClusterGeneralDiagnostics(Commands & commands) make_unique(), // #if MTR_ENABLE_PROVISIONAL make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // #endif // MTR_ENABLE_PROVISIONAL make_unique(Id), // make_unique(Id), // @@ -183422,6 +186448,125 @@ void registerClusterValveConfigurationAndControl(Commands & commands) commands.RegisterCluster(clusterName, clusterCommands); #endif // MTR_ENABLE_PROVISIONAL } +void registerClusterElectricalPowerMeasurement(Commands & commands) +{ +#if MTR_ENABLE_PROVISIONAL + using namespace chip::app::Clusters::ElectricalPowerMeasurement; + + const char * clusterName = "ElectricalPowerMeasurement"; + + commands_list clusterCommands = { + make_unique(Id), // + make_unique(Id), // + make_unique(Id), // + make_unique(Id), // +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL + make_unique(Id), // + make_unique(Id), // + }; + + commands.RegisterCluster(clusterName, clusterCommands); +#endif // MTR_ENABLE_PROVISIONAL +} void registerClusterElectricalEnergyMeasurement(Commands & commands) { #if MTR_ENABLE_PROVISIONAL @@ -183454,6 +186599,10 @@ void registerClusterElectricalEnergyMeasurement(Commands & commands) make_unique(), // make_unique(), // #endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL make_unique(), // make_unique(), // @@ -183955,6 +187104,55 @@ void registerClusterEnergyPreference(Commands & commands) commands.RegisterCluster(clusterName, clusterCommands); #endif // MTR_ENABLE_PROVISIONAL } +void registerClusterPowerTopology(Commands & commands) +{ +#if MTR_ENABLE_PROVISIONAL + using namespace chip::app::Clusters::PowerTopology; + + const char * clusterName = "PowerTopology"; + + commands_list clusterCommands = { + make_unique(Id), // + make_unique(Id), // + make_unique(Id), // + make_unique(Id), // +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL + }; + + commands.RegisterCluster(clusterName, clusterCommands); +#endif // MTR_ENABLE_PROVISIONAL +} void registerClusterEnergyEvseMode(Commands & commands) { #if MTR_ENABLE_PROVISIONAL @@ -187537,12 +190735,14 @@ void registerClusters(Commands & commands) registerClusterActivatedCarbonFilterMonitoring(commands); registerClusterBooleanStateConfiguration(commands); registerClusterValveConfigurationAndControl(commands); + registerClusterElectricalPowerMeasurement(commands); registerClusterElectricalEnergyMeasurement(commands); registerClusterDemandResponseLoadControl(commands); registerClusterMessages(commands); registerClusterDeviceEnergyManagement(commands); registerClusterEnergyEvse(commands); registerClusterEnergyPreference(commands); + registerClusterPowerTopology(commands); registerClusterEnergyEvseMode(commands); registerClusterDeviceEnergyManagementMode(commands); registerClusterDoorLock(commands); diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h deleted file mode 100644 index c801864f724f3b..00000000000000 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ /dev/null @@ -1,193554 +0,0 @@ -/* - * - * 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. - */ - -// THIS FILE IS GENERATED BY ZAP - -#pragma once - -#if CONFIG_ENABLE_YAML_TESTS - -#include -#include -#include -#include - -#include // For INFINITY - -typedef void (^ResponseHandler)(id _Nullable value, NSError * _Nullable error); - -class TestList : public Command { -public: - TestList() - : Command("list") {}; - CHIP_ERROR Run() override - { - printf("TestAccessControlCluster\n"); - printf("Test_TC_ACL_1_1\n"); - printf("Test_TC_ACL_2_1\n"); - printf("Test_TC_ACL_2_3\n"); - printf("Test_TC_ACE_1_1\n"); - printf("Test_TC_ACE_1_5\n"); - printf("Test_TC_AIRQUAL_1_1\n"); - printf("Test_TC_AIRQUAL_2_1\n"); - printf("Test_TC_BOOL_1_1\n"); - printf("Test_TC_BOOL_2_1\n"); - printf("Test_TC_BRBINFO_1_1\n"); - printf("Test_TC_ACT_1_1\n"); - printf("Test_TC_BIND_1_1\n"); - printf("Test_TC_CC_1_1\n"); - printf("Test_TC_CC_2_1\n"); - printf("Test_TC_CC_3_2\n"); - printf("Test_TC_CC_3_3\n"); - printf("Test_TC_CC_4_1\n"); - printf("Test_TC_CC_4_2\n"); - printf("Test_TC_CC_4_3\n"); - printf("Test_TC_CC_4_4\n"); - printf("Test_TC_CC_5_1\n"); - printf("Test_TC_CC_5_2\n"); - printf("Test_TC_CC_5_3\n"); - printf("Test_TC_CC_6_1\n"); - printf("Test_TC_CC_6_5\n"); - printf("Test_TC_CC_7_3\n"); - printf("Test_TC_CC_7_4\n"); - printf("TestColorControl_9_1\n"); - printf("TestColorControl_9_2\n"); - printf("Test_TC_CDOCONC_1_1\n"); - printf("Test_TC_CDOCONC_2_1\n"); - printf("Test_TC_CMOCONC_1_1\n"); - printf("Test_TC_CMOCONC_2_1\n"); - printf("Test_TC_FLDCONC_1_1\n"); - printf("Test_TC_FLDCONC_2_1\n"); - printf("Test_TC_NDOCONC_1_1\n"); - printf("Test_TC_NDOCONC_2_1\n"); - printf("Test_TC_OZCONC_1_1\n"); - printf("Test_TC_OZCONC_2_1\n"); - printf("Test_TC_PMHCONC_1_1\n"); - printf("Test_TC_PMHCONC_2_1\n"); - printf("Test_TC_PMICONC_1_1\n"); - printf("Test_TC_PMICONC_2_1\n"); - printf("Test_TC_PMKCONC_1_1\n"); - printf("Test_TC_PMKCONC_2_1\n"); - printf("Test_TC_RNCONC_1_1\n"); - printf("Test_TC_RNCONC_2_1\n"); - printf("Test_TC_TVOCCONC_1_1\n"); - printf("Test_TC_TVOCCONC_2_1\n"); - printf("Test_TC_OPCREDS_1_2\n"); - printf("Test_TC_BINFO_1_1\n"); - printf("Test_TC_CNET_1_3\n"); - printf("Test_TC_DESC_1_1\n"); - printf("Test_TC_DLOG_1_1\n"); - printf("Test_TC_DGETH_1_1\n"); - printf("Test_TC_DGETH_2_1\n"); - printf("Test_TC_DGETH_2_2\n"); - printf("Test_TC_FLW_1_1\n"); - printf("Test_TC_FLABEL_1_1\n"); - printf("Test_TC_FAN_1_1\n"); - printf("Test_TC_FAN_2_1\n"); - printf("Test_TC_FAN_2_2\n"); - printf("Test_TC_FAN_2_3\n"); - printf("Test_TC_FAN_2_4\n"); - printf("Test_TC_FAN_3_6\n"); - printf("Test_TC_CGEN_1_1\n"); - printf("Test_TC_CGEN_2_1\n"); - printf("Test_TC_DGGEN_1_1\n"); - printf("Test_TC_GRPKEY_1_1\n"); - printf("Test_TC_GRPKEY_2_2\n"); - printf("Test_TC_ICDM_1_1\n"); - printf("Test_TC_I_1_1\n"); - printf("Test_TC_I_2_1\n"); - printf("Test_TC_I_2_2\n"); - printf("Test_TC_I_2_3\n"); - printf("Test_TC_ILL_1_1\n"); - printf("Test_TC_ILL_2_1\n"); - printf("Test_TC_ILL_2_2\n"); - printf("Test_TC_LVL_1_1\n"); - printf("Test_TC_LVL_2_1\n"); - printf("Test_TC_LVL_2_2\n"); - printf("Test_TC_LVL_3_1\n"); - printf("Test_TC_LVL_4_1\n"); - printf("Test_TC_LVL_5_1\n"); - printf("Test_TC_LVL_6_1\n"); - printf("Test_TC_LVL_7_1\n"); - printf("Test_TC_LCFG_1_1\n"); - printf("Test_TC_LUNIT_1_2\n"); - printf("Test_TC_LUNIT_3_1\n"); - printf("Test_TC_LTIME_1_2\n"); - printf("Test_TC_LTIME_3_1\n"); - printf("Test_TC_LWM_1_1\n"); - printf("Test_TC_LWM_2_1\n"); - printf("Test_TC_WASHERCTRL_1_1\n"); - printf("Test_TC_WASHERCTRL_2_1\n"); - printf("Test_TC_WASHERCTRL_2_2\n"); - printf("Test_TC_OTCCM_1_1\n"); - printf("Test_TC_DRYERCTRL_1_1\n"); - printf("Test_TC_DRYERCTRL_2_1\n"); - printf("Test_TC_LOWPOWER_1_1\n"); - printf("Test_TC_KEYPADINPUT_1_2\n"); - printf("Test_TC_APPLAUNCHER_1_3\n"); - printf("Test_TC_MEDIAINPUT_1_4\n"); - printf("Test_TC_WAKEONLAN_1_5\n"); - printf("Test_TC_CHANNEL_1_6\n"); - printf("Test_TC_MEDIAPLAYBACK_1_7\n"); - printf("Test_TC_AUDIOOUTPUT_1_8\n"); - printf("Test_TC_TGTNAV_1_9\n"); - printf("Test_TC_APBSC_1_10\n"); - printf("Test_TC_CONTENTLAUNCHER_1_11\n"); - printf("Test_TC_ALOGIN_1_12\n"); - printf("Test_TC_LOWPOWER_2_1\n"); - printf("Test_TC_KEYPADINPUT_3_2\n"); - printf("Test_TC_KEYPADINPUT_3_3\n"); - printf("Test_TC_APPLAUNCHER_3_5\n"); - printf("Test_TC_APPLAUNCHER_3_6\n"); - printf("Test_TC_MEDIAINPUT_3_10\n"); - printf("Test_TC_MEDIAINPUT_3_11\n"); - printf("Test_TC_MEDIAINPUT_3_12\n"); - printf("Test_TC_MEDIAINPUT_3_13\n"); - printf("Test_TC_CHANNEL_5_1\n"); - printf("Test_TC_CHANNEL_5_2\n"); - printf("Test_TC_CHANNEL_5_3\n"); - printf("Test_TC_MEDIAPLAYBACK_6_1\n"); - printf("Test_TC_MEDIAPLAYBACK_6_2\n"); - printf("Test_TC_MEDIAPLAYBACK_6_3\n"); - printf("Test_TC_MEDIAPLAYBACK_6_4\n"); - printf("Test_TC_AUDIOOUTPUT_7_1\n"); - printf("Test_TC_AUDIOOUTPUT_7_2\n"); - printf("Test_TC_TGTNAV_8_1\n"); - printf("Test_TC_APBSC_9_1\n"); - printf("Test_TC_CONTENTLAUNCHER_10_1\n"); - printf("Test_TC_WAKEONLAN_4_1\n"); - printf("Test_TC_ALOGIN_12_1\n"); - printf("Test_TC_CONTENTLAUNCHER_10_3\n"); - printf("Test_TC_CONTENTLAUNCHER_10_5\n"); - printf("Test_TC_CONTENTLAUNCHER_10_7\n"); - printf("Test_TC_MOD_1_1\n"); - printf("OTA_SuccessfulTransfer\n"); - printf("Test_TC_OCC_1_1\n"); - printf("Test_TC_OCC_2_1\n"); - printf("Test_TC_OCC_2_3\n"); - printf("Test_TC_OO_1_1\n"); - printf("Test_TC_OO_2_1\n"); - printf("Test_TC_OO_2_2\n"); - printf("Test_TC_OO_2_4\n"); - printf("Test_TC_OPSTATE_1_1\n"); - printf("Test_TC_PS_1_1\n"); - printf("Test_TC_PS_2_1\n"); - printf("Test_TC_PRS_1_1\n"); - printf("Test_TC_PRS_2_1\n"); - printf("Test_TC_PRS_2_2\n"); - printf("Test_TC_PCC_1_1\n"); - printf("Test_TC_PCC_2_1\n"); - printf("Test_TC_PCC_2_2\n"); - printf("Test_TC_PCC_2_3\n"); - printf("Test_TC_PCC_2_4\n"); - printf("Test_TC_REFALM_1_1\n"); - printf("Test_TC_REFALM_2_1\n"); - printf("Test_TC_RH_1_1\n"); - printf("Test_TC_RVCCLEANM_1_1\n"); - printf("Test_TC_RVCRUNM_1_1\n"); - printf("Test_TC_RVCOPSTATE_1_1\n"); - printf("Test_TC_SMOKECO_1_1\n"); - printf("Test_TC_SMOKECO_2_1\n"); - printf("Test_TC_SWTCH_1_1\n"); - printf("Test_TC_TCCM_1_1\n"); - printf("Test_TC_TCTL_1_1\n"); - printf("Test_TC_TCTL_2_2\n"); - printf("Test_TC_TCTL_2_3\n"); - printf("Test_TC_TCTL_3_2\n"); - printf("Test_TC_TCTL_3_3\n"); - printf("Test_TC_TMP_1_1\n"); - printf("Test_TC_TMP_2_1\n"); - printf("Test_TC_TSTAT_1_1\n"); - printf("Test_TC_TSUIC_1_1\n"); - printf("Test_TC_TSUIC_2_1\n"); - printf("Test_TC_TSUIC_2_2\n"); - printf("Test_TC_DGTHREAD_1_1\n"); - printf("Test_TC_TIMESYNC_1_1\n"); - printf("Test_TC_TIMESYNC_2_3\n"); - printf("Test_TC_ULABEL_1_1\n"); - printf("Test_TC_ULABEL_2_1\n"); - printf("Test_TC_ULABEL_2_2\n"); - printf("Test_TC_ULABEL_2_3\n"); - printf("Test_TC_ULABEL_2_4\n"); - printf("Test_TC_DGWIFI_1_1\n"); - printf("Test_TC_DGWIFI_2_1\n"); - printf("Test_TC_DGWIFI_2_3\n"); - printf("Test_TC_WNCV_1_1\n"); - printf("Test_TC_WNCV_2_1\n"); - printf("Test_TC_WNCV_2_2\n"); - printf("Test_TC_WNCV_2_3\n"); - printf("Test_TC_WNCV_2_5\n"); - printf("Test_TC_WNCV_3_1\n"); - printf("Test_TC_WNCV_3_2\n"); - printf("Test_TC_WNCV_3_3\n"); - printf("Test_TC_WNCV_3_4\n"); - printf("Test_TC_WNCV_3_5\n"); - printf("Test_TC_WNCV_4_1\n"); - printf("Test_TC_WNCV_4_2\n"); - printf("Test_TC_WNCV_4_3\n"); - printf("Test_TC_WNCV_4_4\n"); - printf("Test_TC_WNCV_4_5\n"); - printf("TV_TargetNavigatorCluster\n"); - printf("TV_AudioOutputCluster\n"); - printf("TV_ApplicationLauncherCluster\n"); - printf("TV_KeypadInputCluster\n"); - printf("TV_AccountLoginCluster\n"); - printf("TV_WakeOnLanCluster\n"); - printf("TV_ApplicationBasicCluster\n"); - printf("TV_MediaPlaybackCluster\n"); - printf("TV_ChannelCluster\n"); - printf("TV_LowPowerCluster\n"); - printf("TV_ContentLauncherCluster\n"); - printf("TV_MediaInputCluster\n"); - printf("TestCASERecovery\n"); - printf("TestCluster\n"); - printf("TestConstraints\n"); - printf("TestDelayCommands\n"); - printf("TestLogCommands\n"); - printf("TestSaveAs\n"); - printf("TestConfigVariables\n"); - printf("TestDescriptorCluster\n"); - printf("TestFabricRemovalWhileSubscribed\n"); - printf("TestGeneralCommissioning\n"); - printf("TestIdentifyCluster\n"); - printf("TestOperationalCredentialsCluster\n"); - printf("TestModeSelectCluster\n"); - printf("TestTemperatureControl\n"); - printf("TestSelfFabricRemoval\n"); - printf("TestSystemCommands\n"); - printf("TestBinding\n"); - printf("TestUserLabelCluster\n"); - printf("TestUserLabelClusterConstraints\n"); - printf("TestArmFailSafe\n"); - printf("TestFanControl\n"); - printf("TestAccessControlConstraints\n"); - printf("TestLevelControlWithOnOffDependency\n"); - printf("TestCommissioningWindow\n"); - printf("TestCommissionerNodeId\n"); - printf("TestTimeSynchronization\n"); - printf("TestOperationalState\n"); - printf("TestRVCOperationalState\n"); - printf("TestDishwasherAlarm\n"); - printf("TestMultiAdmin\n"); - printf("Test_TC_DGSW_1_1\n"); - printf("TestSubscribe_OnOff\n"); - printf("TestSubscribe_AdministratorCommissioning\n"); - printf("DL_UsersAndCredentials\n"); - printf("DL_Schedules\n"); - printf("Test_TC_DRLK_1_1\n"); - printf("Test_TC_DRLK_2_4\n"); - printf("Test_TC_DRLK_2_5\n"); - printf("Test_TC_DRLK_2_6\n"); - printf("Test_TC_DRLK_2_7\n"); - printf("Test_TC_DRLK_2_8\n"); - printf("Test_TC_DRLK_2_11\n"); - printf("TestGroupsCluster\n"); - printf("Test_TC_G_1_1\n"); - printf("TestScenesFabricRemoval\n"); - printf("Test_TC_S_1_1\n"); - printf("Test_TC_S_2_1\n"); - printf("Test_TC_S_2_4\n"); - printf("TestActivatedCarbonFilterMonitoring\n"); - printf("TestHepaFilterMonitoring\n"); - printf("Test_TC_ACFREMON_1_1\n"); - printf("Test_TC_ACFREMON_2_1\n"); - printf("Test_TC_HEPAFREMON_1_1\n"); - printf("Test_TC_HEPAFREMON_2_1\n"); - - return CHIP_NO_ERROR; - } -}; - -class ManualTestList : public Command { -public: - ManualTestList() - : Command("list-manual") {}; - CHIP_ERROR Run() override - { - - return CHIP_NO_ERROR; - } -}; - -class TestAccessControlCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestAccessControlCluster() - : TestCommandBridge("TestAccessControlCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestAccessControlCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestAccessControlCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestAccessControlCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for commissionee\n"); - err = TestWaitForCommissionee_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write entries\n"); - err = TestWriteEntries_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify\n"); - err = TestVerify_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Write entries empty lists\n"); - err = TestWriteEntriesEmptyLists_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify\n"); - err = TestVerify_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Write entry invalid privilege\n"); - err = TestWriteEntryInvalidPrivilege_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Verify\n"); - err = TestVerify_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write entry invalid auth mode\n"); - err = TestWriteEntryInvalidAuthMode_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify\n"); - err = TestVerify_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Write entry invalid subject\n"); - err = TestWriteEntryInvalidSubject_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Verify\n"); - err = TestVerify_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Write entry invalid target\n"); - err = TestWriteEntryInvalidTarget_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Verify\n"); - err = TestVerify_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Write entry too many subjects\n"); - err = TestWriteEntryTooManySubjects_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Verify\n"); - err = TestVerify_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Write entry too many targets\n"); - err = TestWriteEntryTooManyTargets_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Verify\n"); - err = TestVerify_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Write too many entries\n"); - err = TestWriteTooManyEntries_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Verify\n"); - err = TestVerify_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Restore ACL\n"); - err = TestRestoreAcl_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Verify\n"); - err = TestVerify_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Validate resource minima (SubjectsPerAccessControlEntry)\n"); - err = TestValidateResourceMinimaSubjectsPerAccessControlEntry_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Validate resource minima (TargetsPerAccessControlEntry)\n"); - err = TestValidateResourceMinimaTargetsPerAccessControlEntry_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Validate resource minima (AccessControlEntriesPerFabric)\n"); - err = TestValidateResourceMinimaAccessControlEntriesPerFabric_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForCommissionee_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteEntries_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:1UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:2UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:4ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:5ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:6ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:7ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:8U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:9UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:10UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:11U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[2] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).authMode = - [NSNumber numberWithUnsignedChar:3U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:12ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:13ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:14ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:15ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:16U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:17UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:18UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:19U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[3] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:20ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:21ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:22ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:23ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:24U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:25UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:26UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:27U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entries: Error: %@", err); - } else { - NSLog(@"Write entries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint, 0U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster, 1UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster, 2UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint, 3U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).privilege, 1U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[0], 4ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[1], 5ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[2], 6ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[3], 7ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint, 8U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster, 9UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster, 10UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint, 11U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).privilege, 3U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).authMode, 3U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[0], 12ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[1], 13ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[2], 14ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[3], 15ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint, 16U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster, 17UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster, 18UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint, 19U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).privilege, 3U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[0], 20ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[1], 21ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[2], 22ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[3], 23ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint, 24U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster, 25UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster, 26UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint, 27U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntriesEmptyLists_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entries empty lists: Error: %@", err); - } else { - NSLog(@"Write entries empty lists: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).privilege, 1U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryInvalidPrivilege_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry invalid privilege: Error: %@", err); - } else { - NSLog(@"Write entry invalid privilege: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryInvalidAuthMode_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry invalid auth mode: Error: %@", err); - } else { - NSLog(@"Write entry invalid auth mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryInvalidSubject_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry invalid subject: Error: %@", err); - } else { - NSLog(@"Write entry invalid subject: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryInvalidTarget_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry invalid target: Error: %@", err); - } else { - NSLog(@"Write entry invalid target: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryTooManySubjects_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:1ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:2ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:3ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:4ULL]; - temp_3[4] = - [NSNumber numberWithUnsignedLongLong:5ULL]; - temp_3[5] = - [NSNumber numberWithUnsignedLongLong:6ULL]; - temp_3[6] = - [NSNumber numberWithUnsignedLongLong:7ULL]; - temp_3[7] = - [NSNumber numberWithUnsignedLongLong:8ULL]; - temp_3[8] = - [NSNumber numberWithUnsignedLongLong:9ULL]; - temp_3[9] = - [NSNumber numberWithUnsignedLongLong:10ULL]; - temp_3[10] = - [NSNumber numberWithUnsignedLongLong:11ULL]; - temp_3[11] = - [NSNumber numberWithUnsignedLongLong:12ULL]; - temp_3[12] = - [NSNumber numberWithUnsignedLongLong:13ULL]; - temp_3[13] = - [NSNumber numberWithUnsignedLongLong:14ULL]; - temp_3[14] = - [NSNumber numberWithUnsignedLongLong:15ULL]; - temp_3[15] = - [NSNumber numberWithUnsignedLongLong:16ULL]; - temp_3[16] = - [NSNumber numberWithUnsignedLongLong:17ULL]; - temp_3[17] = - [NSNumber numberWithUnsignedLongLong:18ULL]; - temp_3[18] = - [NSNumber numberWithUnsignedLongLong:19ULL]; - temp_3[19] = - [NSNumber numberWithUnsignedLongLong:20ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry too many subjects: Error: %@", err); - } else { - NSLog(@"Write entry too many subjects: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryTooManyTargets_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = - [NSNumber numberWithUnsignedShort:2U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - temp_3[3] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[3]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[3]).endpoint = - [NSNumber numberWithUnsignedShort:4U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[3]).deviceType = nil; - - temp_3[4] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[4]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[4]).endpoint = - [NSNumber numberWithUnsignedShort:5U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[4]).deviceType = nil; - - temp_3[5] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[5]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[5]).endpoint = - [NSNumber numberWithUnsignedShort:6U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[5]).deviceType = nil; - - temp_3[6] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[6]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[6]).endpoint = - [NSNumber numberWithUnsignedShort:7U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[6]).deviceType = nil; - - temp_3[7] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[7]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[7]).endpoint = - [NSNumber numberWithUnsignedShort:8U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[7]).deviceType = nil; - - temp_3[8] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[8]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[8]).endpoint = - [NSNumber numberWithUnsignedShort:9U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[8]).deviceType = nil; - - temp_3[9] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[9]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[9]).endpoint = - [NSNumber numberWithUnsignedShort:10U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[9]).deviceType = nil; - - temp_3[10] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[10]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[10]).endpoint = - [NSNumber numberWithUnsignedShort:11U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[10]).deviceType = nil; - - temp_3[11] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[11]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[11]).endpoint = - [NSNumber numberWithUnsignedShort:12U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[11]).deviceType = nil; - - temp_3[12] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[12]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[12]).endpoint = - [NSNumber numberWithUnsignedShort:13U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[12]).deviceType = nil; - - temp_3[13] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[13]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[13]).endpoint = - [NSNumber numberWithUnsignedShort:14U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[13]).deviceType = nil; - - temp_3[14] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[14]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[14]).endpoint = - [NSNumber numberWithUnsignedShort:15U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[14]).deviceType = nil; - - temp_3[15] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[15]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[15]).endpoint = - [NSNumber numberWithUnsignedShort:16U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[15]).deviceType = nil; - - temp_3[16] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[16]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[16]).endpoint = - [NSNumber numberWithUnsignedShort:17U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[16]).deviceType = nil; - - temp_3[17] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[17]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[17]).endpoint = - [NSNumber numberWithUnsignedShort:18U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[17]).deviceType = nil; - - temp_3[18] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[18]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[18]).endpoint = - [NSNumber numberWithUnsignedShort:19U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[18]).deviceType = nil; - - temp_3[19] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[19]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[19]).endpoint = - [NSNumber numberWithUnsignedShort:20U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[19]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry too many targets: Error: %@", err); - } else { - NSLog(@"Write entry too many targets: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTooManyEntries_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:1UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:2UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:4ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:5ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:6ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:7ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:8U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:9UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:10UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:11U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[2] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).authMode = - [NSNumber numberWithUnsignedChar:3U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:12ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:13ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:14ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:15ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:16U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:17UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:18UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:19U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[3] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:20ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:21ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:22ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:23ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:24U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:25UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:26UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:27U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[4] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:28ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:29ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:30ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:31ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:32U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:33UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:34UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:35U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write too many entries: Error: %@", err); - } else { - NSLog(@"Write too many entries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint, 0U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster, 1UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster, 2UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint, 3U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).privilege, 1U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[0], 4ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[1], 5ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[2], 6ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[3], 7ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint, 8U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster, 9UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster, 10UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint, 11U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).privilege, 3U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).authMode, 3U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[0], 12ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[1], 13ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[2], 14ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[3], 15ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint, 16U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster, 17UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster, 18UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint, 19U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).privilege, 1U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[0], 20ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[1], 21ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[2], 22ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[3], 23ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint, 24U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster, 25UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster, 26UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint, 27U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRestoreAcl_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Restore ACL: Error: %@", err); - } else { - NSLog(@"Restore ACL: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidateResourceMinimaSubjectsPerAccessControlEntry_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSubjectsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate resource minima (SubjectsPerAccessControlEntry): Error: %@", err); - } else { - NSLog(@"Validate resource minima (SubjectsPerAccessControlEntry): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("subjectsPerAccessControlEntry", [value unsignedShortValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidateResourceMinimaTargetsPerAccessControlEntry_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate resource minima (TargetsPerAccessControlEntry): Error: %@", err); - } else { - NSLog(@"Validate resource minima (TargetsPerAccessControlEntry): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("targetsPerAccessControlEntry", [value unsignedShortValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidateResourceMinimaAccessControlEntriesPerFabric_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAccessControlEntriesPerFabricWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate resource minima (AccessControlEntriesPerFabric): Error: %@", err); - } else { - NSLog(@"Validate resource minima (AccessControlEntriesPerFabric): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("accessControlEntriesPerFabric", [value unsignedShortValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACL_1_1() - : TestCommandBridge("Test_TC_ACL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads ClusterRevision attribute from DUT\n"); - err = TestStep2ThReadsClusterRevisionAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FeatureMap attribute from DUT\n"); - err = TestStep3ThReadsFeatureMapAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads AttributeList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList attribute from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute (Extension) in AttributeList\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeExtensionInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads AcceptedCommandList attribute from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsClusterRevisionAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeExtensionInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute (Extension) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute (Extension) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACL_2_1() - : TestCommandBridge("Test_TC_ACL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TH1 commissions DUT using admin node ID N1\n"); - err = TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH1 reads DUT Endpoint 0 AccessControl cluster SubjectsPerAccessControlEntry attribute\n"); - if (ShouldSkip("ACL.S.A0002")) { - NextTest(); - return; - } - err = TestStep2Th1ReadsDutEndpoint0AccessControlClusterSubjectsPerAccessControlEntryAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster TargetsPerAccessControlEntry attribute\n"); - if (ShouldSkip("ACL.S.A0003")) { - NextTest(); - return; - } - err = TestStep3Th1ReadsDutEndpoint0AccessControlClusterTargetsPerAccessControlEntryAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH1 reads DUT Endpoint 0 AccessControl cluster AccessControlEntriesPerFabric attribute\n"); - if (ShouldSkip("ACL.S.A0004")) { - NextTest(); - return; - } - err = TestStep4Th1ReadsDutEndpoint0AccessControlClusterAccessControlEntriesPerFabricAttribute_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2Th1ReadsDutEndpoint0AccessControlClusterSubjectsPerAccessControlEntryAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSubjectsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH1 reads DUT Endpoint 0 AccessControl cluster SubjectsPerAccessControlEntry attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH1 reads DUT Endpoint 0 AccessControl cluster SubjectsPerAccessControlEntry attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("subjectsPerAccessControlEntry", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("subjectsPerAccessControlEntry", [value unsignedShortValue], 4U)); - VerifyOrReturn(CheckConstraintMaxValue("subjectsPerAccessControlEntry", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3Th1ReadsDutEndpoint0AccessControlClusterTargetsPerAccessControlEntryAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster TargetsPerAccessControlEntry attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster TargetsPerAccessControlEntry attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("targetsPerAccessControlEntry", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("targetsPerAccessControlEntry", [value unsignedShortValue], 3U)); - VerifyOrReturn(CheckConstraintMaxValue("targetsPerAccessControlEntry", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4Th1ReadsDutEndpoint0AccessControlClusterAccessControlEntriesPerFabricAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAccessControlEntriesPerFabricWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH1 reads DUT Endpoint 0 AccessControl cluster AccessControlEntriesPerFabric attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH1 reads DUT Endpoint 0 AccessControl cluster AccessControlEntriesPerFabric attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("accessControlEntriesPerFabric", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("accessControlEntriesPerFabric", [value unsignedShortValue], 4U)); - VerifyOrReturn(CheckConstraintMaxValue("accessControlEntriesPerFabric", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACL_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACL_2_3() - : TestCommandBridge("Test_TC_ACL_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("D_OK_EMPTY", &mDOkEmpty); - AddArgument("D_OK_SINGLE", &mDOkSingle); - AddArgument("D_OK_FULL", &mDOkFull); - AddArgument("D_BAD_LENGTH", &mDBadLength); - AddArgument("D_BAD_STRUCT", &mDBadStruct); - AddArgument("D_BAD_LIST", &mDBadList); - AddArgument("D_BAD_ELEM", &mDBadElem); - AddArgument("D_BAD_OVERFLOW", &mDBadOverflow); - AddArgument("D_BAD_UNDERFLOW", &mDBadUnderflow); - AddArgument("D_BAD_NONE", &mDBadNone); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACL_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACL_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACL_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TH1 commissions DUT using admin node ID N1\n"); - err = TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH1 reads DUT Endpoint 0 OperationalCredentials cluster CurrentFabricIndex attribute\n"); - err = TestStep2Th1ReadsDutEndpoint0OperationalCredentialsClusterCurrentFabricIndexAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct: Data field: D_OK_EMPTY : 1718\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep4Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDOkEmpty1718_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep5Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_SINGLE :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep6Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep7Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_FULL :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003148656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E0018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep8Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkFull17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003148656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e0018_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep9Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_LENGTH :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003248656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E2E0018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep10Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadLength17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003248656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e2e0018_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_STRUCT : 1518\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep11Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadStruct1518_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_LIST :3701D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep12Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadList3701d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_ELEM :17103D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep13Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadElem17103d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_OVERFLOW : 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018FF\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep14Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadOverflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018ff_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_UNDERFLOW :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep15Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadUnderflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_BAD_NONE\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep16Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadNone_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 2 elements . value is list of AccessControlExtensionStruct containing 2 elements . first element contains Data field: D_OK_EMPTY 1718 . second element contains Data field: D_OK_SINGLE 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep17Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining2ElementsValueIsListOfAccessControlExtensionStructContaining2ElementsFirstElementContainsDataFieldDOkEmpty1718SecondElementContainsDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep18Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 19: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is an empty list\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep19Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsAnEmptyList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 20: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep20Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mDOkEmpty; - chip::Optional mDOkSingle; - chip::Optional mDOkFull; - chip::Optional mDBadLength; - chip::Optional mDBadStruct; - chip::Optional mDBadList; - chip::Optional mDBadElem; - chip::Optional mDBadOverflow; - chip::Optional mDBadUnderflow; - chip::Optional mDBadNone; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull CurrentFabricIndexValue; - - CHIP_ERROR TestStep2Th1ReadsDutEndpoint0OperationalCredentialsClusterCurrentFabricIndexAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH1 reads DUT Endpoint 0 OperationalCredentials cluster CurrentFabricIndex attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH1 reads DUT Endpoint 0 OperationalCredentials cluster CurrentFabricIndex attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - CurrentFabricIndexValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDOkEmpty1718_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct: Data field: D_OK_EMPTY : 1718: Error: %@", err); - } else { - NSLog(@"Step 4: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct: Data field: D_OK_EMPTY : 1718: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2] - - )); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkSingle.HasValue() ? [NSData dataWithBytes:mDOkSingle.Value().data() length:mDOkSingle.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:71]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_SINGLE :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); - } else { - NSLog(@"Step 6: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_SINGLE :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkSingle.HasValue() ? [NSData dataWithBytes:mDOkSingle.Value().data() length:mDOkSingle.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:71] - - )); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkFull17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003148656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e0018_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkFull.HasValue() ? [NSData dataWithBytes:mDOkFull.Value().data() length:mDOkFull.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\xD0\x00\x00\xF1\xFF\x02\x00\x31\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x61\x67\x61\x69\x6E\x2E\x2E\x2E\x2E\x2E\x00\x18" length:128]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_FULL :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003148656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E0018: Error: %@", err); - } else { - NSLog(@"Step 8: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_FULL :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003148656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E0018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 9: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkFull.HasValue() ? [NSData dataWithBytes:mDOkFull.Value().data() length:mDOkFull.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\xD0\x00\x00\xF1\xFF\x02\x00\x31\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x61\x67\x61\x69\x6E\x2E\x2E\x2E\x2E\x2E\x00\x18" length:128] - - )); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadLength17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003248656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e2e0018_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadLength.HasValue() ? [NSData dataWithBytes:mDBadLength.Value().data() length:mDBadLength.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\xD0\x00\x00\xF1\xFF\x02\x00\x32\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x61\x67\x61\x69\x6E\x2E\x2E\x2E\x2E\x2E\x2E\x00\x18" length:129]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_LENGTH :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003248656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E2E0018: Error: %@", err); - } else { - NSLog(@"Step 10: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_LENGTH :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003248656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E2E0018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadStruct1518_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadStruct.HasValue() ? [NSData dataWithBytes:mDBadStruct.Value().data() length:mDBadStruct.Value().size()] : [[NSData alloc] initWithBytes:"\x15\x18" length:2]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_STRUCT : 1518: Error: %@", err); - } else { - NSLog(@"Step 11: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_STRUCT : 1518: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadList3701d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadList.HasValue() ? [NSData dataWithBytes:mDBadList.Value().data() length:mDBadList.Value().size()] : [[NSData alloc] initWithBytes:"\x37\x01\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:72]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_LIST :3701D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); - } else { - NSLog(@"Step 12: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_LIST :3701D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadElem17103d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadElem.HasValue() ? [NSData dataWithBytes:mDBadElem.Value().data() length:mDBadElem.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x10\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:65]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_ELEM :17103D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); - } else { - NSLog(@"Step 13: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_ELEM :17103D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadOverflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018ff_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadOverflow.HasValue() ? [NSData dataWithBytes:mDBadOverflow.Value().data() length:mDBadOverflow.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18\xFF" length:72]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_OVERFLOW : 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018FF: Error: %@", err); - } else { - NSLog(@"Step 14: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_OVERFLOW : 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018FF: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadUnderflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadUnderflow.HasValue() ? [NSData dataWithBytes:mDBadUnderflow.Value().data() length:mDBadUnderflow.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00" length:70]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_UNDERFLOW :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700: Error: %@", err); - } else { - NSLog(@"Step 15: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_UNDERFLOW :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadNone_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadNone.HasValue() ? [NSData dataWithBytes:mDBadNone.Value().data() length:mDBadNone.Value().size()] : [[NSData alloc] initWithBytes:"" length:0]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_BAD_NONE: Error: %@", err); - } else { - NSLog(@"Step 16: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_BAD_NONE: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining2ElementsValueIsListOfAccessControlExtensionStructContaining2ElementsFirstElementContainsDataFieldDOkEmpty1718SecondElementContainsDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[1]).data = mDOkSingle.HasValue() ? [NSData dataWithBytes:mDOkSingle.Value().data() length:mDOkSingle.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:71]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[1]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 2 elements . value is list of AccessControlExtensionStruct containing 2 elements . first element contains Data field: D_OK_EMPTY 1718 . second element contains Data field: D_OK_SINGLE 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); - } else { - NSLog(@"Step 17: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 2 elements . value is list of AccessControlExtensionStruct containing 2 elements . first element contains Data field: D_OK_EMPTY 1718 . second element contains Data field: D_OK_SINGLE 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 18: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2] - - )); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsAnEmptyList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is an empty list: Error: %@", err); - } else { - NSLog(@"Step 19: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is an empty list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 20: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACE_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACE_1_1() - : TestCommandBridge("Test_TC_ACE_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACE_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACE_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACE_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TH1 commissions DUT using admin node ID N1\n"); - err = TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read the commissioner node ID\n"); - err = TestReadTheCommissionerNodeId_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 1 elements, granting itself administer privileges on all of Endpoint 0 : struct a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: null, Endpoint: 0, DeviceType: null}]\n"); - err = TestStep2ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining1ElementsGrantingItselfAdministerPrivilegesOnAllOfEndpoint0StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterNullEndpoint0DeviceTypeNull_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-scoped read (requires administer privilege)\n"); - err = TestStep3ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricScopedReadRequiresAdministerPrivilege_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestStep4ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends the UpdateFabricLabel command to the Node Operational Credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); - err = TestStep5ThSendsTheUpdateFabricLabelCommandToTheNodeOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege)\n"); - err = TestStep6ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0 (requires manage privilege). Note that this will cause an error to be returned because the EnableKey is invalid, but still indicates that the TH passed the ACL check.\n"); - err = TestStep7ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilegeNoteThatThisWillCauseAnErrorToBeReturnedBecauseTheEnableKeyIsInvalidButStillIndicatesThatTheThPassedTheAclCheck_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege)\n"); - err = TestStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and manage privilege on everything else on EP0 : 1.Struct : a)Fabric Index:1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Manage (4) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]\n"); - err = TestStep9ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndManagePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldManage4CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 10: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege)\n"); - err = TestStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 11: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 12: TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); - err = TestStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 13a: Write NodeLabel attribute (Basic - requires manage)\n"); - err = TestStep13aWriteNodeLabelAttributeBasicRequiresManage_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 13b: Send TestEventTrigger (General Diagnostics - requires manage)\n"); - err = TestStep13bSendTestEventTriggerGeneralDiagnosticsRequiresManage_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 13c: Tead the VendorID attribute (Basic - requires view)\n"); - err = TestStep13cTeadTheVendorIDAttributeBasicRequiresView_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 14: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and operate privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Operate (3) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]\n"); - err = TestStep14ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndOperatePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldOperate3CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 15a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges step:10 p- TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege)\n"); - err = TestStep15aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesStep10PThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 15b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestStep15bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 15c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege) \n"); - err = TestStep15cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 16: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege)\n"); - err = TestStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 17: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege)\n"); - err = TestStep17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 18: Repeat step 8 to confirm that the TH still has view privileges : Step 8 - TH reads the VendorID attribute from the Basic Information cluster (requires view privilege)\n"); - err = TestStep18RepeatStep8ToConfirmThatTheThStillHasViewPrivilegesStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 19: TH1 writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and view privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]\n"); - err = TestStep19Th1WritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndViewPrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 20a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege)\n"); - err = TestStep20aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 20b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestStep20bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 20c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); - err = TestStep20cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 21a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege) \n"); - err = TestStep21aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 21b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege)\n"); - err = TestStep21bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 22: Tead the VendorID attribute (Basic - requires view)\n"); - err = TestStep22TeadTheVendorIDAttributeBasicRequiresView_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 23: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, granting Administer privilege on only the Access Control cluster and no other access : 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}]\n"); - err = TestStep23ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementGrantingAdministerPrivilegeOnOnlyTheAccessControlClusterAndNoOtherAccess1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint0_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 24a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege) \n"); - err = TestStep24aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : TStep 24b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestTStep24bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 24c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); - err = TestStep24cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 25a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege)\n"); - err = TestStep25aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 25b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege)\n"); - err = TestStep25bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 26: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege)\n"); - err = TestStep26ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 27: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, restoring full access to the node. Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null\n"); - err = TestStep27ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementRestoringFullAccessToTheNodeStructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_37(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 38; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull commissionerNodeId; - - CHIP_ERROR TestReadTheCommissionerNodeId_1() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeId = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestStep2ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining1ElementsGrantingItselfAdministerPrivilegesOnAllOfEndpoint0StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterNullEndpoint0DeviceTypeNull_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 1 elements, granting itself administer privileges on all of Endpoint 0 : struct a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: null, Endpoint: 0, DeviceType: null}]: Error: %@", err); - } else { - NSLog(@"Step 2: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 1 elements, granting itself administer privileges on all of Endpoint 0 : struct a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: null, Endpoint: 0, DeviceType: null}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricScopedReadRequiresAdministerPrivilege_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-scoped read (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-scoped read (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("NOCs", value, 1)); - VerifyOrReturn(CheckConstraintMaxLength("NOCs", value, 1)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 4: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsTheUpdateFabricLabelCommandToTheNodeOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends the UpdateFabricLabel command to the Node Operational Credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 5: TH sends the UpdateFabricLabel command to the Node Operational Credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 6: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilegeNoteThatThisWillCauseAnErrorToBeReturnedBecauseTheEnableKeyIsInvalidButStillIndicatesThatTheThPassedTheAclCheck_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0 (requires manage privilege). Note that this will cause an error to be returned because the EnableKey is invalid, but still indicates that the TH passed the ACL check.: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0 (requires manage privilege). Note that this will cause an error to be returned because the EnableKey is invalid, but still indicates that the TH passed the ACL check.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Error: %@", err); - } else { - NSLog(@"Step 8: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndManagePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldManage4CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and manage privilege on everything else on EP0 : 1.Struct : a)Fabric Index:1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Manage (4) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 9: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and manage privilege on everything else on EP0 : 1.Struct : a)Fabric Index:1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Manage (4) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 10: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 11: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 12: TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13aWriteNodeLabelAttributeBasicRequiresManage_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13a: Write NodeLabel attribute (Basic - requires manage): Error: %@", err); - } else { - NSLog(@"Step 13a: Write NodeLabel attribute (Basic - requires manage): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13bSendTestEventTriggerGeneralDiagnosticsRequiresManage_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13b: Send TestEventTrigger (General Diagnostics - requires manage): Error: %@", err); - } else { - NSLog(@"Step 13b: Send TestEventTrigger (General Diagnostics - requires manage): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13cTeadTheVendorIDAttributeBasicRequiresView_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13c: Tead the VendorID attribute (Basic - requires view): Error: %@", err); - } else { - NSLog(@"Step 13c: Tead the VendorID attribute (Basic - requires view): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndOperatePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldOperate3CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and operate privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Operate (3) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 14: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and operate privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Operate (3) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesStep10PThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges step:10 p- TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 15a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges step:10 p- TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 15b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege) : Error: %@", err); - } else { - NSLog(@"Step 15c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege) : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 16: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 17: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18RepeatStep8ToConfirmThatTheThStillHasViewPrivilegesStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: Repeat step 8 to confirm that the TH still has view privileges : Step 8 - TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Error: %@", err); - } else { - NSLog(@"Step 18: Repeat step 8 to confirm that the TH still has view privileges : Step 8 - TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19Th1WritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndViewPrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH1 writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and view privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 19: TH1 writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and view privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 20a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 20b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 20c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege) : Error: %@", err); - } else { - NSLog(@"Step 21a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege) : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 21b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep22TeadTheVendorIDAttributeBasicRequiresView_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: Tead the VendorID attribute (Basic - requires view): Error: %@", err); - } else { - NSLog(@"Step 22: Tead the VendorID attribute (Basic - requires view): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementGrantingAdministerPrivilegeOnOnlyTheAccessControlClusterAndNoOtherAccess1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint0_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 23: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, granting Administer privilege on only the Access Control cluster and no other access : 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 23: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, granting Administer privilege on only the Access Control cluster and no other access : 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege) : Error: %@", err); - } else { - NSLog(@"Step 24a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege) : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTStep24bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TStep 24b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"TStep 24b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 24c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 25a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 25a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 25b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 25b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep26ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 26: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Error: %@", err); - } else { - NSLog(@"Step 26: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep27ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementRestoringFullAccessToTheNodeStructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 27: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, restoring full access to the node. Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Error: %@", err); - } else { - NSLog(@"Step 27: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, restoring full access to the node. Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACE_1_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACE_1_5() - : TestCommandBridge("Test_TC_ACE_1_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("payload", &mPayload); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("waitAfterCommissioning", 0, UINT16_MAX, &mWaitAfterCommissioning); - AddArgument("PakeVerifier", &mPakeVerifier); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACE_1_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACE_1_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACE_1_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TH1 commissions DUT using admin node ID N1\n"); - err = TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : TH1 reads the fabric index\n"); - err = TestTh1ReadsTheFabricIndex_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2 & 3: TH1 puts DUT into commissioning mode, TH2 commissions DUT using admin node ID N2\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep23Th1PutsDutIntoCommissioningModeTh2CommissionsDutUsingAdminNodeIdN2_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH1 opens the commissioning window on the DUT\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep2Th1OpensTheCommissioningWindowOnTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Waiting after opening commissioning window\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestWaitingAfterOpeningCommissioningWindow_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH2 commissions DUT using admin node ID N2\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep3Th2CommissionsDutUsingAdminNodeIdN2_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait for the commissioned device to be retrieved for TH2\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH2 reads its fabric index from the Operational Credentials cluster CurrentFabricIndex attribute\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep4Th2ReadsItsFabricIndexFromTheOperationalCredentialsClusterCurrentFabricIndexAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH2 reads the fabric index\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4Th2ReadsTheFabricIndex_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read the commissioner node ID from the alpha fabric\n"); - err = TestReadTheCommissionerNodeIdFromTheAlphaFabric_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5: TH1 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field:[{Cluster: AccessControl (0x001f), Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: null e)Targets field: [{Cluster: Descriptor (0x001d), Endpoint: 0}]\n"); - err = TestStep5Th1WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterAccessControl0x001fEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldNullETargetsFieldClusterDescriptor0x001dEndpoint0_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read the commissioner node ID from the beta fabric\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestReadTheCommissionerNodeIdFromTheBetaFabric_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH2 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: th2FabricIndex b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N2] e)Targets field: [{Cluster: AccessControl (0x001f), Endpoint: 0}]\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep6Th2WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndexTh2FabricIndexBPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn2ETargetsFieldClusterAccessControl0x001fEndpoint0_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH2 writes ACL giving view privilge for basic cluster\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep6Th2WritesAclGivingViewPrivilgeForBasicCluster_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7: TH1 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute\n"); - err = TestStep7Th1ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 8: TH1 reads DUT Endpoint 0 Basic Information cluster VendorID attribute\n"); - err = TestStep8Th1ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 9: TH2 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep9Th2ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 9: TH2 reads descriptor cluster - expect UNSUPPORTED_ACCESS\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep9Th2ReadsDescriptorClusterExpectUnsupportedAccess_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute - expect SUCCESS\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttributeExpectSuccess_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 11: TH1 resets the ACLs to the default value bywriting DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 1 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null\n"); - err = TestStep11Th1ResetsTheACLsToTheDefaultValueBywritingDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining1Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric command to the DUT with the FabricIndex set to th2FabricIndex\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandToTheDutWithTheFabricIndexSetToTh2FabricIndex_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric commandto the DUT with the FabricIndex set to th2FabricIndex\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandtoTheDutWithTheFabricIndexSetToTh2FabricIndex_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPayload; - chip::Optional mDiscriminator; - chip::Optional mWaitAfterCommissioning; - chip::Optional mPakeVerifier; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull th1FabricIndex; - - CHIP_ERROR TestTh1ReadsTheFabricIndex_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 reads the fabric index: Error: %@", err); - } else { - NSLog(@"TH1 reads the fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th1FabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23Th1PutsDutIntoCommissioningModeTh2CommissionsDutUsingAdminNodeIdN2_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2Th1OpensTheCommissioningWindowOnTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - params.pakePasscodeVerifier = mPakeVerifier.HasValue() ? [NSData dataWithBytes:mPakeVerifier.Value().data() length:mPakeVerifier.Value().size()] : [[NSData alloc] initWithBytes:"\xb9\x61\x70\xaa\xe8\x03\x34\x68\x84\x72\x4f\xe9\xa3\xb2\x87\xc3\x03\x30\xc2\xa6\x60\x37\x5d\x17\xbb\x20\x5a\x8c\xf1\xae\xcb\x35\x04\x57\xf8\xab\x79\xee\x25\x3a\xb6\xa8\xe4\x6b\xb0\x9e\x54\x3a\xe4\x22\x73\x6d\xe5\x01\xe3\xdb\x37\xd4\x41\xfe\x34\x49\x20\xd0\x95\x48\xe4\xc1\x82\x40\x63\x0c\x4f\xf4\x91\x3c\x53\x51\x38\x39\xb7\xc0\x7f\xcc\x06\x27\xa1\xb8\x57\x3a\x14\x9f\xcd\x1f\xa4\x66\xcf" length:97]; - params.discriminator = mDiscriminator.HasValue() ? [NSNumber numberWithUnsignedShort:mDiscriminator.Value()] : [NSNumber numberWithUnsignedShort:3840U]; - params.iterations = - [NSNumber numberWithUnsignedInt:1000UL]; - params.salt = - [[NSData alloc] initWithBytes:"SPAKE2P Key Salt" length:16]; - [cluster openCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH1 opens the commissioning window on the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH1 opens the commissioning window on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitingAfterOpeningCommissioningWindow_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mWaitAfterCommissioning.HasValue() ? mWaitAfterCommissioning.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3Th2CommissionsDutUsingAdminNodeIdN2_5() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("beta", value); - } - NSNumber * _Nonnull th2FabricIndex; - - CHIP_ERROR TestStep4Th2ReadsItsFabricIndexFromTheOperationalCredentialsClusterCurrentFabricIndexAttribute_7() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH2 reads its fabric index from the Operational Credentials cluster CurrentFabricIndex attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH2 reads its fabric index from the Operational Credentials cluster CurrentFabricIndex attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th2FabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4Th2ReadsTheFabricIndex_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nonnull commissionerNodeIdAlpha; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheAlphaFabric_9() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdAlpha = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestStep5Th1WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterAccessControl0x001fEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldNullETargetsFieldClusterDescriptor0x001dEndpoint0_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [th1FabricIndex copy]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:29UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [th1FabricIndex copy]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH1 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field:[{Cluster: AccessControl (0x001f), Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: null e)Targets field: [{Cluster: Descriptor (0x001d), Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 5: TH1 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field:[{Cluster: AccessControl (0x001f), Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: null e)Targets field: [{Cluster: Descriptor (0x001d), Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull commissionerNodeIdBeta; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheBetaFabric_11() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("beta", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdBeta = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestStep6Th2WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndexTh2FabricIndexBPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn2ETargetsFieldClusterAccessControl0x001fEndpoint0_12() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdBeta copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [th2FabricIndex copy]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:40UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [th2FabricIndex copy]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH2 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: th2FabricIndex b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N2] e)Targets field: [{Cluster: AccessControl (0x001f), Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 6: TH2 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: th2FabricIndex b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N2] e)Targets field: [{Cluster: AccessControl (0x001f), Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6Th2WritesAclGivingViewPrivilgeForBasicCluster_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7Th1ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDeviceTypeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH1 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH1 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8Th1ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH1 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH1 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9Th2ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDeviceTypeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH2 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Error: %@", err); - } else { - NSLog(@"Step 9: TH2 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9Th2ReadsDescriptorClusterExpectUnsupportedAccess_17() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_18() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Error: %@", err); - } else { - NSLog(@"Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttributeExpectSuccess_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep11Th1ResetsTheACLsToTheDefaultValueBywritingDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining1Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH1 resets the ACLs to the default value bywriting DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 1 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Error: %@", err); - } else { - NSLog(@"Step 11: TH1 resets the ACLs to the default value bywriting DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 1 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandToTheDutWithTheFabricIndexSetToTh2FabricIndex_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [th2FabricIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric command to the DUT with the FabricIndex set to th2FabricIndex: Error: %@", err); - } else { - NSLog(@"Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric command to the DUT with the FabricIndex set to th2FabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandtoTheDutWithTheFabricIndexSetToTh2FabricIndex_22() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_AIRQUAL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AIRQUAL_1_1() - : TestCommandBridge("Test_TC_AIRQUAL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AIRQUAL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AIRQUAL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AIRQUAL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!AIRQUAL.S.F00 && !AIRQUAL.S.F01 && !AIRQUAL.S.F02 && !AIRQUAL.S.F03")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given AIRQUAL.S.F00(Fair) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("AIRQUAL.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenAIRQUALSF00FairEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given AIRQUAL.S.F01(Moderate) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("AIRQUAL.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenAIRQUALSF01ModerateEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given AIRQUAL.S.F02(VeryPoor) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("AIRQUAL.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenAIRQUALSF02VeryPoorEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given AIRQUAL.S.F03(ExtremelyPoor) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("AIRQUAL.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenAIRQUALSF03ExtremelyPoorEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenAIRQUALSF00FairEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given AIRQUAL.S.F00(Fair) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given AIRQUAL.S.F00(Fair) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenAIRQUALSF01ModerateEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given AIRQUAL.S.F01(Moderate) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given AIRQUAL.S.F01(Moderate) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenAIRQUALSF02VeryPoorEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given AIRQUAL.S.F02(VeryPoor) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given AIRQUAL.S.F02(VeryPoor) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenAIRQUALSF03ExtremelyPoorEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given AIRQUAL.S.F03(ExtremelyPoor) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given AIRQUAL.S.F03(ExtremelyPoor) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_AIRQUAL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AIRQUAL_2_1() - : TestCommandBridge("Test_TC_AIRQUAL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AIRQUAL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AIRQUAL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AIRQUAL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the AirQuality attribute.\n"); - if (ShouldSkip("AIRQUAL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheAirQualityAttribute_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheAirQualityAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAirQualityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the AirQuality attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the AirQuality attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("airQuality", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("airQuality", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("airQuality", [value unsignedCharValue], 6U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BOOL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BOOL_1_1() - : TestCommandBridge("Test_TC_BOOL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BOOL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BOOL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BOOL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("BOOL.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip(" !BOOL.S.E00 && PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BOOL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BOOL_2_1() - : TestCommandBridge("Test_TC_BOOL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BOOL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BOOL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BOOL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the StateValue attribute from the DUT\n"); - if (ShouldSkip("BOOL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheStateValueAttributeFromTheDut_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheStateValueAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the StateValue attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the StateValue attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("stateValue", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BRBINFO_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BRBINFO_1_1() - : TestCommandBridge("Test_TC_BRBINFO_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BRBINFO_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BRBINFO_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BRBINFO_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); - err = TestStep3ThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip(" !PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(VendorName) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0001")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeVendorNameInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads optional attribute(VendorID) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributeVendorIDInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads optional attribute(ProductName) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0003")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeProductNameInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: TH reads optional attribute(NodeLabel) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0005")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeNodeLabelInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: TH reads optional attribute(HardwareVersion) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0007")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributeHardwareVersionInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: TH reads optional attribute(HardwareVersionString) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0008")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributeHardwareVersionStringInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4h: TH reads optional attribute(SoftwareVersion) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0009")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributeSoftwareVersionInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4i: TH reads optional attribute(SoftwareVersionString) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000a")) { - NextTest(); - return; - } - err = TestStep4iThReadsOptionalAttributeSoftwareVersionStringInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4j: TH reads optional attribute(ManufacturingDate) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000b")) { - NextTest(); - return; - } - err = TestStep4jThReadsOptionalAttributeManufacturingDateInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4k: TH reads optional attribute(PartNumber) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000c")) { - NextTest(); - return; - } - err = TestStep4kThReadsOptionalAttributePartNumberInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4l: TH reads optional attribute(ProductURL) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000d")) { - NextTest(); - return; - } - err = TestStep4lThReadsOptionalAttributeProductURLInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4m: TH reads optional attribute(ProductLabel) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000e")) { - NextTest(); - return; - } - err = TestStep4mThReadsOptionalAttributeProductLabelInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4n: TH reads optional attribute(SerialNumber) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000f")) { - NextTest(); - return; - } - err = TestStep4nThReadsOptionalAttributeSerialNumberInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4o: TH reads optional attribute(UniqueID) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0012")) { - NextTest(); - return; - } - err = TestStep4oThReadsOptionalAttributeUniqueIDInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4p: TH reads optional attribute(ProductAppearance) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0014")) { - NextTest(); - return; - } - err = TestStep4pThReadsOptionalAttributeProductAppearanceInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5a: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5b: TH reads optional event(StartUp) in EventList\n"); - if (ShouldSkip("BRBINFO.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5c: TH reads optional attribute(ShutDown) in EventList\n"); - if (ShouldSkip("BRBINFO.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 5d TH reads optional attribute(Leave) in EventList\n"); - if (ShouldSkip("BRBINFO.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 6: TH reads AcceptedCommandList from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 7: TH1 reads GeneratedCommandList from DUT\n"); - err = TestStep7Th1ReadsGeneratedCommandListFromDut_25(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 26; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeVendorNameInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(VendorName) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(VendorName) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributeVendorIDInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(VendorID) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(VendorID) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeProductNameInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(ProductName) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(ProductName) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeNodeLabelInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(NodeLabel) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(NodeLabel) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributeHardwareVersionInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(HardwareVersion) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(HardwareVersion) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributeHardwareVersionStringInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(HardwareVersionString) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(HardwareVersionString) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributeSoftwareVersionInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(SoftwareVersion) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(SoftwareVersion) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsOptionalAttributeSoftwareVersionStringInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads optional attribute(SoftwareVersionString) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads optional attribute(SoftwareVersionString) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsOptionalAttributeManufacturingDateInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads optional attribute(ManufacturingDate) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads optional attribute(ManufacturingDate) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsOptionalAttributePartNumberInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH reads optional attribute(PartNumber) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: TH reads optional attribute(PartNumber) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsOptionalAttributeProductURLInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: TH reads optional attribute(ProductURL) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: TH reads optional attribute(ProductURL) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsOptionalAttributeProductLabelInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: TH reads optional attribute(ProductLabel) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4m: TH reads optional attribute(ProductLabel) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsOptionalAttributeSerialNumberInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: TH reads optional attribute(SerialNumber) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4n: TH reads optional attribute(SerialNumber) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsOptionalAttributeUniqueIDInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: TH reads optional attribute(UniqueID) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4o: TH reads optional attribute(UniqueID) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsOptionalAttributeProductAppearanceInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4p: TH reads optional attribute(ProductAppearance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4p: TH reads optional attribute(ProductAppearance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7Th1ReadsGeneratedCommandListFromDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH1 reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH1 reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACT_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACT_1_1() - : TestCommandBridge("Test_TC_ACT_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACT_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACT_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACT_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: Read the optional attribute(SetupURL) in AttributeList\n"); - if (ShouldSkip("ACT.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeSetupURLInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6a: TH Read the optional command (InstantAction) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadTheOptionalCommandInstantActionInAcceptedCommandList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6b: TH Read the optional command (InstantActionWithTransition) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadTheOptionalCommandInstantActionWithTransitionInAcceptedCommandList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6C: TH Read the optional command (StartAction) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThReadTheOptionalCommandStartActionInAcceptedCommandList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6d: TH Read the optional command (StartActionWithDuration) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThReadTheOptionalCommandStartActionWithDurationInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6e: TH Read the optional command (StopAction) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep6eThReadTheOptionalCommandStopActionInAcceptedCommandList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6f: TH Read the optional command (PauseAction) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep6fThReadTheOptionalCommandPauseActionInAcceptedCommandList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6g: TH Read the optional command (PauseActionWithDuration) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep6gThReadTheOptionalCommandPauseActionWithDurationInAcceptedCommandList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6h: TH Read the optional command (ResumeAction) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep6hThReadTheOptionalCommandResumeActionInAcceptedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6i: TH Read the optional command (EnableAction) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep6iThReadTheOptionalCommandEnableActionInAcceptedCommandList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6j: TH Read the optional command (EnableActionWithDuration) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep6jThReadTheOptionalCommandEnableActionWithDurationInAcceptedCommandList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6k: TH Read the optional command (DisableAction) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep6kThReadTheOptionalCommandDisableActionInAcceptedCommandList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6l: TH Read the optional command (DisableActionWithDuration) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep6lThReadTheOptionalCommandDisableActionWithDurationInAcceptedCommandList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeSetupURLInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute(SetupURL) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute(SetupURL) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadTheOptionalCommandInstantActionInAcceptedCommandList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH Read the optional command (InstantAction) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a: TH Read the optional command (InstantAction) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadTheOptionalCommandInstantActionWithTransitionInAcceptedCommandList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH Read the optional command (InstantActionWithTransition) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH Read the optional command (InstantActionWithTransition) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadTheOptionalCommandStartActionInAcceptedCommandList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6C: TH Read the optional command (StartAction) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6C: TH Read the optional command (StartAction) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadTheOptionalCommandStartActionWithDurationInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH Read the optional command (StartActionWithDuration) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH Read the optional command (StartActionWithDuration) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eThReadTheOptionalCommandStopActionInAcceptedCommandList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: TH Read the optional command (StopAction) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6e: TH Read the optional command (StopAction) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fThReadTheOptionalCommandPauseActionInAcceptedCommandList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: TH Read the optional command (PauseAction) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6f: TH Read the optional command (PauseAction) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gThReadTheOptionalCommandPauseActionWithDurationInAcceptedCommandList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6g: TH Read the optional command (PauseActionWithDuration) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6g: TH Read the optional command (PauseActionWithDuration) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6hThReadTheOptionalCommandResumeActionInAcceptedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6h: TH Read the optional command (ResumeAction) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6h: TH Read the optional command (ResumeAction) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6iThReadTheOptionalCommandEnableActionInAcceptedCommandList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6i: TH Read the optional command (EnableAction) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6i: TH Read the optional command (EnableAction) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6jThReadTheOptionalCommandEnableActionWithDurationInAcceptedCommandList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6j: TH Read the optional command (EnableActionWithDuration) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6j: TH Read the optional command (EnableActionWithDuration) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6kThReadTheOptionalCommandDisableActionInAcceptedCommandList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6k: TH Read the optional command (DisableAction) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6k: TH Read the optional command (DisableAction) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6lThReadTheOptionalCommandDisableActionWithDurationInAcceptedCommandList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6l: TH Read the optional command (DisableActionWithDuration) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6l: TH Read the optional command (DisableActionWithDuration) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BIND_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BIND_1_1() - : TestCommandBridge("Test_TC_BIND_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BIND_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BIND_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BIND_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); - err = TestStep3ThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsAttributeListFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads AcceptedCommandList attribute from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAttributeListFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_1_1() - : TestCommandBridge("Test_TC_CC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute\n"); - if (ShouldSkip("( !CC.S.F00 && !CC.S.F01 && !CC.S.F02 && !CC.S.F03 && !CC.S.F04 )")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given CC.S.F00(HS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenCcsf00hsEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given CC.S.F01(EHue) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenCCSF01EHueEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given CC.S.F02(CL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenCcsf02clEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given CC.S.F03(XY) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenCcsf03xyEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given CC.S.F04(CT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenCcsf04ctEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads feature dependent attribute (CurrentHue) in AttributeList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentAttributeCurrentHueInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: TH reads feature dependent attribute (CurrentSaturation) in AttributeList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentAttributeCurrentSaturationInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: TH reads the optional attribute(RemainingTime) in AttributeList\n"); - if (ShouldSkip("CC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeRemainingTimeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4e: TH reads feature dependent attribute (CurrentX) in AttributeList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003")) { - NextTest(); - return; - } - err = TestStep4eThReadsFeatureDependentAttributeCurrentXInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4f: TH reads feature dependent attribute (CurrentY) in AttributeList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004")) { - NextTest(); - return; - } - err = TestStep4fThReadsFeatureDependentAttributeCurrentYInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4g: TH reads the optional attribute(DriftCompensation) in AttributeList\n"); - if (ShouldSkip("CC.S.A0005")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalAttributeDriftCompensationInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4h: TH reads the optional attribute(CompensationText) in AttributeList\n"); - if (ShouldSkip("CC.S.A0006")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalAttributeCompensationTextInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4i: TH reads feature dependent attribute (ColorTemperatureMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep4iThReadsFeatureDependentAttributeColorTemperatureMiredsInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4j: TH reads the Primary1X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0011")) { - NextTest(); - return; - } - err = TestStep4jThReadsThePrimary1XAttributeInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4k: TH reads the Primary1Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0012")) { - NextTest(); - return; - } - err = TestStep4kThReadsThePrimary1YAttributeInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4l: TH reads the Primary1Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0013")) { - NextTest(); - return; - } - err = TestStep4lThReadsThePrimary1IntensityAttributeInAttributeList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4m: TH reads the Primary2X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0015")) { - NextTest(); - return; - } - err = TestStep4mThReadsThePrimary2XAttributeInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4n: TH reads the Primary2Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0016")) { - NextTest(); - return; - } - err = TestStep4nThReadsThePrimary2YAttributeInAttributeList_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4o: TH reads the Primary2Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0017")) { - NextTest(); - return; - } - err = TestStep4oThReadsThePrimary2IntensityAttributeInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4p: TH reads the Primary3X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0019")) { - NextTest(); - return; - } - err = TestStep4pThReadsThePrimary3XAttributeInAttributeList_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4q: TH reads the Primary3Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A001a")) { - NextTest(); - return; - } - err = TestStep4qThReadsThePrimary3YAttributeInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4r: TH reads the Primary3Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A001b")) { - NextTest(); - return; - } - err = TestStep4rThReadsThePrimary3IntensityAttributeInAttributeList_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4s: TH reads the Primary4X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0020")) { - NextTest(); - return; - } - err = TestStep4sThReadsThePrimary4XAttributeInAttributeList_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4t: TH reads the Primary4Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0021")) { - NextTest(); - return; - } - err = TestStep4tThReadsThePrimary4YAttributeInAttributeList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4u: TH reads the Primary4Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0022")) { - NextTest(); - return; - } - err = TestStep4uThReadsThePrimary4IntensityAttributeInAttributeList_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 4v: TH reads the Primary5X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0024")) { - NextTest(); - return; - } - err = TestStep4vThReadsThePrimary5XAttributeInAttributeList_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4w: TH reads the Primary5Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0025")) { - NextTest(); - return; - } - err = TestStep4wThReadsThePrimary5YAttributeInAttributeList_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4x: TH reads the Primary5Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0026")) { - NextTest(); - return; - } - err = TestStep4xThReadsThePrimary5IntensityAttributeInAttributeList_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 4y: TH reads the Primary6X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0028")) { - NextTest(); - return; - } - err = TestStep4yThReadsThePrimary6XAttributeInAttributeList_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4z: TH reads the Primary6Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0029")) { - NextTest(); - return; - } - err = TestStep4zThReadsThePrimary6YAttributeInAttributeList_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4a1: TH reads the Primary6Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A002a")) { - NextTest(); - return; - } - err = TestStep4a1ThReadsThePrimary6IntensityAttributeInAttributeList_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4a2: TH reads the optional attribute(WhitePointX) in AttributeList\n"); - if (ShouldSkip("CC.S.A0030")) { - NextTest(); - return; - } - err = TestStep4a2ThReadsTheOptionalAttributeWhitePointXInAttributeList_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 4a3: TH reads the optional attribute(WhitePointY) in AttributeList\n"); - if (ShouldSkip("CC.S.A0031")) { - NextTest(); - return; - } - err = TestStep4a3ThReadsTheOptionalAttributeWhitePointYInAttributeList_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 4a4: TH reads the optional attribute(ColorPointRX) in AttributeList\n"); - if (ShouldSkip("CC.S.A0032")) { - NextTest(); - return; - } - err = TestStep4a4ThReadsTheOptionalAttributeColorPointRXInAttributeList_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 4a5: TH reads the optional attribute(ColorPointRY) in AttributeList\n"); - if (ShouldSkip("CC.S.A0033")) { - NextTest(); - return; - } - err = TestStep4a5ThReadsTheOptionalAttributeColorPointRYInAttributeList_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 4a6: TH reads the optional attribute(ColorPointRIntensity) in AttributeList\n"); - if (ShouldSkip("CC.S.A0034")) { - NextTest(); - return; - } - err = TestStep4a6ThReadsTheOptionalAttributeColorPointRIntensityInAttributeList_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 4a7: TH reads the optional attribute(ColorPointGX) in AttributeList\n"); - if (ShouldSkip("CC.S.A0036")) { - NextTest(); - return; - } - err = TestStep4a7ThReadsTheOptionalAttributeColorPointGXInAttributeList_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 4a8: TH reads the optional attribute(ColorPointGY) in AttributeList\n"); - if (ShouldSkip("CC.S.A0037")) { - NextTest(); - return; - } - err = TestStep4a8ThReadsTheOptionalAttributeColorPointGYInAttributeList_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 4a9: TH reads the optional attribute(ColorPointGIntensity) in AttributeList\n"); - if (ShouldSkip("CC.S.A0038")) { - NextTest(); - return; - } - err = TestStep4a9ThReadsTheOptionalAttributeColorPointGIntensityInAttributeList_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 4a10: TH reads the optional attribute(ColorPointBX) in AttributeList\n"); - if (ShouldSkip("CC.S.A003a")) { - NextTest(); - return; - } - err = TestStep4a10ThReadsTheOptionalAttributeColorPointBXInAttributeList_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 4a11: TH reads the optional attribute(ColorPointBY) in AttributeList\n"); - if (ShouldSkip("CC.S.A003b")) { - NextTest(); - return; - } - err = TestStep4a11ThReadsTheOptionalAttributeColorPointBYInAttributeList_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 4a12: TH reads the optional attribute(ColorPointBIntensity) in AttributeList\n"); - if (ShouldSkip("CC.S.A003c")) { - NextTest(); - return; - } - err = TestStep4a12ThReadsTheOptionalAttributeColorPointBIntensityInAttributeList_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 4a13: TH reads feature dependent attribute (EnhancedCurrentHue) in AttributeList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep4a13ThReadsFeatureDependentAttributeEnhancedCurrentHueInAttributeList_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 4a14: TH reads feature dependent attribute (ColorLoopActive) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4002")) { - NextTest(); - return; - } - err = TestStep4a14ThReadsFeatureDependentAttributeColorLoopActiveInAttributeList_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Step 4a15: TH reads feature dependent attribute (ColorLoopDirection) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4003")) { - NextTest(); - return; - } - err = TestStep4a15ThReadsFeatureDependentAttributeColorLoopDirectionInAttributeList_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Step 4a16: TH reads feature dependent attribute (ColorLoopTime) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4004")) { - NextTest(); - return; - } - err = TestStep4a16ThReadsFeatureDependentAttributeColorLoopTimeInAttributeList_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Step 4a17: TH reads feature dependent attribute (ColorLoopStartEnhancedHue) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4005")) { - NextTest(); - return; - } - err = TestStep4a17ThReadsFeatureDependentAttributeColorLoopStartEnhancedHueInAttributeList_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Step 4a18: TH reads feature dependent attribute (ColorLoopStoredEnhancedHue) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4006")) { - NextTest(); - return; - } - err = TestStep4a18ThReadsFeatureDependentAttributeColorLoopStoredEnhancedHueInAttributeList_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Step 4a19: TH reads feature dependent attribute (ColorTempPhysicalMinMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400b")) { - NextTest(); - return; - } - err = TestStep4a19ThReadsFeatureDependentAttributeColorTempPhysicalMinMiredsInAttributeList_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Step 4a20: TH reads feature dependent attribute (ColorTempPhysicalMaxMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400c")) { - NextTest(); - return; - } - err = TestStep4a20ThReadsFeatureDependentAttributeColorTempPhysicalMaxMiredsInAttributeList_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Step 4a21:TH reads feature dependent attribute (CoupleColorTempToLevelMinMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400d")) { - NextTest(); - return; - } - err = TestStep4a21THReadsFeatureDependentAttributeCoupleColorTempToLevelMinMiredsInAttributeList_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Step 4a22: TH reads feature dependent attribute (StartUpColorTemperatureMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A4010")) { - NextTest(); - return; - } - err = TestStep4a22ThReadsFeatureDependentAttributeStartUpColorTemperatureMiredsInAttributeList_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Step 5: TH reads from the DUT the (0xFFFA) EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Step 6a: TH reads feature dependent command(MoveToHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsFeatureDependentCommandMoveToHueInAcceptedCommandList_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Step 6b: TH reads feature dependent command(MoveHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsFeatureDependentCommandMoveHueInAcceptedCommandList_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Step 6c: TH reads feature dependent command(StepHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThReadsFeatureDependentCommandStepHueInAcceptedCommandList_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Step 6d: TH reads feature dependent command(MoveToSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThReadsFeatureDependentCommandMoveToSaturationInAcceptedCommandList_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Step 6e: TH reads feature dependent command(MoveSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep6eThReadsFeatureDependentCommandMoveSaturationInAcceptedCommandList_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Step 6f: TH reads feature dependent command(StepSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep6fThReadsFeatureDependentCommandStepSaturationInAcceptedCommandList_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Step 6g: TH reads feature dependent command(MoveToHueAndSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep6gThReadsFeatureDependentCommandMoveToHueAndSaturationInAcceptedCommandList_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Step 6h: TH reads feature dependent command(MoveToColor) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep6hThReadsFeatureDependentCommandMoveToColorInAcceptedCommandList_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Step 6i: TH reads feature dependent command(MoveColor) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep6iThReadsFeatureDependentCommandMoveColorInAcceptedCommandList_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Step 6j: TH reads feature dependent command(StepColor) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep6jThReadsFeatureDependentCommandStepColorInAcceptedCommandList_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Step 6k: TH reads feature dependent command(MoveToColorTemperature) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep6kThReadsFeatureDependentCommandMoveToColorTemperatureInAcceptedCommandList_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Step 6l: TH reads feature dependent command(EnhancedMoveToHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep6lThReadsFeatureDependentCommandEnhancedMoveToHueInAcceptedCommandList_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Step 6m: TH reads feature dependent command(EnhancedMoveHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep6mThReadsFeatureDependentCommandEnhancedMoveHueInAcceptedCommandList_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Step 6n: TH reads feature dependent command(EnhancedStepHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C42.Rsp")) { - NextTest(); - return; - } - err = TestStep6nThReadsFeatureDependentCommandEnhancedStepHueInAcceptedCommandList_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Step 6o:TH reads feature dependent command(EnhancedMoveToHueAndSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C43.Rsp")) { - NextTest(); - return; - } - err = TestStep6oTHReadsFeatureDependentCommandEnhancedMoveToHueAndSaturationInAcceptedCommandList_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Step 6p: TH reads feature dependent command(ColorLoopSet) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.C44.Rsp")) { - NextTest(); - return; - } - err = TestStep6pThReadsFeatureDependentCommandColorLoopSetInAcceptedCommandList_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Step 6q: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.F03 && CC.S.F04 && CC.S.C47.Rsp")) { - NextTest(); - return; - } - err = TestStep6qThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Step 6r: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C4b.Rsp")) { - NextTest(); - return; - } - err = TestStep6rThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Step 6s: TH reads feature dependent command(StepColorTemperature) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C4c.Rsp")) { - NextTest(); - return; - } - err = TestStep6sThReadsFeatureDependentCommandStepColorTemperatureInAcceptedCommandList_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_77(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 78; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 6U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenCcsf00hsEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given CC.S.F00(HS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given CC.S.F00(HS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenCCSF01EHueEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given CC.S.F01(EHue) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given CC.S.F01(EHue) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenCcsf02clEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given CC.S.F02(CL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given CC.S.F02(CL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenCcsf03xyEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given CC.S.F03(XY) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given CC.S.F03(XY) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenCcsf04ctEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given CC.S.F04(CT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given CC.S.F04(CT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16385UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16394UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16385UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16394UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentAttributeCurrentHueInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads feature dependent attribute (CurrentHue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads feature dependent attribute (CurrentHue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentAttributeCurrentSaturationInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads feature dependent attribute (CurrentSaturation) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads feature dependent attribute (CurrentSaturation) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeRemainingTimeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional attribute(RemainingTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional attribute(RemainingTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsFeatureDependentAttributeCurrentXInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads feature dependent attribute (CurrentX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads feature dependent attribute (CurrentX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsFeatureDependentAttributeCurrentYInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads feature dependent attribute (CurrentY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads feature dependent attribute (CurrentY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalAttributeDriftCompensationInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional attribute(DriftCompensation) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional attribute(DriftCompensation) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalAttributeCompensationTextInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional attribute(CompensationText) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional attribute(CompensationText) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsFeatureDependentAttributeColorTemperatureMiredsInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads feature dependent attribute (ColorTemperatureMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads feature dependent attribute (ColorTemperatureMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsThePrimary1XAttributeInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the Primary1X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the Primary1X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsThePrimary1YAttributeInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH reads the Primary1Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: TH reads the Primary1Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsThePrimary1IntensityAttributeInAttributeList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: TH reads the Primary1Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: TH reads the Primary1Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsThePrimary2XAttributeInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: TH reads the Primary2X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4m: TH reads the Primary2X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsThePrimary2YAttributeInAttributeList_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: TH reads the Primary2Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4n: TH reads the Primary2Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsThePrimary2IntensityAttributeInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: TH reads the Primary2Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4o: TH reads the Primary2Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsThePrimary3XAttributeInAttributeList_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4p: TH reads the Primary3X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4p: TH reads the Primary3X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qThReadsThePrimary3YAttributeInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4q: TH reads the Primary3Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4q: TH reads the Primary3Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4rThReadsThePrimary3IntensityAttributeInAttributeList_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4r: TH reads the Primary3Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4r: TH reads the Primary3Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4sThReadsThePrimary4XAttributeInAttributeList_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4s: TH reads the Primary4X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4s: TH reads the Primary4X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4tThReadsThePrimary4YAttributeInAttributeList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4t: TH reads the Primary4Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4t: TH reads the Primary4Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4uThReadsThePrimary4IntensityAttributeInAttributeList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4u: TH reads the Primary4Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4u: TH reads the Primary4Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4vThReadsThePrimary5XAttributeInAttributeList_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4v: TH reads the Primary5X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4v: TH reads the Primary5X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4wThReadsThePrimary5YAttributeInAttributeList_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4w: TH reads the Primary5Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4w: TH reads the Primary5Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4xThReadsThePrimary5IntensityAttributeInAttributeList_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4x: TH reads the Primary5Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4x: TH reads the Primary5Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4yThReadsThePrimary6XAttributeInAttributeList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4y: TH reads the Primary6X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4y: TH reads the Primary6X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 40UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4zThReadsThePrimary6YAttributeInAttributeList_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4z: TH reads the Primary6Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4z: TH reads the Primary6Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a1ThReadsThePrimary6IntensityAttributeInAttributeList_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a1: TH reads the Primary6Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a1: TH reads the Primary6Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 42UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a2ThReadsTheOptionalAttributeWhitePointXInAttributeList_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a2: TH reads the optional attribute(WhitePointX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a2: TH reads the optional attribute(WhitePointX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a3ThReadsTheOptionalAttributeWhitePointYInAttributeList_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a3: TH reads the optional attribute(WhitePointY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a3: TH reads the optional attribute(WhitePointY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a4ThReadsTheOptionalAttributeColorPointRXInAttributeList_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a4: TH reads the optional attribute(ColorPointRX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a4: TH reads the optional attribute(ColorPointRX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a5ThReadsTheOptionalAttributeColorPointRYInAttributeList_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a5: TH reads the optional attribute(ColorPointRY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a5: TH reads the optional attribute(ColorPointRY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 51UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a6ThReadsTheOptionalAttributeColorPointRIntensityInAttributeList_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a6: TH reads the optional attribute(ColorPointRIntensity) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a6: TH reads the optional attribute(ColorPointRIntensity) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 52UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a7ThReadsTheOptionalAttributeColorPointGXInAttributeList_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a7: TH reads the optional attribute(ColorPointGX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a7: TH reads the optional attribute(ColorPointGX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 54UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a8ThReadsTheOptionalAttributeColorPointGYInAttributeList_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a8: TH reads the optional attribute(ColorPointGY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a8: TH reads the optional attribute(ColorPointGY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 55UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a9ThReadsTheOptionalAttributeColorPointGIntensityInAttributeList_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a9: TH reads the optional attribute(ColorPointGIntensity) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a9: TH reads the optional attribute(ColorPointGIntensity) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 56UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a10ThReadsTheOptionalAttributeColorPointBXInAttributeList_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a10: TH reads the optional attribute(ColorPointBX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a10: TH reads the optional attribute(ColorPointBX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 58UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a11ThReadsTheOptionalAttributeColorPointBYInAttributeList_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a11: TH reads the optional attribute(ColorPointBY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a11: TH reads the optional attribute(ColorPointBY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 59UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a12ThReadsTheOptionalAttributeColorPointBIntensityInAttributeList_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a12: TH reads the optional attribute(ColorPointBIntensity) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a12: TH reads the optional attribute(ColorPointBIntensity) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 60UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a13ThReadsFeatureDependentAttributeEnhancedCurrentHueInAttributeList_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a13: TH reads feature dependent attribute (EnhancedCurrentHue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a13: TH reads feature dependent attribute (EnhancedCurrentHue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16384UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a14ThReadsFeatureDependentAttributeColorLoopActiveInAttributeList_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a14: TH reads feature dependent attribute (ColorLoopActive) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a14: TH reads feature dependent attribute (ColorLoopActive) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16386UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a15ThReadsFeatureDependentAttributeColorLoopDirectionInAttributeList_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a15: TH reads feature dependent attribute (ColorLoopDirection) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a15: TH reads feature dependent attribute (ColorLoopDirection) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16387UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a16ThReadsFeatureDependentAttributeColorLoopTimeInAttributeList_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a16: TH reads feature dependent attribute (ColorLoopTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a16: TH reads feature dependent attribute (ColorLoopTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16388UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a17ThReadsFeatureDependentAttributeColorLoopStartEnhancedHueInAttributeList_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a17: TH reads feature dependent attribute (ColorLoopStartEnhancedHue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a17: TH reads feature dependent attribute (ColorLoopStartEnhancedHue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16389UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a18ThReadsFeatureDependentAttributeColorLoopStoredEnhancedHueInAttributeList_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a18: TH reads feature dependent attribute (ColorLoopStoredEnhancedHue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a18: TH reads feature dependent attribute (ColorLoopStoredEnhancedHue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16390UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a19ThReadsFeatureDependentAttributeColorTempPhysicalMinMiredsInAttributeList_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a19: TH reads feature dependent attribute (ColorTempPhysicalMinMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a19: TH reads feature dependent attribute (ColorTempPhysicalMinMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16395UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a20ThReadsFeatureDependentAttributeColorTempPhysicalMaxMiredsInAttributeList_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a20: TH reads feature dependent attribute (ColorTempPhysicalMaxMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a20: TH reads feature dependent attribute (ColorTempPhysicalMaxMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16396UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a21THReadsFeatureDependentAttributeCoupleColorTempToLevelMinMiredsInAttributeList_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a21:TH reads feature dependent attribute (CoupleColorTempToLevelMinMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a21:TH reads feature dependent attribute (CoupleColorTempToLevelMinMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16397UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a22ThReadsFeatureDependentAttributeStartUpColorTemperatureMiredsInAttributeList_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a22: TH reads feature dependent attribute (StartUpColorTemperatureMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a22: TH reads feature dependent attribute (StartUpColorTemperatureMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16400UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFeatureDependentCommandMoveToHueInAcceptedCommandList_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads feature dependent command(MoveToHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads feature dependent command(MoveToHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFeatureDependentCommandMoveHueInAcceptedCommandList_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads feature dependent command(MoveHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads feature dependent command(MoveHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsFeatureDependentCommandStepHueInAcceptedCommandList_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads feature dependent command(StepHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads feature dependent command(StepHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsFeatureDependentCommandMoveToSaturationInAcceptedCommandList_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads feature dependent command(MoveToSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads feature dependent command(MoveToSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eThReadsFeatureDependentCommandMoveSaturationInAcceptedCommandList_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: TH reads feature dependent command(MoveSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6e: TH reads feature dependent command(MoveSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fThReadsFeatureDependentCommandStepSaturationInAcceptedCommandList_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: TH reads feature dependent command(StepSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6f: TH reads feature dependent command(StepSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gThReadsFeatureDependentCommandMoveToHueAndSaturationInAcceptedCommandList_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6g: TH reads feature dependent command(MoveToHueAndSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6g: TH reads feature dependent command(MoveToHueAndSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6hThReadsFeatureDependentCommandMoveToColorInAcceptedCommandList_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6h: TH reads feature dependent command(MoveToColor) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6h: TH reads feature dependent command(MoveToColor) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6iThReadsFeatureDependentCommandMoveColorInAcceptedCommandList_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6i: TH reads feature dependent command(MoveColor) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6i: TH reads feature dependent command(MoveColor) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6jThReadsFeatureDependentCommandStepColorInAcceptedCommandList_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6j: TH reads feature dependent command(StepColor) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6j: TH reads feature dependent command(StepColor) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6kThReadsFeatureDependentCommandMoveToColorTemperatureInAcceptedCommandList_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6k: TH reads feature dependent command(MoveToColorTemperature) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6k: TH reads feature dependent command(MoveToColorTemperature) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6lThReadsFeatureDependentCommandEnhancedMoveToHueInAcceptedCommandList_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6l: TH reads feature dependent command(EnhancedMoveToHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6l: TH reads feature dependent command(EnhancedMoveToHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6mThReadsFeatureDependentCommandEnhancedMoveHueInAcceptedCommandList_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6m: TH reads feature dependent command(EnhancedMoveHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6m: TH reads feature dependent command(EnhancedMoveHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 65UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6nThReadsFeatureDependentCommandEnhancedStepHueInAcceptedCommandList_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6n: TH reads feature dependent command(EnhancedStepHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6n: TH reads feature dependent command(EnhancedStepHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 66UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6oTHReadsFeatureDependentCommandEnhancedMoveToHueAndSaturationInAcceptedCommandList_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6o:TH reads feature dependent command(EnhancedMoveToHueAndSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6o:TH reads feature dependent command(EnhancedMoveToHueAndSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 67UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6pThReadsFeatureDependentCommandColorLoopSetInAcceptedCommandList_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6p: TH reads feature dependent command(ColorLoopSet) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6p: TH reads feature dependent command(ColorLoopSet) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 68UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6qThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6q: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6q: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 71UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6rThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6r: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6r: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 75UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6sThReadsFeatureDependentCommandStepColorTemperatureInAcceptedCommandList_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6s: TH reads feature dependent command(StepColorTemperature) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6s: TH reads feature dependent command(StepColorTemperature) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 76UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_2_1() - : TestCommandBridge("Test_TC_CC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0x0000) CurrentHue attribute\n"); - if (ShouldSkip("CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutThe0x0000CurrentHueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the (0x0001) CurrentSaturation attribute\n"); - if (ShouldSkip("CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutThe0x0001CurrentSaturationAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the (0x0002) RemainingTime attribute\n"); - if (ShouldSkip("CC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutThe0x0002RemainingTimeAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the (0x0003) CurrentX attribute\n"); - if (ShouldSkip("CC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThe0x0003CurrentXAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the (0x0004) CurrentY attribute\n"); - if (ShouldSkip("CC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThe0x0004CurrentYAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the (0x0005) DriftCompensation attribute\n"); - if (ShouldSkip("CC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutThe0x0005DriftCompensationAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the (0x0006) CompensationText attribute\n"); - if (ShouldSkip("CC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutThe0x0006CompensationTextAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the (0x0007) ColorTemperatureMireds attribute\n"); - if (ShouldSkip("CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutThe0x0007ColorTemperatureMiredsAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the (0x0008) ColorMode attribute\n"); - if (ShouldSkip("CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutThe0x0008ColorModeAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the (0x000f) Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutThe0x000fOptionsAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the (0x4000) EnhancedCurrentHue attribute\n"); - if (ShouldSkip("CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutThe0x4000EnhancedCurrentHueAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the (0x4001) EnhancedColorMode attribute\n"); - if (ShouldSkip("CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep13ThReadsFromTheDutThe0x4001EnhancedColorModeAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14:TH reads from the DUT the (0x4002) ColorLoopActive attribute\n"); - if (ShouldSkip("CC.S.A4002")) { - NextTest(); - return; - } - err = TestStep14thReadsFromTheDutThe0x4002ColorLoopActiveAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: TH reads from the DUT the (0x4003) ColorLoopDirection attribute\n"); - if (ShouldSkip("CC.S.A4003")) { - NextTest(); - return; - } - err = TestStep15ThReadsFromTheDutThe0x4003ColorLoopDirectionAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: TH reads from the DUT the (0x4004) ColorLoopTime attribute\n"); - if (ShouldSkip("CC.S.A4004")) { - NextTest(); - return; - } - err = TestStep16ThReadsFromTheDutThe0x4004ColorLoopTimeAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: TH reads from the DUT the (0x4005) ColorLoopStartEnhancedHue attribute\n"); - if (ShouldSkip("CC.S.A4005")) { - NextTest(); - return; - } - err = TestStep17ThReadsFromTheDutThe0x4005ColorLoopStartEnhancedHueAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: TH reads from the DUT the (0x4006) ColorLoopStoredEnhancedHue attributeT\n"); - if (ShouldSkip("CC.S.A4006")) { - NextTest(); - return; - } - err = TestStep18ThReadsFromTheDutThe0x4006ColorLoopStoredEnhancedHueAttributeT_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 18a: Saving for comparision in step 19 reads FeatureMap attribute from DUT\n"); - err = TestStep18aSavingForComparisionInStep19ReadsFeatureMapAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 19: TH reads from the DUT the (0x400a) ColorCapabilities attribute\n"); - if (ShouldSkip("CC.S.A400a")) { - NextTest(); - return; - } - err = TestStep19ThReadsFromTheDutThe0x400aColorCapabilitiesAttribute_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 20: TH reads from the DUT the (0x400b) ColorTempPhysicalMinMireds attribute\n"); - if (ShouldSkip("CC.S.A400b")) { - NextTest(); - return; - } - err = TestStep20ThReadsFromTheDutThe0x400bColorTempPhysicalMinMiredsAttribute_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 21: TH reads from the DUT the (0x400c) ColorTempPhysicalMaxMireds attribute\n"); - if (ShouldSkip("CC.S.A400c")) { - NextTest(); - return; - } - err = TestStep21ThReadsFromTheDutThe0x400cColorTempPhysicalMaxMiredsAttribute_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 22: TH reads from the DUT the (0x400d) CoupleColorTempToLevelMinMireds attribute\n"); - if (ShouldSkip("CC.S.A400d")) { - NextTest(); - return; - } - err = TestStep22ThReadsFromTheDutThe0x400dCoupleColorTempToLevelMinMiredsAttribute_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 23: TH reads from the DUT the (0x4010) StartUpColorTemperatureMireds attribute\n"); - if (ShouldSkip("CC.S.A4010")) { - NextTest(); - return; - } - err = TestStep23ThReadsFromTheDutThe0x4010StartUpColorTemperatureMiredsAttribute_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 24: TH reads from the DUT the (0x0010) NumberOfPrimaries attribute\n"); - if (ShouldSkip("CC.S.A0010")) { - NextTest(); - return; - } - err = TestStep24ThReadsFromTheDutThe0x0010NumberOfPrimariesAttribute_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 25: TH reads Primary1X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 1 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0011")) { - NextTest(); - return; - } - err = TestStep25ThReadsPrimary1XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 26: TH reads Primary1Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 1 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0012")) { - NextTest(); - return; - } - err = TestStep26ThReadsPrimary1YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 27: TH reads Primary1Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 1 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0013")) { - NextTest(); - return; - } - err = TestStep27ThReadsPrimary1IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs1OrMore_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 28: TH reads Primary2X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 2 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0015")) { - NextTest(); - return; - } - err = TestStep28ThReadsPrimary2XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 29: TH reads Primary2Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 2 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0016")) { - NextTest(); - return; - } - err = TestStep29ThReadsPrimary2YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 30: TH reads Primary2Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 2 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0017")) { - NextTest(); - return; - } - err = TestStep30ThReadsPrimary2IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs2OrMore_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 31: TH reads Primary3X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 3 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0019")) { - NextTest(); - return; - } - err = TestStep31ThReadsPrimary3XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 32: TH reads Primary3Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 3 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A001a")) { - NextTest(); - return; - } - err = TestStep32ThReadsPrimary3YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 33: TH reads Primary3Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 3 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A001b")) { - NextTest(); - return; - } - err = TestStep33ThReadsPrimary3IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs3OrMore_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 34: TH reads Primary4X attribute from DUT Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 4 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0020")) { - NextTest(); - return; - } - err = TestStep34ThReadsPrimary4XAttributeFromDutVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 35: TH reads Primary4Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 4 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0021")) { - NextTest(); - return; - } - err = TestStep35ThReadsPrimary4YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 36: TH reads Primary4Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 4 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0022")) { - NextTest(); - return; - } - err = TestStep36ThReadsPrimary4IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs4OrMore_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 37: TH reads Primary5X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 5 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0024")) { - NextTest(); - return; - } - err = TestStep37ThReadsPrimary5XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 38: TH reads Primary5Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 5 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0025")) { - NextTest(); - return; - } - err = TestStep38ThReadsPrimary5YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 39: TH reads Primary5Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 5 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0026")) { - NextTest(); - return; - } - err = TestStep39ThReadsPrimary5IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs5OrMore_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 40: TH reads Primary6X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 6 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0028")) { - NextTest(); - return; - } - err = TestStep40ThReadsPrimary6XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 41: TH reads Primary6Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 6 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0029")) { - NextTest(); - return; - } - err = TestStep41ThReadsPrimary6YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 42: TH reads Primary6Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 6 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A002a")) { - NextTest(); - return; - } - err = TestStep42ThReadsPrimary6IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs6OrMore_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 43: TH reads from the DUT the (0x0030) WhitePointX attribute\n"); - if (ShouldSkip("CC.S.A0030")) { - NextTest(); - return; - } - err = TestStep43ThReadsFromTheDutThe0x0030WhitePointXAttribute_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 44: TH reads from the DUT the (0x0031) WhitePointY attribute\n"); - if (ShouldSkip("CC.S.A0031")) { - NextTest(); - return; - } - err = TestStep44ThReadsFromTheDutThe0x0031WhitePointYAttribute_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 45: TH reads from the DUT the (0x0032) ColorPointRX attribute\n"); - if (ShouldSkip("CC.S.A0032")) { - NextTest(); - return; - } - err = TestStep45ThReadsFromTheDutThe0x0032ColorPointRXAttribute_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 46: TH reads from the DUT the (0x0033) ColorPointRY attribute\n"); - if (ShouldSkip("CC.S.A0033")) { - NextTest(); - return; - } - err = TestStep46ThReadsFromTheDutThe0x0033ColorPointRYAttribute_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 47: TH reads from the DUT the (0x0034) ColorPointRIntensity attribute\n"); - if (ShouldSkip("CC.S.A0034")) { - NextTest(); - return; - } - err = TestStep47ThReadsFromTheDutThe0x0034ColorPointRIntensityAttribute_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 48: TH reads from the DUT the (0x0036) ColorPointGX attribute\n"); - if (ShouldSkip("CC.S.A0036")) { - NextTest(); - return; - } - err = TestStep48ThReadsFromTheDutThe0x0036ColorPointGXAttribute_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Step 49: TH reads from the DUT the (0x0037) ColorPointGY attribute\n"); - if (ShouldSkip("CC.S.A0037")) { - NextTest(); - return; - } - err = TestStep49ThReadsFromTheDutThe0x0037ColorPointGYAttribute_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Step 50: TH reads from the DUT the (0x0038) ColorPointGIntensity attribute\n"); - if (ShouldSkip("CC.S.A0038")) { - NextTest(); - return; - } - err = TestStep50ThReadsFromTheDutThe0x0038ColorPointGIntensityAttribute_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Step 51: TH reads from the DUT the (0x003a) ColorPointBX attribute\n"); - if (ShouldSkip("CC.S.A003a")) { - NextTest(); - return; - } - err = TestStep51ThReadsFromTheDutThe0x003aColorPointBXAttribute_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Step 52: TH reads from the DUT the (0x003b) ColorPointBY attribute\n"); - if (ShouldSkip("CC.S.A003b")) { - NextTest(); - return; - } - err = TestStep52ThReadsFromTheDutThe0x003bColorPointBYAttribute_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Step 53: TH reads from the DUT the (0x003c) ColorPointBIntensity attribute\n"); - if (ShouldSkip("CC.S.A003c")) { - NextTest(); - return; - } - err = TestStep53ThReadsFromTheDutThe0x003cColorPointBIntensityAttribute_53(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 54; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0x0000CurrentHueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0x0000) CurrentHue attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0x0000) CurrentHue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentHue", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutThe0x0001CurrentSaturationAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the (0x0001) CurrentSaturation attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the (0x0001) CurrentSaturation attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentSaturation", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutThe0x0002RemainingTimeAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRemainingTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the (0x0002) RemainingTime attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the (0x0002) RemainingTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("remainingTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("remainingTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("remainingTime", [value unsignedShortValue], 65534U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThe0x0003CurrentXAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the (0x0003) CurrentX attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the (0x0003) CurrentX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThe0x0004CurrentYAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the (0x0004) CurrentY attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the (0x0004) CurrentY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0x0005DriftCompensationAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDriftCompensationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0x0005) DriftCompensation attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0x0005) DriftCompensation attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("driftCompensation", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("driftCompensation", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("driftCompensation", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutThe0x0006CompensationTextAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCompensationTextWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the (0x0006) CompensationText attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the (0x0006) CompensationText attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("compensationText", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("compensationText", value, 254)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutThe0x0007ColorTemperatureMiredsAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the (0x0007) ColorTemperatureMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the (0x0007) ColorTemperatureMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutThe0x0008ColorModeAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the (0x0008) ColorMode attribute: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the (0x0008) ColorMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutThe0x000fOptionsAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the (0x000f) Options attribute: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the (0x000f) Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("options", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("options", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("options", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutThe0x4000EnhancedCurrentHueAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the (0x4000) EnhancedCurrentHue attribute: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the (0x4000) EnhancedCurrentHue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsFromTheDutThe0x4001EnhancedColorModeAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads from the DUT the (0x4001) EnhancedColorMode attribute: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads from the DUT the (0x4001) EnhancedColorMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedColorMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14thReadsFromTheDutThe0x4002ColorLoopActiveAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14:TH reads from the DUT the (0x4002) ColorLoopActive attribute: Error: %@", err); - } else { - NSLog(@"Step 14:TH reads from the DUT the (0x4002) ColorLoopActive attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopActive", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopActive", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopActive", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15ThReadsFromTheDutThe0x4003ColorLoopDirectionAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: TH reads from the DUT the (0x4003) ColorLoopDirection attribute: Error: %@", err); - } else { - NSLog(@"Step 15: TH reads from the DUT the (0x4003) ColorLoopDirection attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopDirection", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopDirection", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopDirection", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16ThReadsFromTheDutThe0x4004ColorLoopTimeAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH reads from the DUT the (0x4004) ColorLoopTime attribute: Error: %@", err); - } else { - NSLog(@"Step 16: TH reads from the DUT the (0x4004) ColorLoopTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17ThReadsFromTheDutThe0x4005ColorLoopStartEnhancedHueAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH reads from the DUT the (0x4005) ColorLoopStartEnhancedHue attribute: Error: %@", err); - } else { - NSLog(@"Step 17: TH reads from the DUT the (0x4005) ColorLoopStartEnhancedHue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopStartEnhancedHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopStartEnhancedHue", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopStartEnhancedHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18ThReadsFromTheDutThe0x4006ColorLoopStoredEnhancedHueAttributeT_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: TH reads from the DUT the (0x4006) ColorLoopStoredEnhancedHue attributeT: Error: %@", err); - } else { - NSLog(@"Step 18: TH reads from the DUT the (0x4006) ColorLoopStoredEnhancedHue attributeT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopStoredEnhancedHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopStoredEnhancedHue", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopStoredEnhancedHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull FeatureMapValue; - - CHIP_ERROR TestStep18aSavingForComparisionInStep19ReadsFeatureMapAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18a: Saving for comparision in step 19 reads FeatureMap attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 18a: Saving for comparision in step 19 reads FeatureMap attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - FeatureMapValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19ThReadsFromTheDutThe0x400aColorCapabilitiesAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorCapabilitiesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH reads from the DUT the (0x400a) ColorCapabilities attribute: Error: %@", err); - } else { - NSLog(@"Step 19: TH reads from the DUT the (0x400a) ColorCapabilities attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorCapabilities", actualValue, FeatureMapValue)); - } - - VerifyOrReturn(CheckConstraintType("colorCapabilities", "bitmap16", "bitmap16")); - VerifyOrReturn(CheckConstraintMinValue("colorCapabilities", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorCapabilities", [value unsignedShortValue], 31U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20ThReadsFromTheDutThe0x400bColorTempPhysicalMinMiredsAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: TH reads from the DUT the (0x400b) ColorTempPhysicalMinMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 20: TH reads from the DUT the (0x400b) ColorTempPhysicalMinMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMinMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21ThReadsFromTheDutThe0x400cColorTempPhysicalMaxMiredsAttribute_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMaxMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21: TH reads from the DUT the (0x400c) ColorTempPhysicalMaxMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 21: TH reads from the DUT the (0x400c) ColorTempPhysicalMaxMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMaxMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep22ThReadsFromTheDutThe0x400dCoupleColorTempToLevelMinMiredsAttribute_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCoupleColorTempToLevelMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: TH reads from the DUT the (0x400d) CoupleColorTempToLevelMinMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 22: TH reads from the DUT the (0x400d) CoupleColorTempToLevelMinMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("coupleColorTempToLevelMinMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("coupleColorTempToLevelMinMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("coupleColorTempToLevelMinMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23ThReadsFromTheDutThe0x4010StartUpColorTemperatureMiredsAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 23: TH reads from the DUT the (0x4010) StartUpColorTemperatureMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 23: TH reads from the DUT the (0x4010) StartUpColorTemperatureMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpColorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("startUpColorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpColorTemperatureMireds", [value unsignedShortValue], 65279U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24ThReadsFromTheDutThe0x0010NumberOfPrimariesAttribute_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfPrimariesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24: TH reads from the DUT the (0x0010) NumberOfPrimaries attribute: Error: %@", err); - } else { - NSLog(@"Step 24: TH reads from the DUT the (0x0010) NumberOfPrimaries attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("numberOfPrimaries", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("numberOfPrimaries", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfPrimaries", [value unsignedCharValue], 6U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25ThReadsPrimary1XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_25() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep26ThReadsPrimary1YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_26() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep27ThReadsPrimary1IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs1OrMore_27() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep28ThReadsPrimary2XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_28() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep29ThReadsPrimary2YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_29() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep30ThReadsPrimary2IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs2OrMore_30() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep31ThReadsPrimary3XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_31() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep32ThReadsPrimary3YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_32() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep33ThReadsPrimary3IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs3OrMore_33() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep34ThReadsPrimary4XAttributeFromDutVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_34() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep35ThReadsPrimary4YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_35() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep36ThReadsPrimary4IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs4OrMore_36() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep37ThReadsPrimary5XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_37() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep38ThReadsPrimary5YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_38() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep39ThReadsPrimary5IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs5OrMore_39() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep40ThReadsPrimary6XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_40() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep41ThReadsPrimary6YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_41() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep42ThReadsPrimary6IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs6OrMore_42() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep43ThReadsFromTheDutThe0x0030WhitePointXAttribute_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWhitePointXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 43: TH reads from the DUT the (0x0030) WhitePointX attribute: Error: %@", err); - } else { - NSLog(@"Step 43: TH reads from the DUT the (0x0030) WhitePointX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("whitePointX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("whitePointX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("whitePointX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep44ThReadsFromTheDutThe0x0031WhitePointYAttribute_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWhitePointYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 44: TH reads from the DUT the (0x0031) WhitePointY attribute: Error: %@", err); - } else { - NSLog(@"Step 44: TH reads from the DUT the (0x0031) WhitePointY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("whitePointY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("whitePointY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("whitePointY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep45ThReadsFromTheDutThe0x0032ColorPointRXAttribute_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointRXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 45: TH reads from the DUT the (0x0032) ColorPointRX attribute: Error: %@", err); - } else { - NSLog(@"Step 45: TH reads from the DUT the (0x0032) ColorPointRX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointRX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointRX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointRX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep46ThReadsFromTheDutThe0x0033ColorPointRYAttribute_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointRYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 46: TH reads from the DUT the (0x0033) ColorPointRY attribute: Error: %@", err); - } else { - NSLog(@"Step 46: TH reads from the DUT the (0x0033) ColorPointRY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointRY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointRY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointRY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep47ThReadsFromTheDutThe0x0034ColorPointRIntensityAttribute_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointRIntensityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 47: TH reads from the DUT the (0x0034) ColorPointRIntensity attribute: Error: %@", err); - } else { - NSLog(@"Step 47: TH reads from the DUT the (0x0034) ColorPointRIntensity attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("colorPointRIntensity", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointRIntensity", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointRIntensity", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep48ThReadsFromTheDutThe0x0036ColorPointGXAttribute_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointGXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 48: TH reads from the DUT the (0x0036) ColorPointGX attribute: Error: %@", err); - } else { - NSLog(@"Step 48: TH reads from the DUT the (0x0036) ColorPointGX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointGX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointGX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointGX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep49ThReadsFromTheDutThe0x0037ColorPointGYAttribute_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointGYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 49: TH reads from the DUT the (0x0037) ColorPointGY attribute: Error: %@", err); - } else { - NSLog(@"Step 49: TH reads from the DUT the (0x0037) ColorPointGY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointGY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointGY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointGY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep50ThReadsFromTheDutThe0x0038ColorPointGIntensityAttribute_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointGIntensityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 50: TH reads from the DUT the (0x0038) ColorPointGIntensity attribute: Error: %@", err); - } else { - NSLog(@"Step 50: TH reads from the DUT the (0x0038) ColorPointGIntensity attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("colorPointGIntensity", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointGIntensity", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointGIntensity", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep51ThReadsFromTheDutThe0x003aColorPointBXAttribute_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointBXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 51: TH reads from the DUT the (0x003a) ColorPointBX attribute: Error: %@", err); - } else { - NSLog(@"Step 51: TH reads from the DUT the (0x003a) ColorPointBX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointBX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointBX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointBX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep52ThReadsFromTheDutThe0x003bColorPointBYAttribute_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointBYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 52: TH reads from the DUT the (0x003b) ColorPointBY attribute: Error: %@", err); - } else { - NSLog(@"Step 52: TH reads from the DUT the (0x003b) ColorPointBY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointBY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointBY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointBY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep53ThReadsFromTheDutThe0x003cColorPointBIntensityAttribute_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointBIntensityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 53: TH reads from the DUT the (0x003c) ColorPointBIntensity attribute: Error: %@", err); - } else { - NSLog(@"Step 53: TH reads from the DUT the (0x003c) ColorPointBIntensity attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("colorPointBIntensity", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointBIntensity", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointBIntensity", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_3_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_3_2() - : TestCommandBridge("Test_TC_CC_3_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_3_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_3_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_3_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends MoveHue command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsMoveHueCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentHueAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2f: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2fThReadsCurrentHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 2s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait2s_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2g: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2gThReadsCurrentHueAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH sends MoveToHue command to DUT with Hue=60, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToHueCommandToDutWithHue60Direction0x00ShortestDistanceAndTransitionTime0Immediately_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3b: TH sends MoveHue command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsMoveHueCommandToDutWithMoveMode0x03DownAndRate5UnitsS_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentHueAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentHueAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3f: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3fThReadsCurrentHueAttributeFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Wait 2s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait2s_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 3g: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3gThReadsCurrentHueAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 31; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:200U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsMoveHueCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:1U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends MoveHue command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends MoveHue command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentHueAttributeFromDut_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 22U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 68U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 2e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThReadsCurrentHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 79U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 111U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2s_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2gThReadsCurrentHueAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2g: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 79U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 111U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToHueCommandToDutWithHue60Direction0x00ShortestDistanceAndTransitionTime0Immediately_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:60U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=60, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=60, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsMoveHueCommandToDutWithMoveMode0x03DownAndRate5UnitsS_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:3U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends MoveHue command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends MoveHue command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentHueAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 4U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 16U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentHueAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 183U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 247U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_22() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 3e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsCurrentHueAttributeFromDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 140U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 190U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2s_25() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3gThReadsCurrentHueAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3g: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 140U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 190U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_3_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_3_3() - : TestCommandBridge("Test_TC_CC_3_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_3_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_3_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_3_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends StepHue command to DUT with StepMode=0x01 (up), StepSize=60 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsStepHueCommandToDutWithStepMode0x01UpStepSize60AndTransitionTime20020s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentHueAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2eThReadsCurrentHueAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH sends MoveToHue command to DUT with Hue=50, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToHueCommandToDutWithHue50Direction0x00ShortestDistanceAndTransitionTime0Immediately_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3b: TH sends StepHue command to DUT with StepMode=0x03 (down), StepSize=60 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsStepHueCommandToDutWithStepMode0x03DownStepSize60AndTransitionTime20020s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentHueAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentHueAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3e: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3eThReadsCurrentHueAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_24(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 25; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:200U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsStepHueCommandToDutWithStepMode0x01UpStepSize60AndTransitionTime20020s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepHueParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:1U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:60U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends StepHue command to DUT with StepMode=0x01 (up), StepSize=60 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends StepHue command to DUT with StepMode=0x01 (up), StepSize=60 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentHueAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 195U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentHueAttributeFromDut_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait5s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsCurrentHueAttributeFromDut_11() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3aThSendsMoveToHueCommandToDutWithHue50Direction0x00ShortestDistanceAndTransitionTime0Immediately_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:50U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=50, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=50, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsStepHueCommandToDutWithStepMode0x03DownStepSize60AndTransitionTime20020s_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepHueParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:3U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:60U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends StepHue command to DUT with StepMode=0x03 (down), StepSize=60 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends StepHue command to DUT with StepMode=0x03 (down), StepSize=60 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentHueAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 17U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 23U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentHueAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 208U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3eThReadsCurrentHueAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 208U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_4_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_4_1() - : TestCommandBridge("Test_TC_CC_4_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("SaturationConfigValue", 0, UINT8_MAX, &mSaturationConfigValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_4_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToSaturation command to DUT with Saturation=60 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation60AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=300 (30s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime30030s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentSaturationAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentSaturationAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2eThReadsCurrentSaturationAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2f: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2fThReadsCurrentSaturationAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep3aThReadsColorModeAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep3bThReadsEnhancedColorModeAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mSaturationConfigValue; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation60AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:60U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=60 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=60 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime30030s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:120U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=300 (30s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=300 (30s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentSaturationAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentSaturationAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 80U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 115U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsCurrentSaturationAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 102U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 138U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2fThReadsCurrentSaturationAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 102U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 138U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsColorModeAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsEnhancedColorModeAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_4_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_4_2() - : TestCommandBridge("Test_TC_CC_4_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_4_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentSaturationAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentSaturationAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2eThReadsCurrentSaturationAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime0Immediately_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3b: TH sends MoveSaturation command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsMoveSaturationCommandToDutWithMoveMode0x03DownAndRate5UnitsS_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentSaturationAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentSaturationAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3eThReadsCurrentSaturationAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep4bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep4cThReadsCurrentSaturationAttributeFromDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4d: TH sends MoveSaturation command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep4dThSendsMoveSaturationCommandToDutWithMoveMode0x00StopAndRate5UnitsS_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep4eThReadsCurrentSaturationAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Wait 2s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait2s_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4f: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep4fThReadsCurrentSaturationAttributeFromDut_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 5a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep5aThReadsColorModeAttributeFromDut_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 5b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep5bThReadsEnhancedColorModeAttributeFromDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_33(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 34; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:150U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:1U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentSaturationAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentSaturationAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 216U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsCurrentSaturationAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 216U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime0Immediately_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:120U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsMoveSaturationCommandToDutWithMoveMode0x03DownAndRate5UnitsS_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:3U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends MoveSaturation command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends MoveSaturation command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentSaturationAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 59U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 81U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentSaturationAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 5U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 35U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3eThReadsCurrentSaturationAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 10U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:150U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_22() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:1U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 4b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_24() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cThReadsCurrentSaturationAttributeFromDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThSendsMoveSaturationCommandToDutWithMoveMode0x00StopAndRate5UnitsS_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH sends MoveSaturation command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 4d: TH sends MoveSaturation command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsCurrentSaturationAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2s_28() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4fThReadsCurrentSaturationAttributeFromDut_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThReadsColorModeAttributeFromDut_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsEnhancedColorModeAttributeFromDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_4_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_4_3() - : TestCommandBridge("Test_TC_CC_4_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_4_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToSaturation command to DUT with Saturation=200 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation200AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=40 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize40AndTransitionTime20020s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentSaturationAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentSaturationAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2eThReadsCurrentSaturationAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2f: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=20 and TransitionTime=100 (10s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize20AndTransitionTime10010s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2g: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2gThReadsCurrentSaturationAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH sends MoveToSaturation command to DUT with Saturation=50 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation50AndTransitionTime0Immediately_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3b: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=40 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize40AndTransitionTime20020s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3c: H reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cHReadsCurrentSaturationAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentSaturationAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3eThReadsCurrentSaturationAttributeFromDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3f: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=20 and TransitionTime=100 (10 s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep3fThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize20AndTransitionTime10010S_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 3g: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3gThReadsCurrentSaturationAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4b: H reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bHReadsEnhancedColorModeAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 31; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation200AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=200 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=200 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize40AndTransitionTime20020s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:1U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:40U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=40 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=40 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentSaturationAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 187U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 253U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentSaturationAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 204U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsCurrentSaturationAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 204U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize20AndTransitionTime10010s_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:1U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:20U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:100U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=20 and TransitionTime=100 (10s): Error: %@", err); - } else { - NSLog(@"Step 2f: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=20 and TransitionTime=100 (10s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2gThReadsCurrentSaturationAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2g: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 216U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation50AndTransitionTime0Immediately_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=50 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=50 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize40AndTransitionTime20020s_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:3U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:40U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=40 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=40 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cHReadsCurrentSaturationAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: H reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: H reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 25U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 35U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentSaturationAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 8U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 12U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_22() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3eThReadsCurrentSaturationAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 8U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 12U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize20AndTransitionTime10010S_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:3U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:20U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:100U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=20 and TransitionTime=100 (10 s): Error: %@", err); - } else { - NSLog(@"Step 3f: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=20 and TransitionTime=100 (10 s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_25() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3gThReadsCurrentSaturationAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3g: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentSaturation", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bHReadsEnhancedColorModeAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: H reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: H reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_4_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_4_4() - : TestCommandBridge("Test_TC_CC_4_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_4_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToHueAndSaturation command to DUT with Hue=200, Saturation=50 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToHueAndSaturationCommandToDutWithHue200Saturation50AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads CurrentHue attribute from DUT.\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000 && CC.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentHueAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b1: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2b1ThReadsCurrentSaturationAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH sends MoveToHueAndSaturation command to DUT with Hue=160, Saturation=80 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToHueAndSaturationCommandToDutWithHue160Saturation80AndTransitionTime20020s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3b1: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3b1ThReadsCurrentSaturationAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c1: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3c1ThReadsCurrentSaturationAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentHueAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d1: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3d1ThReadsCurrentSaturationAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToHueAndSaturationCommandToDutWithHue200Saturation50AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueAndSaturationParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:200U]; - params.saturation = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueAndSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToHueAndSaturation command to DUT with Hue=200, Saturation=50 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToHueAndSaturation command to DUT with Hue=200, Saturation=50 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsCurrentHueAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2b1ThReadsCurrentSaturationAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b1: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 42U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 58U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToHueAndSaturationCommandToDutWithHue160Saturation80AndTransitionTime20020s_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueAndSaturationParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:160U]; - params.saturation = - [NSNumber numberWithUnsignedChar:80U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueAndSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToHueAndSaturation command to DUT with Hue=160, Saturation=80 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToHueAndSaturation command to DUT with Hue=160, Saturation=80 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsCurrentHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 160U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3b1ThReadsCurrentSaturationAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b1: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 50U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 80U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 135U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 185U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3c1ThReadsCurrentSaturationAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c1: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentSaturation", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentHueAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 135U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 185U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3d1ThReadsCurrentSaturationAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d1: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_5_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_5_1() - : TestCommandBridge("Test_TC_CC_5_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_5_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_5_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_5_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentXAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b1: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004")) { - NextTest(); - return; - } - err = TestStep2b1ThReadsCurrentYAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 200 (20s)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime20020s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentXAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3b: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentYAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentXAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentYAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 5s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait5s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentXAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentYAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep4aThWrites0ToTheOptionsAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4b: TH read Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep4bThReadOptionsAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep4cThSendsOnCommandToDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4d: TH sends a MoveToColor command to the DUT with ColorX = 32768/0x8000 (x=0.5) (purple) ColorY = 19660/0x4CCC (y=0.3) TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4dThSendsAMoveToColorCommandToTheDutWithColorX327680x8000X05PurpleColorY196600x4CCCY03TransitionTime0Immediate_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4e: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4eThReadsCurrentXAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4e: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4eThReadsCurrentYAttributeFromDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4f: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4fThSendsOffCommandToDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4h: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4hThReadsCurrentXAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4h: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4hThReadsCurrentYAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4j: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4jThReadsCurrentXAttributeFromDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4j: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4jThReadsCurrentYAttributeFromDut_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 4k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4i: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4iThReadsCurrentXAttributeFromDut_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4i: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4iThReadsCurrentYAttributeFromDut_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 5a: TH writes 1 to the Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep5aThWrites1ToTheOptionsAttribute_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 5b: TH read Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep5bThReadOptionsAttribute_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 5c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep5cThSendsOnCommandToDut_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 5d: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5dThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 5e: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5eThReadsCurrentXAttributeFromDut_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 5e: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5eThReadsCurrentYAttributeFromDut_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 5f: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5fThSendsOffCommandToDut_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 5g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 5h: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5hThReadsCurrentXAttributeFromDut_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 5h: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5hThReadsCurrentYAttributeFromDut_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Step 5i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Step 5j: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5jThReadsCurrentXAttributeFromDut_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Step 5j: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5jThReadsCurrentYAttributeFromDut_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Step 5k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Step 5l: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5lThReadsCurrentXAttributeFromDut_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Step 5l: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5lThReadsCurrentYAttributeFromDut_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Step 6a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep6aThReadsColorModeAttributeFromDut_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Step 6b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep6bThReadsEnhancedColorModeAttributeFromDut_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_60(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 61; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:32768U]; - params.colorY = - [NSNumber numberWithUnsignedShort:19660U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsCurrentXAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2b1ThReadsCurrentYAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b1: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b1: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 16711U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 22609U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime20020s_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:13107U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsCurrentXAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 13107U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 32768U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentYAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 13107U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 19660U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentXAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentYAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentXAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsCurrentYAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWrites0ToTheOptionsAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadOptionsAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH read Options attribute: Error: %@", err); - } else { - NSLog(@"Step 4b: TH read Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Options", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThSendsOnCommandToDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThSendsAMoveToColorCommandToTheDutWithColorX327680x8000X05PurpleColorY196600x4CCCY03TransitionTime0Immediate_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:32768U]; - params.colorY = - [NSNumber numberWithUnsignedShort:19660U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH sends a MoveToColor command to the DUT with ColorX = 32768/0x8000 (x=0.5) (purple) ColorY = 19660/0x4CCC (y=0.3) TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 4d: TH sends a MoveToColor command to the DUT with ColorX = 32768/0x8000 (x=0.5) (purple) ColorY = 19660/0x4CCC (y=0.3) TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_21() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4eThReadsCurrentXAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsCurrentYAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 16711U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 22609U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThSendsOffCommandToDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4f: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:13107U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 4g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_26() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4hThReadsCurrentXAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentX", actualValue, 32768U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsCurrentYAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentY", actualValue, 19660U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:32768U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 4i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_30() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4jThReadsCurrentXAttributeFromDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentX", actualValue, 32768U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsCurrentYAttributeFromDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentY", actualValue, 19660U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:26214U]; - params.colorY = - [NSNumber numberWithUnsignedShort:32768U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 4k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_34() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4iThReadsCurrentXAttributeFromDut_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 22282U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 30146U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsCurrentYAttributeFromDut_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrites1ToTheOptionsAttribute_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH writes 1 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 5a: TH writes 1 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadOptionsAttribute_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH read Options attribute: Error: %@", err); - } else { - NSLog(@"Step 5b: TH read Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Options", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThSendsOnCommandToDut_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5dThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:32768U]; - params.colorY = - [NSNumber numberWithUnsignedShort:19660U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 5d: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_41() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5eThReadsCurrentXAttributeFromDut_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5e: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5e: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5eThReadsCurrentYAttributeFromDut_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5e: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5e: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 16711U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 22609U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5fThSendsOffCommandToDut_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5f: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5f: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:13107U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 5g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_46() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5hThReadsCurrentXAttributeFromDut_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5h: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5h: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5hThReadsCurrentYAttributeFromDut_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5h: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5h: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:32768U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 5i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_50() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5jThReadsCurrentXAttributeFromDut_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5j: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5j: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentX", actualValue, 13107U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5jThReadsCurrentYAttributeFromDut_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5j: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5j: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentY", actualValue, 13107U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:26214U]; - params.colorY = - [NSNumber numberWithUnsignedShort:32768U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 5k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_54() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5lThReadsCurrentXAttributeFromDut_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5l: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5l: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 22282U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 30146U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5lThReadsCurrentYAttributeFromDut_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5l: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5l: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsColorModeAttributeFromDut_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsEnhancedColorModeAttributeFromDut_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_5_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_5_2() - : TestCommandBridge("Test_TC_CC_5_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_5_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_5_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_5_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 26000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsMoveToColorCommandToDutWithColorX33000ColorY26000TransitionTime0Immediate_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a: TH sends MoveColor command to DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveColorCommandToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentXAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentYAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2c: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentXAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2c: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentYAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2d: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentXAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2d: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentYAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH sends StopMoveStep command to DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C47.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsStopMoveStepCommandToDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentXAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3b: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentYAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThSendsMoveToColorCommandToDutWithColorX33000ColorY26000TransitionTime0Immediate_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:33000U]; - params.colorY = - [NSNumber numberWithUnsignedShort:26000U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 26000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 26000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsMoveColorCommandToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveColorParams alloc] init]; - params.rateX = - [NSNumber numberWithShort:-100]; - params.rateY = - [NSNumber numberWithShort:100]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveColor command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveColor command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsCurrentXAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27200U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 36800U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsCurrentYAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 22900U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 31100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentXAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 26350U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 35650U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsCurrentYAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 23800U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 32200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull CurrentXValue; - - CHIP_ERROR TestStep2dThReadsCurrentXAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 25500U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 34500U)); - { - CurrentXValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull CurrentYValue; - - CHIP_ERROR TestStep2dThReadsCurrentYAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 24650U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 33350U)); - { - CurrentYValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsStopMoveStepCommandToDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStopMoveStepParams alloc] init]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stopMoveStepWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends StopMoveStep command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends StopMoveStep command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentXAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 25500U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 34500U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentYAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 24650U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 33350U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_5_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_5_3() - : TestCommandBridge("Test_TC_CC_5_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_5_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_5_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_5_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 20000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToColorCommandToDutWithColorX33000ColorY20000TransitionTime0Immediate_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH sends StepColor command to DUT, with StepX = -20000, StepY = -6000, TransitionTime = 200 (20s)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsStepColorCommandToDutWithStepX20000StepY6000TransitionTime20020s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentXAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentYAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3c: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentXAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3c: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentYAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait5s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3d: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentXAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3d: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentYAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_18(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 19; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToColorCommandToDutWithColorX33000ColorY20000TransitionTime0Immediate_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:33000U]; - params.colorY = - [NSNumber numberWithUnsignedShort:20000U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 20000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 20000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3aThSendsStepColorCommandToDutWithStepX20000StepY6000TransitionTime20020s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepColorParams alloc] init]; - params.stepX = - [NSNumber numberWithShort:-20000]; - params.stepY = - [NSNumber numberWithShort:-6000]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends StepColor command to DUT, with StepX = -20000, StepY = -6000, TransitionTime = 200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends StepColor command to DUT, with StepX = -20000, StepY = -6000, TransitionTime = 200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsCurrentXAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 13000U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 33000U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentYAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 14000U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 20000U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentXAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11050U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 14950U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentYAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11900U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 16100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentXAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11050U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 14950U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsCurrentYAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11900U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 16100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_6_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_6_1() - : TestCommandBridge("Test_TC_CC_6_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ConfigWait", 0, UINT16_MAX, &mConfigWait); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_6_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_6_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_6_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1a: TH reads ColorTempPhysicalMinMireds attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400b")) { - NextTest(); - return; - } - err = TestStep1aThReadsColorTempPhysicalMinMiredsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1b: TH reads ColorTempPhysicalMaxMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400c")) { - NextTest(); - return; - } - err = TestStep1bThReadsColorTempPhysicalMaxMiredsAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1c: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep1cThReadsColorTemperatureMiredsAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: TH sends MoveToColorTemperature command to DUT with ColorTemperatureMireds=310 and TransitionTime=0 (immediately).\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToColorTemperatureCommandToDutWithColorTemperatureMireds310AndTransitionTime0Immediately_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait100ms_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH sends MoveToColorTemperatur command to DUT with ColorTemperatureMireds=250 and TransitionTime=300 (30s).\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsMoveToColorTemperaturCommandToDutWithColorTemperatureMireds250AndTransitionTime30030s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Wait 10s\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait10s_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2c: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsColorTemperatureMiredsAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait10s_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2d: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsColorTemperatureMiredsAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 10s\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait10s_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2e: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThReadsColorTemperatureMiredsAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 5s\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait5s_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 2f: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThReadsColorTemperatureMiredsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep3aThReadsColorModeAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep3bThReadsEnhancedColorModeAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Turn Off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait to turn Off light\n"); - err = TestWaitToTurnOffLight_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mConfigWait; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorTempPhysicalMinMiredsValue; - - CHIP_ERROR TestStep1aThReadsColorTempPhysicalMinMiredsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads ColorTempPhysicalMinMireds attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads ColorTempPhysicalMinMireds attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMinMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 65279U)); - { - ColorTempPhysicalMinMiredsValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorTempPhysicalMaxMiredsValue; - - CHIP_ERROR TestStep1bThReadsColorTempPhysicalMaxMiredsAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMaxMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMaxMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 65279U)); - { - ColorTempPhysicalMaxMiredsValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsColorTemperatureMiredsAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], ColorTempPhysicalMinMiredsValue)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], ColorTempPhysicalMaxMiredsValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToColorTemperatureCommandToDutWithColorTemperatureMireds310AndTransitionTime0Immediately_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorTemperatureParams alloc] init]; - params.colorTemperatureMireds = - [NSNumber numberWithUnsignedShort:310U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToColorTemperature command to DUT with ColorTemperatureMireds=310 and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToColorTemperature command to DUT with ColorTemperatureMireds=310 and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsMoveToColorTemperaturCommandToDutWithColorTemperatureMireds250AndTransitionTime30030s_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorTemperatureParams alloc] init]; - params.colorTemperatureMireds = - [NSNumber numberWithUnsignedShort:250U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends MoveToColorTemperatur command to DUT with ColorTemperatureMireds=250 and TransitionTime=300 (30s).: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends MoveToColorTemperatur command to DUT with ColorTemperatureMireds=250 and TransitionTime=300 (30s).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsColorTemperatureMiredsAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 246U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 334U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsColorTemperatureMiredsAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 230U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 310U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsColorTemperatureMiredsAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 212U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 288U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2fThReadsColorTemperatureMiredsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 212U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 288U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsColorModeAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsEnhancedColorModeAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn Off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitToTurnOffLight_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigWait.HasValue() ? mConfigWait.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_6_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_6_5() - : TestCommandBridge("Test_TC_CC_6_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ConfigWait", 0, UINT16_MAX, &mConfigWait); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_6_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_6_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_6_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp && CC.S.F04")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 0c: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep0cThReadsColorTemperatureMiredsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 0d: TH reads ColorTempPhysicalMinMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400b")) { - NextTest(); - return; - } - err = TestStep0dThReadsColorTempPhysicalMinMiredsAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 0e: TH reads ColorTempPhysicalMaxMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400c")) { - NextTest(); - return; - } - err = TestStep0eThReadsColorTempPhysicalMaxMiredsAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1: TH reads from the DUT the StartUpColorTemperatureMireds attribute\n"); - if (ShouldSkip("CC.S.A4010 && CC.S.F04")) { - NextTest(); - return; - } - err = TestStep1ThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH writes to StartUpColorTemperatureMireds attribute with value StartUpColorTemperatureMireds\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && CC.S.A4010 && CC.S.F04")) { - NextTest(); - return; - } - err = TestStep2aThWritesToStartUpColorTemperatureMiredsAttributeWithValueStartUpColorTemperatureMireds_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH reads StartUpColorTemperatureMireds attribute from DUT\n"); - if (ShouldSkip("CC.S.A4010 && CC.S.F04")) { - NextTest(); - return; - } - err = TestStep2bThReadsStartUpColorTemperatureMiredsAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2b: Verify that the DUT response contains StartUpColorTemperatureMireds that matches the StartUpColorTemperatureMireds set in Step 2a\n"); - if (ShouldSkip("CC.S.A4010 && CC.S.F04 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2bVerifyThatTheDutResponseContainsStartUpColorTemperatureMiredsThatMatchesTheStartUpColorTemperatureMiredsSetInStep2a_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3a: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep3aRebootTargetDevice_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep3bRebootTargetDeviceDUT_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4a: TH reads from the DUT the StartUpColorTemperatureMireds attribute\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A4010")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4b: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep4bThReadsColorTemperatureMiredsAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep5aThReadsColorModeAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep5bThReadsEnhancedColorModeAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Turn Off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait to turn Off light\n"); - err = TestWaitToTurnOffLight_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mConfigWait; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0cThReadsColorTemperatureMiredsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0c: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 0c: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0dThReadsColorTempPhysicalMinMiredsAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0d: TH reads ColorTempPhysicalMinMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 0d: TH reads ColorTempPhysicalMinMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMinMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0eThReadsColorTempPhysicalMaxMiredsAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMaxMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0e: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 0e: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMaxMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpColorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("startUpColorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpColorTemperatureMireds", [value unsignedShortValue], 65279U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThWritesToStartUpColorTemperatureMiredsAttributeWithValueStartUpColorTemperatureMireds_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nullable StartUpColorTemperatureMiredsValue; - - CHIP_ERROR TestStep2bThReadsStartUpColorTemperatureMiredsAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads StartUpColorTemperatureMireds attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads StartUpColorTemperatureMireds attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpColorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("startUpColorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpColorTemperatureMireds", [value unsignedShortValue], 65279U)); - } - { - StartUpColorTemperatureMiredsValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bVerifyThatTheDutResponseContainsStartUpColorTemperatureMiredsThatMatchesTheStartUpColorTemperatureMiredsSetInStep2a_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3aRebootTargetDevice_10() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep3bRebootTargetDeviceDUT_11() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (StartUpColorTemperatureMiredsValue == nil) { - VerifyOrReturn(CheckValueNull("StartUpColorTemperatureMireds", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("StartUpColorTemperatureMireds", actualValue)); - VerifyOrReturn(CheckValue("StartUpColorTemperatureMireds", actualValue, StartUpColorTemperatureMiredsValue)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsColorTemperatureMiredsAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorTemperatureMireds", actualValue, StartUpColorTemperatureMiredsValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThReadsColorModeAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsEnhancedColorModeAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn Off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitToTurnOffLight_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigWait.HasValue() ? mConfigWait.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_7_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_7_3() - : TestCommandBridge("Test_TC_CC_7_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_7_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_7_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_7_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=6000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue6000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends EnhancedStepHue command to DUT with StepMode=0x01 (up), StepSize=6000 and TransitionTime=300 (30s).\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C42.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsEnhancedStepHueCommandToDutWithStepMode0x01UpStepSize6000AndTransitionTime30030s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsEnhancedCurrentHueAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait5s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2f: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=12000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep5aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue12000Direction0x00ShortestDistanceAndTransitionTime0Immediately_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait100ms_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 (down), StepSize=6000 and TransitionTime=300 (30s)\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C42.Rsp")) { - NextTest(); - return; - } - err = TestStep5bThSendsEnhancedStepHueCommandToDutWithStepMode0x03DownStepSize6000AndTransitionTime30030s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5c: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep5cThReadsEnhancedCurrentHueAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 2d: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 2e: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Wait 5s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait5s_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 2f: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 6a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep6aThReadsColorModeAttributeFromDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 6b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep6bThReadsEnhancedColorModeAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Turn Off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_28(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 29; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue6000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:6000U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=6000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=6000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsEnhancedStepHueCommandToDutWithStepMode0x01UpStepSize6000AndTransitionTime30030s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedStepHueParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:1U]; - params.stepSize = - [NSNumber numberWithUnsignedShort:6000U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedStepHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends EnhancedStepHue command to DUT with StepMode=0x01 (up), StepSize=6000 and TransitionTime=300 (30s).: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends EnhancedStepHue command to DUT with StepMode=0x01 (up), StepSize=6000 and TransitionTime=300 (30s).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsEnhancedCurrentHueAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 6800U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 9200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 8500U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 11500U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 10200U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 13800U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 10200U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 13800U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue12000Direction0x00ShortestDistanceAndTransitionTime0Immediately_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:12000U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=12000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"Step 5a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=12000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bThSendsEnhancedStepHueCommandToDutWithStepMode0x03DownStepSize6000AndTransitionTime30030s_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedStepHueParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:3U]; - params.stepSize = - [NSNumber numberWithUnsignedShort:6000U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedStepHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 (down), StepSize=6000 and TransitionTime=300 (30s): Error: %@", err); - } else { - NSLog(@"Step 5b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 (down), StepSize=6000 and TransitionTime=300 (30s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5cThReadsEnhancedCurrentHueAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 8500U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 11500U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 6800U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 9200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_21() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 5100U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 6900U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_23() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 5100U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 6900U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsColorModeAttributeFromDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsEnhancedColorModeAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn Off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_7_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_7_4() - : TestCommandBridge("Test_TC_CC_7_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_7_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_7_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_7_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=20000, Saturation=50 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C43.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue20000Saturation50AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep2bThReadsEnhancedCurrentHueAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestThReadsCurrentSaturationAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=16000, Saturation=80 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C43.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue16000Saturation80AndTransitionTime20020s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep3bThReadsEnhancedCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3b: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentSaturationAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep3cThReadsEnhancedCurrentHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentSaturationAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 5s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait5s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep3dThReadsEnhancedCurrentHueAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentSaturationAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Turn Off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue20000Saturation50AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueAndSaturationParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:20000U]; - params.saturation = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueAndSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=20000, Saturation=50 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=20000, Saturation=50 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsEnhancedCurrentHueAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 17000U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 23000U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThReadsCurrentSaturationAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 42U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 58U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue16000Saturation80AndTransitionTime20020s_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueAndSaturationParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:16000U]; - params.saturation = - [NSNumber numberWithUnsignedChar:80U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueAndSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=16000, Saturation=80 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=16000, Saturation=80 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsEnhancedCurrentHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 16000U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 20000U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentSaturationAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 50U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 80U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsEnhancedCurrentHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 13600U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 18400U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentSaturationAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsEnhancedCurrentHueAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, 16000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsCurrentSaturationAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentSaturation", actualValue, 80U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn Off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestColorControl_9_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestColorControl_9_1() - : TestCommandBridge("TestColorControl_9_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestColorControl_9_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestColorControl_9_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestColorControl_9_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : TH writes 0 to the Options attribute\n"); - err = TestThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : TH sends On command to DUT\n"); - err = TestThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - err = TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for 100ms\n"); - err = TestWaitFor100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read ColorLoopDirection attribute from DUT\n"); - err = TestReadColorLoopDirectionAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x4 (UpdateTime) and Time attribute to 5 (5s for one loop) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x4UpdateTimeAndTimeAttributeTo55sForOneLoopToDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read ColorLoopTime attribute from DUT\n"); - err = TestReadColorLoopTimeAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x8 (UpdateStartHue) and StartHue attribute to 0x00A0 to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x8UpdateStartHueAndStartHueAttributeTo0x00A0ToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStartEnhancedHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait for 5S\n"); - err = TestWaitFor5s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Saving value for comparison in step 8d read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisonInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait for 5S\n"); - err = TestWaitFor5s_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Saving value for comparison in step 6c read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisonInStep6cReadColorLoopStoredEnhancedHueAttributeFromDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Read ColorLoopDirection attribute from DUT\n"); - err = TestReadColorLoopDirectionAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Wait for 5S\n"); - err = TestWaitFor5s_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Saving value for comparision in step 8d read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisionInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Wait for 5S\n"); - err = TestWaitFor5s_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Saving value for comparision in step 9c read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisionInStep9cReadColorLoopStoredEnhancedHueAttributeFromDut_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - err = TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Wait 10ms\n"); - err = TestWait10ms_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Read ColorLoopDirection attribute from DUT\n"); - err = TestReadColorLoopDirectionAttributeFromDut_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Wait for 5S\n"); - err = TestWaitFor5s_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Saving value for comparision in step 12d read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisionInStep12dReadColorLoopStartEnhancedHueAttributeFromDut_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Wait for 5S\n"); - err = TestWaitFor5s_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Saving value for comparision in step 13c read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionInStep13cReadColorLoopStoredEnhancedHueAttributeFromDut_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Read ColorLoopDirection attribute from DUT\n"); - err = TestReadColorLoopDirectionAttributeFromDut_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Wait for 5S\n"); - err = TestWaitFor5s_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Saving value for comparision in step 15d read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisionInStep15dReadColorLoopStartEnhancedHueAttributeFromDut_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Wait for 5S\n"); - err = TestWaitFor5s_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Saving value for comparision in step 16b read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionInStep16bReadColorLoopStoredEnhancedHueAttributeFromDut_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Turn Off light for color control tests\n"); - err = TestTurnOffLightForColorControlTests_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Check on/off attribute value is false after off command\n"); - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_71(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(400)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 72; - - chip::Optional mNodeId; - chip::Optional mTimeout; - chip::Optional mCluster; - chip::Optional mEndpoint; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:16384U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x4UpdateTimeAndTimeAttributeTo55sForOneLoopToDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:4U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:5U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x4 (UpdateTime) and Time attribute to 5 (5s for one loop) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x4 (UpdateTime) and Time attribute to 5 (5s for one loop) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopTimeAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopTime", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x8UpdateStartHueAndStartHueAttributeTo0x00A0ToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:8U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:160U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x8 (UpdateStartHue) and StartHue attribute to 0x00A0 to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x8 (UpdateStartHue) and StartHue attribute to 0x00A0 to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStartEnhancedHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStartEnhancedHue", actualValue, 160U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:1U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueStep5d; - - CHIP_ERROR TestSavingValueForComparisonInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparison in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparison in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueStep5d = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep5d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep5d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep6c; - - CHIP_ERROR TestSavingValueForComparisonInStep6cReadColorLoopStoredEnhancedHueAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparison in step 6c read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparison in step 6c read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueStep6c = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep6c)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:1U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:1U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_30() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueStep8d; - - CHIP_ERROR TestSavingValueForComparisionInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueStep8d = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep8d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_33() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep8d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep9c; - - CHIP_ERROR TestSavingValueForComparisionInStep9cReadColorLoopStoredEnhancedHueAttributeFromDut_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 9c read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 9c read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueStep9c = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep9c)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:16384U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10ms_40() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:2U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_47() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueStep12d; - - CHIP_ERROR TestSavingValueForComparisionInStep12dReadColorLoopStartEnhancedHueAttributeFromDut_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 12d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 12d read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueStep12d = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep12d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_50() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep12d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep13c; - - CHIP_ERROR TestSavingValueForComparisionInStep13cReadColorLoopStoredEnhancedHueAttributeFromDut_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 13c read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 13c read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueStep13c = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep13c)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:1U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:2U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_61() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueStep15d; - - CHIP_ERROR TestSavingValueForComparisionInStep15dReadColorLoopStartEnhancedHueAttributeFromDut_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 15d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 15d read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueStep15d = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep15d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_64() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep15d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep16b; - - CHIP_ERROR TestSavingValueForComparisionInStep16bReadColorLoopStoredEnhancedHueAttributeFromDut_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 16b read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 16b read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueStep16b = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep16b)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightForColorControlTests_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light for color control tests: Error: %@", err); - } else { - NSLog(@"Turn Off light for color control tests: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestColorControl_9_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestColorControl_9_2() - : TestCommandBridge("TestColorControl_9_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestColorControl_9_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestColorControl_9_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestColorControl_9_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : TH writes 0 to the Options attribute\n"); - err = TestThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : TH sends On command to DUT\n"); - err = TestThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - err = TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for 100ms\n"); - err = TestWaitFor100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0xF, Action attribute to 0x0 (De-activate), Direction attribute to 0x0 (decrement hue), Time attribute to 30, and StartHue attribute to 0x00A0 to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0xFActionAttributeTo0x0DeActivateDirectionAttributeTo0x0DecrementHueTimeAttributeTo30AndStartHueAttributeTo0x00A0ToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read ColorLoopDirection attribute from DUT.\n"); - err = TestReadColorLoopDirectionAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read ColorLoopTime attribute from DUT.\n"); - err = TestReadColorLoopTimeAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read ColorLoopStartEnhancedHue attribute from DUT.\n"); - err = TestReadColorLoopStartEnhancedHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read ColorLoopActive attribute from DUT.\n"); - err = TestReadColorLoopActiveAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for 5S\n"); - err = TestWaitFor5s_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait for 5S\n"); - err = TestWaitFor5s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read ColorLoopDirection attribute from DUT.\n"); - err = TestReadColorLoopDirectionAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait for 5S\n"); - err = TestWaitFor5s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Wait for 5S\n"); - err = TestWaitFor5s_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Saving value for comparision read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionReadColorLoopStoredEnhancedHueAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Read EnhancedCurrentHue attribute from DUT.\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Turn off light for color control tests\n"); - err = TestTurnOffLightForColorControlTests_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(400)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 31; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:16384U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0xFActionAttributeTo0x0DeActivateDirectionAttributeTo0x0DecrementHueTimeAttributeTo30AndStartHueAttributeTo0x00A0ToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:15U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:5U]; - params.startHue = - [NSNumber numberWithUnsignedShort:160U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0xF, Action attribute to 0x0 (De-activate), Direction attribute to 0x0 (decrement hue), Time attribute to 30, and StartHue attribute to 0x00A0 to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0xF, Action attribute to 0x0 (De-activate), Direction attribute to 0x0 (decrement hue), Time attribute to 30, and StartHue attribute to 0x00A0 to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopTimeAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopTime attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopTime attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopTime", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStartEnhancedHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStartEnhancedHue", actualValue, 160U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:1U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueValue; - - CHIP_ERROR TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:1U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueValue2; - - CHIP_ERROR TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueValue2 = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue2)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_23() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue2)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueValue3; - - CHIP_ERROR TestSavingValueForComparisionReadColorLoopStoredEnhancedHueAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueValue3 = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueValue3)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightForColorControlTests_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light for color control tests: Error: %@", err); - } else { - NSLog(@"Turn off light for color control tests: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CDOCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CDOCONC_1_1() - : TestCommandBridge("Test_TC_CDOCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CDOCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CDOCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CDOCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given CDOCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenCdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given CDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenCdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given CDOCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenCdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given CDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenCdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given CDOCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CDOCONC.S.F02 && CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenCdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given CDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F02 && !CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenCdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given CDOCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CDOCONC.S.F03 && CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenCdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given CDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F03 && !CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenCdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given CDOCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CDOCONC.S.F04 && CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenCdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given CDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F04 && !CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3kGivenCdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given CDOCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CDOCONC.S.F05 && CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenCdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given CDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F05 && !CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenCdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip(" !PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.A0007 && CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CDOCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !CDOCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCdoconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CDOCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !CDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCdoconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !CDOCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !CDOCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when CDOCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !CDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCdoconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenCdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given CDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given CDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenCdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given CDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given CDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenCdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given CDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given CDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenCdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given CDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given CDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenCdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given CDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given CDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenCdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given CDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given CDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenCdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given CDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given CDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenCdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given CDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given CDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenCdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given CDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given CDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenCdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given CDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given CDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenCdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given CDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given CDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenCdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given CDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given CDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCdoconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CDOCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CDOCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCdoconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CDOCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CDOCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCdoconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CDOCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CDOCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CDOCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CDOCONC_2_1() - : TestCommandBridge("Test_TC_CDOCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CDOCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CDOCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CDOCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CMOCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CMOCONC_1_1() - : TestCommandBridge("Test_TC_CMOCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CMOCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CMOCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CMOCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given CMOCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenCmoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given CMOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenCmoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given CMOCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenCmoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given CMOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenCmoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given CMOCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CMOCONC.S.F02 && CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenCmoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given CMOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F02 && !CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenCmoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given CMOCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CMOCONC.S.F03 && CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenCmoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given CMOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F03 && !CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenCmoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given CMOCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CMOCONC.S.F04 && CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenCmoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given CMOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F04 && !CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3kGivenCmoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given CMOCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CMOCONC.S.F05 && CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenCmoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given CMOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F05 && !CMOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3mGivenCmoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.A0007 && CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CMOCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !CMOCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCmoconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CMOCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !CMOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCmoconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !CMOCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !CMOCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when CMOCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !CMOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCmoconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenCmoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given CMOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given CMOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenCmoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given CMOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given CMOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenCmoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given CMOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given CMOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenCmoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given CMOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given CMOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenCmoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given CMOCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given CMOCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenCmoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given CMOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given CMOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenCmoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given CMOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given CMOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenCmoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given CMOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given CMOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenCmoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given CMOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given CMOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenCmoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given CMOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given CMOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenCmoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given CMOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given CMOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenCmoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given CMOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given CMOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCmoconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CMOCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CMOCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCmoconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CMOCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CMOCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCmoconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CMOCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CMOCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CMOCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CMOCONC_2_1() - : TestCommandBridge("Test_TC_CMOCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CMOCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CMOCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CMOCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FLDCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FLDCONC_1_1() - : TestCommandBridge("Test_TC_FLDCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FLDCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLDCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLDCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given FLDCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenFldconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given FLDCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenFldconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given FLDCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenFldconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given FLDCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenFldconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given FLDCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FLDCONC.S.F02 && FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenFldconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given FLDCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F02 && !FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenFldconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given FLDCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("FLDCONC.S.F03 && FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenFldconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given FLDCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F03 && !FLDCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3iGivenFldconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given FLDCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("FLDCONC.S.F04 && FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenFldconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given FLDCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F04 && !FLDCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenFldconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given FLDCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("FLDCONC.S.F05 && FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenFldconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given FLDCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F05 && !FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenFldconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.A0007 && FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when FLDCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !FLDCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenFldconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when FLDCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !FLDCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenFldconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !FLDCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !FLDCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when FLDCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !FLDCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenFldconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenFldconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given FLDCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given FLDCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenFldconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given FLDCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given FLDCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenFldconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given FLDCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given FLDCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenFldconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given FLDCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given FLDCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenFldconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given FLDCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given FLDCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenFldconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given FLDCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given FLDCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenFldconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given FLDCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given FLDCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenFldconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given FLDCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given FLDCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenFldconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given FLDCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given FLDCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenFldconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given FLDCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given FLDCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenFldconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given FLDCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given FLDCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenFldconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given FLDCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given FLDCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenFldconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when FLDCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when FLDCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenFldconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when FLDCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when FLDCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenFldconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when FLDCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when FLDCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FLDCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FLDCONC_2_1() - : TestCommandBridge("Test_TC_FLDCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FLDCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLDCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLDCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_NDOCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_NDOCONC_1_1() - : TestCommandBridge("Test_TC_NDOCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_NDOCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_NDOCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_NDOCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given NDOCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenNdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given NDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenNdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given NDOCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("NDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenNdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given NDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenNdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given NDOCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("NDOCONC.S.F02 && NDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenNdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given NDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F02 && !NDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3gGivenNdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given NDOCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("NDOCONC.S.F03 && NDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenNdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given NDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F03 && !NDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3iGivenNdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given NDOCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("NDOCONC.S.F04 && NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenNdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given NDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F04 && NDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenNdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given NDOCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("NDOCONC.S.F05 && NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenNdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given NDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F05 && !NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenNdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.A0007 && NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when NDOCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !NDOCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenNdoconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when NDOCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !NDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenNdoconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !NDOCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: TH reads that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !NDOCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iThReadsThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when NDOCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !NDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenNdoconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenNdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given NDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given NDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenNdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given NDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given NDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenNdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given NDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given NDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenNdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given NDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given NDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenNdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given NDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given NDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenNdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given NDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given NDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenNdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given NDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given NDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenNdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given NDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given NDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenNdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given NDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given NDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenNdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given NDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given NDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenNdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given NDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given NDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenNdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given NDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given NDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenNdoconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when NDOCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when NDOCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenNdoconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when NDOCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when NDOCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenNdoconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when NDOCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when NDOCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_NDOCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_NDOCONC_2_1() - : TestCommandBridge("Test_TC_NDOCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_NDOCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_NDOCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_NDOCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OZCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OZCONC_1_1() - : TestCommandBridge("Test_TC_OZCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OZCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OZCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OZCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given OZCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenOzconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given OZCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenOzconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given OZCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenOzconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given OZCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenOzconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given OZCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OZCONC.S.F02 && OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenOzconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given OZCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F02 && !OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenOzconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given OZCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("OZCONC.S.F03 && OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenOzconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given OZCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F03 && !OZCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3iGivenOzconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given OZCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("OZCONC.S.F04 && OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenOzconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given OZCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F04 && !OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3kGivenOzconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given OZCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("OZCONC.S.F05 && OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenOzconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given OZCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F05 && !OZCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3mGivenOzconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("OZCONC.S.A0007 && OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when OZCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !OZCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenOzconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when OZCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !OZCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenOzconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("OZCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !OZCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("OZCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !OZCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when OZCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !OZCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenOzconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenOzconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given OZCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given OZCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenOzconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given OZCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given OZCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenOzconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given OZCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given OZCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenOzconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given OZCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given OZCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenOzconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given OZCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given OZCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenOzconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given OZCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given OZCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenOzconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given OZCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given OZCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenOzconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given OZCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given OZCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenOzconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given OZCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given OZCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenOzconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given OZCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given OZCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenOzconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given OZCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given OZCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenOzconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given OZCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given OZCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenOzconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when OZCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when OZCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenOzconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when OZCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when OZCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenOzconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when OZCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when OZCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OZCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OZCONC_2_1() - : TestCommandBridge("Test_TC_OZCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OZCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OZCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OZCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("OZCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("OZCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("OZCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("OZCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("OZCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMHCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMHCONC_1_1() - : TestCommandBridge("Test_TC_PMHCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMHCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMHCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMHCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PMHCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPmhconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PMHCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenPmhconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PMHCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenPmhconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PMHCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenPmhconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PMHCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMHCONC.S.F02 && PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenPmhconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PMHCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F02 && !PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenPmhconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PMHCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMHCONC.S.F03 && PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenPmhconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given PMHCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F03 && !PMHCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3iGivenPmhconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given PMHCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMHCONC.S.F04 && PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenPmhconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given PMHCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F04 && PMHCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenPmhconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given PMHCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMHCONC.S.F05 && PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenPmhconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given PMHCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F05 && !PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenPmhconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.A0007 && PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMHCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !PMHCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmhconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMHCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !PMHCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmhconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !PMHCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !PMHCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when PMHCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !PMHCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmhconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPmhconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PMHCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PMHCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPmhconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PMHCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PMHCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPmhconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PMHCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PMHCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenPmhconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given PMHCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given PMHCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenPmhconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given PMHCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given PMHCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenPmhconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given PMHCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given PMHCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenPmhconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given PMHCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given PMHCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenPmhconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given PMHCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given PMHCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenPmhconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given PMHCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given PMHCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenPmhconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given PMHCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given PMHCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenPmhconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given PMHCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given PMHCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenPmhconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given PMHCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given PMHCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmhconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMHCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMHCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmhconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMHCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMHCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmhconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMHCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMHCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMHCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMHCONC_2_1() - : TestCommandBridge("Test_TC_PMHCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMHCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMHCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMHCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMICONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMICONC_1_1() - : TestCommandBridge("Test_TC_PMICONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMICONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMICONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMICONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PMICONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPmiconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PMICONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenPmiconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PMICONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenPmiconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PMICONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenPmiconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PMICONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMICONC.S.F02 && PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenPmiconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PMICONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F02 && !PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenPmiconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PMICONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMICONC.S.F03 && PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenPmiconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given PMICONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F03 && !PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenPmiconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given PMICONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMICONC.S.F04 && PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenPmiconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given PMICONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F04 && !PMICONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenPmiconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given PMICONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMICONC.S.F05 && PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenPmiconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given PMICONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F05 && !PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenPmiconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("PMICONC.S.A0007 && PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMICONC.S.A0007 is not set\n"); - if (ShouldSkip(" !PMICONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmiconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMICONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !PMICONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmiconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMICONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !PMICONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMICONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !PMICONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when PMICONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !PMICONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmiconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPmiconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PMICONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PMICONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPmiconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PMICONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PMICONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPmiconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PMICONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PMICONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenPmiconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given PMICONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given PMICONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenPmiconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given PMICONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given PMICONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenPmiconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given PMICONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given PMICONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenPmiconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given PMICONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given PMICONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenPmiconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given PMICONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given PMICONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenPmiconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given PMICONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given PMICONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenPmiconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given PMICONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given PMICONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenPmiconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given PMICONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given PMICONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenPmiconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given PMICONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given PMICONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmiconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMICONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMICONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmiconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMICONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMICONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmiconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMICONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMICONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMICONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMICONC_2_1() - : TestCommandBridge("Test_TC_PMICONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMICONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMICONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMICONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMICONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMICONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("PMICONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("PMICONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("PMICONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMKCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMKCONC_1_1() - : TestCommandBridge("Test_TC_PMKCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMKCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMKCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMKCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PMKCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPmkconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PMKCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenPmkconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PMKCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenPmkconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PMKCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenPmkconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PMKCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMKCONC.S.F02 && PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenPmkconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PMKCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F02 && !PMKCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3gGivenPmkconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PMKCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMKCONC.S.F03 && PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenPmkconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given PMKCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F03 && !PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenPmkconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given PMKCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMKCONC.S.F04 && PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenPmkconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given PMKCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F04 && !PMKCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenPmkconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given PMKCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMKCONC.S.F05 && PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenPmkconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given PMKCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F05 && !PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenPmkconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.A0007 && PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMKCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !PMKCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmkconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMKCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !PMKCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmkconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !PMKCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !PMKCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when PMKCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !PMKCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmkconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPmkconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PMKCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PMKCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPmkconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PMKCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PMKCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPmkconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PMKCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PMKCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenPmkconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given PMKCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given PMKCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenPmkconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given PMKCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given PMKCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenPmkconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given PMKCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given PMKCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenPmkconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given PMKCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given PMKCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenPmkconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given PMKCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given PMKCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenPmkconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given PMKCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given PMKCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenPmkconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given PMKCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given PMKCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenPmkconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given PMKCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given PMKCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenPmkconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given PMKCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given PMKCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmkconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMKCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMKCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmkconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMKCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMKCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmkconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMKCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMKCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMKCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMKCONC_2_1() - : TestCommandBridge("Test_TC_PMKCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMKCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMKCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMKCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RNCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RNCONC_1_1() - : TestCommandBridge("Test_TC_RNCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RNCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RNCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RNCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given RNCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenRnconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given RNCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenRnconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given RNCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenRnconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given RNCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenRnconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given RNCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("RNCONC.S.F02 && RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenRnconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given RNCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F02 && !RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenRnconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given RNCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("RNCONC.S.F03 && RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenRnconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given RNCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F03 && !RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenRnconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given RNCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("RNCONC.S.F04 && RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenRnconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given RNCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F04 && RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3kGivenRnconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given RNCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("RNCONC.S.F05 && RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenRnconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given RNCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F05 && !RNCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3mGivenRnconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("RNCONC.S.A0007 && RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when RNCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !RNCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenRnconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when RNCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !RNCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenRnconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("RNCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !RNCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("RNCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !RNCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when RNCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !RNCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenRnconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenRnconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given RNCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given RNCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenRnconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given RNCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given RNCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenRnconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given RNCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given RNCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenRnconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given RNCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given RNCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenRnconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given RNCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given RNCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenRnconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given RNCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given RNCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenRnconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given RNCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given RNCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenRnconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given RNCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given RNCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenRnconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given RNCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given RNCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenRnconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given RNCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given RNCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenRnconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given RNCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given RNCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenRnconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given RNCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given RNCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenRnconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when RNCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when RNCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenRnconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when RNCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when RNCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenRnconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when RNCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when RNCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RNCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RNCONC_2_1() - : TestCommandBridge("Test_TC_RNCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RNCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RNCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RNCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("RNCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: H reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7HReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("RNCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("RNCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("RNCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("RNCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7HReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: H reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: H reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TVOCCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TVOCCONC_1_1() - : TestCommandBridge("Test_TC_TVOCCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TVOCCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TVOCCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TVOCCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given TVOCCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenTvocconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given TVOCCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenTvocconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given TVOCCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenTvocconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given TVOCCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenTvocconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given TVOCCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TVOCCONC.S.F02 && TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenTvocconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given TVOCCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F02 && !TVOCCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3gGivenTvocconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given TVOCCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("TVOCCONC.S.F03 && TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenTvocconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given TVOCCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F03 && !TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenTvocconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given TVOCCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("TVOCCONC.S.F04 && TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenTvocconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given TVOCCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F04 && !TVOCCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenTvocconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given TVOCCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("TVOCCONC.S.F05 && TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenTvocconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given TVOCCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F05 && !TVOCCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3mGivenTvocconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.A0007 && TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when TVOCCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenTvocconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when TVOCCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenTvocconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when TVOCCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenTvocconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenTvocconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given TVOCCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given TVOCCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenTvocconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given TVOCCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given TVOCCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenTvocconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given TVOCCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given TVOCCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenTvocconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given TVOCCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given TVOCCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenTvocconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given TVOCCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given TVOCCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenTvocconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given TVOCCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given TVOCCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenTvocconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given TVOCCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given TVOCCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenTvocconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given TVOCCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given TVOCCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenTvocconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given TVOCCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given TVOCCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenTvocconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given TVOCCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given TVOCCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenTvocconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given TVOCCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given TVOCCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenTvocconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given TVOCCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given TVOCCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenTvocconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when TVOCCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when TVOCCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenTvocconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when TVOCCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when TVOCCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenTvocconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when TVOCCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when TVOCCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TVOCCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TVOCCONC_2_1() - : TestCommandBridge("Test_TC_TVOCCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TVOCCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TVOCCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TVOCCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OPCREDS_1_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OPCREDS_1_2() - : TestCommandBridge("Test_TC_OPCREDS_1_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OPCREDS_1_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OPCREDS_1_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OPCREDS_1_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BINFO_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BINFO_1_1() - : TestCommandBridge("Test_TC_BINFO_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BINFO_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BINFO_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BINFO_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); - err = TestStep3ThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(ManufacturingDate) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000b")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeManufacturingDateInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads optional attribute(PartNumber) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000c")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributePartNumberInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads optional attribute(ProductURL) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000d")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeProductURLInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: TH reads optional attribute(ProductLabel) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000e")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeProductLabelInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: TH reads optional attribute(SerialNumber) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000f")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributeSerialNumberInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: TH reads optional attribute(LocalConfigDisabled) in attributeList\n"); - if (ShouldSkip("BINFO.S.A0010")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributeLocalConfigDisabledInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4h: TH reads optional attribute(Reachable) in attributeList\n"); - if (ShouldSkip("BINFO.S.A0011")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributeReachableInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4i: TH reads optional attribute(UniqueID) in attributeList\n"); - if (ShouldSkip("BINFO.S.A0012")) { - NextTest(); - return; - } - err = TestStep4iThReadsOptionalAttributeUniqueIDInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4j: TH reads optional attribute(ProductAppearance) in attributeList\n"); - if (ShouldSkip("BINFO.S.A0014")) { - NextTest(); - return; - } - err = TestStep4jThReadsOptionalAttributeProductAppearanceInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip(" !BINFO.S.E00 && !BINFO.S.E01 && !BINFO.S.E02 && !BINFO.S.A0011 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5b: TH reads BINFO.S.E00(StartUp) event in EventList\n"); - if (ShouldSkip("BINFO.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5c: TH reads BINFO.S.E01(ShutDown) event in EventList\n"); - if (ShouldSkip("BINFO.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5d: TH reads BINFO.S.E02(Leave) event in EventList\n"); - if (ShouldSkip("BINFO.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5e: TH reads (ReachableChanged) event in EventList\n"); - if (ShouldSkip("BINFO.S.A0011 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeManufacturingDateInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(ManufacturingDate) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(ManufacturingDate) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributePartNumberInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(PartNumber) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(PartNumber) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeProductURLInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(ProductURL) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(ProductURL) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeProductLabelInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(ProductLabel) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(ProductLabel) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributeSerialNumberInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(SerialNumber) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(SerialNumber) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributeLocalConfigDisabledInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(LocalConfigDisabled) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(LocalConfigDisabled) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributeReachableInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(Reachable) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(Reachable) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsOptionalAttributeUniqueIDInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads optional attribute(UniqueID) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads optional attribute(UniqueID) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsOptionalAttributeProductAppearanceInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads optional attribute(ProductAppearance) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads optional attribute(ProductAppearance) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CNET_1_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CNET_1_3() - : TestCommandBridge("Test_TC_CNET_1_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CNET_1_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CNET_1_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CNET_1_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute\n"); - if (ShouldSkip(" !CNET.S.F00 && !CNET.S.F01 && !CNET.S.F02 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: TH reads the global attribute: FeatureMap when CNET.S.F00 is set\n"); - if (ShouldSkip("CNET.S.F00")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheGlobalAttributeFeatureMapWhenCnetsf00IsSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: TH reads the global attribute: FeatureMap when CNET.S.F01 is set\n"); - if (ShouldSkip("CNET.S.F01")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheGlobalAttributeFeatureMapWhenCnetsf01IsSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: TH reads the global attribute: FeatureMap when CNET.S.F02 is set\n"); - if (ShouldSkip("CNET.S.F02")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheGlobalAttributeFeatureMapWhenCnetsf02IsSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads mandatory attributes in AttributeList if CNET.S.F00(WI)/CNET.S.F01(TH)/CNET.S.F02(ET) is true\n"); - if (ShouldSkip("CNET.S.F00 || CNET.S.F01 || CNET.S.F02")) { - NextTest(); - return; - } - err = TestStep4cThReadsMandatoryAttributesInAttributeListIfCnetsf00wiCnetsf01thCnetsf02etIsTrue_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4d: TH reads the feature dependent attribute(ScanMaxTimeSeconds): AttributeList\n"); - if (ShouldSkip("CNET.S.F00 || CNET.S.F01")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheFeatureDependentAttributeScanMaxTimeSecondsAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4e: TH reads the feature dependent attribute(ConnectMaxTimeSeconds) in AttributeList\n"); - if (ShouldSkip("CNET.S.F00 || CNET.S.F01")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheFeatureDependentAttributeConnectMaxTimeSecondsInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4f: TH reads WIFI related attribute (SupportedWiFiBands) in AttributeList\n"); - if (ShouldSkip("CNET.S.F00")) { - NextTest(); - return; - } - err = TestStep4fThReadsWifiRelatedAttributeSupportedWiFiBandsInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4g: TH reads Thread related attribute (SupportedWiFiBands and ThreadVersion) in AttributeList\n"); - if (ShouldSkip("CNET.S.F01")) { - NextTest(); - return; - } - err = TestStep4gThReadsThreadRelatedAttributeSupportedWiFiBandsAndThreadVersionInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6a: TH reads AcceptedCommandList attribute from DUT. If DUT supports Wi-Fi/Thread related features CNET.S.F00(WI),CNET.S.F01(TH)\n"); - if (ShouldSkip("( CNET.S.F00 || CNET.S.F01 )")) { - NextTest(); - return; - } - err = TestStep6aThReadsAcceptedCommandListAttributeFromDutIfDutSupportsWiFiThreadRelatedFeaturesCnetsf00wicnetsf01th_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6b: TH reads AcceptedCommandList attribute from DUT. If DUT supports Wi-Fi related features (CNET.S.F00(WI) is true)\n"); - if (ShouldSkip("CNET.S.F00")) { - NextTest(); - return; - } - err = TestStep6bThReadsAcceptedCommandListAttributeFromDutIfDutSupportsWiFiRelatedFeaturesCnetsf00wiIsTrue_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6c: TH reads AcceptedCommandList attribute from DUT. If DUT supports Thread related features(CNET.S.F01(TH) is true)\n"); - if (ShouldSkip("CNET.S.F01")) { - NextTest(); - return; - } - err = TestStep6cThReadsAcceptedCommandListAttributeFromDutIfDutSupportsThreadRelatedFeaturesCNETSF01THIsTrue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6d: TH reads AcceptedCommandList attribute from DUT. If DUT supports Ethernet related features(CNET.S.F02(TH) is true)\n"); - if (ShouldSkip("CNET.S.F02")) { - NextTest(); - return; - } - err = TestStep6dThReadsAcceptedCommandListAttributeFromDutIfDutSupportsEthernetRelatedFeaturesCNETSF02THIsTrue_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 7a: TH reads the GeneratedCommandList attribute from DUT. If DUT supports Wi-Fi/Thread related features(CNET.S.F00(WI) or CNET.S.F01(TH) is true)\n"); - if (ShouldSkip("( CNET.S.F00 || CNET.S.F01 )")) { - NextTest(); - return; - } - err = TestStep7aThReadsTheGeneratedCommandListAttributeFromDutIfDutSupportsWiFiThreadRelatedFeaturesCNETSF00WIOrCnetsf01thIsTrue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7b: Read the GeneratedCommandList attribute from DUT. If DUT supports Ethernet related features(CNET.S.F02(ET) must be true)\n"); - if (ShouldSkip("CNET.S.F02")) { - NextTest(); - return; - } - err = TestStep7bReadTheGeneratedCommandListAttributeFromDutIfDutSupportsEthernetRelatedFeaturesCNETSF02ETMustBeTrue_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheGlobalAttributeFeatureMapWhenCnetsf00IsSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the global attribute: FeatureMap when CNET.S.F00 is set: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the global attribute: FeatureMap when CNET.S.F00 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheGlobalAttributeFeatureMapWhenCnetsf01IsSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the global attribute: FeatureMap when CNET.S.F01 is set: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the global attribute: FeatureMap when CNET.S.F01 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 2UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsTheGlobalAttributeFeatureMapWhenCnetsf02IsSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the global attribute: FeatureMap when CNET.S.F02 is set: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the global attribute: FeatureMap when CNET.S.F02 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 4UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsMandatoryAttributesInAttributeListIfCnetsf00wiCnetsf01thCnetsf02etIsTrue_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads mandatory attributes in AttributeList if CNET.S.F00(WI)/CNET.S.F01(TH)/CNET.S.F02(ET) is true: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads mandatory attributes in AttributeList if CNET.S.F00(WI)/CNET.S.F01(TH)/CNET.S.F02(ET) is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheFeatureDependentAttributeScanMaxTimeSecondsAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the feature dependent attribute(ScanMaxTimeSeconds): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the feature dependent attribute(ScanMaxTimeSeconds): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheFeatureDependentAttributeConnectMaxTimeSecondsInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the feature dependent attribute(ConnectMaxTimeSeconds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the feature dependent attribute(ConnectMaxTimeSeconds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsWifiRelatedAttributeSupportedWiFiBandsInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads WIFI related attribute (SupportedWiFiBands) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads WIFI related attribute (SupportedWiFiBands) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsThreadRelatedAttributeSupportedWiFiBandsAndThreadVersionInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads Thread related attribute (SupportedWiFiBands and ThreadVersion) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads Thread related attribute (SupportedWiFiBands and ThreadVersion) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsAcceptedCommandListAttributeFromDutIfDutSupportsWiFiThreadRelatedFeaturesCnetsf00wicnetsf01th_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads AcceptedCommandList attribute from DUT. If DUT supports Wi-Fi/Thread related features CNET.S.F00(WI),CNET.S.F01(TH): Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads AcceptedCommandList attribute from DUT. If DUT supports Wi-Fi/Thread related features CNET.S.F00(WI),CNET.S.F01(TH): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsAcceptedCommandListAttributeFromDutIfDutSupportsWiFiRelatedFeaturesCnetsf00wiIsTrue_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads AcceptedCommandList attribute from DUT. If DUT supports Wi-Fi related features (CNET.S.F00(WI) is true): Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads AcceptedCommandList attribute from DUT. If DUT supports Wi-Fi related features (CNET.S.F00(WI) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsAcceptedCommandListAttributeFromDutIfDutSupportsThreadRelatedFeaturesCNETSF01THIsTrue_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads AcceptedCommandList attribute from DUT. If DUT supports Thread related features(CNET.S.F01(TH) is true): Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads AcceptedCommandList attribute from DUT. If DUT supports Thread related features(CNET.S.F01(TH) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsAcceptedCommandListAttributeFromDutIfDutSupportsEthernetRelatedFeaturesCNETSF02THIsTrue_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads AcceptedCommandList attribute from DUT. If DUT supports Ethernet related features(CNET.S.F02(TH) is true): Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads AcceptedCommandList attribute from DUT. If DUT supports Ethernet related features(CNET.S.F02(TH) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThReadsTheGeneratedCommandListAttributeFromDutIfDutSupportsWiFiThreadRelatedFeaturesCNETSF00WIOrCnetsf01thIsTrue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH reads the GeneratedCommandList attribute from DUT. If DUT supports Wi-Fi/Thread related features(CNET.S.F00(WI) or CNET.S.F01(TH) is true): Error: %@", err); - } else { - NSLog(@"Step 7a: TH reads the GeneratedCommandList attribute from DUT. If DUT supports Wi-Fi/Thread related features(CNET.S.F00(WI) or CNET.S.F01(TH) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bReadTheGeneratedCommandListAttributeFromDutIfDutSupportsEthernetRelatedFeaturesCNETSF02ETMustBeTrue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: Read the GeneratedCommandList attribute from DUT. If DUT supports Ethernet related features(CNET.S.F02(ET) must be true): Error: %@", err); - } else { - NSLog(@"Step 7b: Read the GeneratedCommandList attribute from DUT. If DUT supports Ethernet related features(CNET.S.F02(ET) must be true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DESC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DESC_1_1() - : TestCommandBridge("Test_TC_DESC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DESC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DESC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DESC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!DESC.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute. 0x0001: SHALL be included if and only if DESC.S.F00(TagList)\n"); - if (ShouldSkip("DESC.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute0x0001ShallBeIncludedIfAndOnlyIfDESCSF00TagList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the AttributeList attribute. 0x0004: SHALL be included if and only if DESC.S.F00\n"); - if (ShouldSkip("DESC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0004ShallBeIncludedIfAndOnlyIfDescsf00_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads AcceptedCommandList attribute from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute0x0001ShallBeIncludedIfAndOnlyIfDESCSF00TagList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. 0x0001: SHALL be included if and only if DESC.S.F00(TagList): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. 0x0001: SHALL be included if and only if DESC.S.F00(TagList): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0004ShallBeIncludedIfAndOnlyIfDescsf00_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0004: SHALL be included if and only if DESC.S.F00: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0004: SHALL be included if and only if DESC.S.F00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DLOG_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DLOG_1_1() - : TestCommandBridge("Test_TC_DLOG_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DLOG_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DLOG_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DLOG_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); - err = TestStep3ThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsAttributeListFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads EventList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads AcceptedCommandList from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAttributeListFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 1UL)); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGETH_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGETH_1_1() - : TestCommandBridge("Test_TC_DGETH_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGETH_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGETH_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGETH_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip(" !DGETH.S.F00 && !DGETH.S.F01")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGETH.S.F00 ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGETH.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDgethsf00EnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DGETH.S.F01 ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGETH.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenDgethsf01EnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads optional attribute(PHYRate) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributePHYRateInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads optional attribute(FullDuplex) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0001")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributeFullDuplexInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4d: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4e: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0003")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4f: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0004")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4g: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0005")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4h: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0006")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4i: TH reads optional attribute(CarrierDetect) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0007")) { - NextTest(); - return; - } - err = TestStep4iThReadsOptionalAttributeCarrierDetectInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4j: TH reads optional attribute(TimeSinceReset) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0008")) { - NextTest(); - return; - } - err = TestStep4jThReadsOptionalAttributeTimeSinceResetInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5: TH reads EventList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip("( DGETH.S.F00 || DGETH.S.F01 )")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip(" !DGETH.S.F00 && !DGETH.S.F01 ")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDgethsf00EnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DGETH.S.F00 ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DGETH.S.F00 ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenDgethsf01EnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given DGETH.S.F01 ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given DGETH.S.F01 ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributePHYRateInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(PHYRate) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(PHYRate) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributeFullDuplexInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(FullDuplex) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(FullDuplex) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsOptionalAttributeCarrierDetectInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads optional attribute(CarrierDetect) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads optional attribute(CarrierDetect) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsOptionalAttributeTimeSinceResetInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads optional attribute(TimeSinceReset) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads optional attribute(TimeSinceReset) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGETH_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGETH_2_1() - : TestCommandBridge("Test_TC_DGETH_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGETH_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGETH_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGETH_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads PHYRate attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsPHYRateAttributeConstraints_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FullDuplex attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFullDuplexAttributeConstraints_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads PacketRxCount attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0002")) { - NextTest(); - return; - } - err = TestStep4aThReadsPacketRxCountAttributeConstraints_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep4bRebootTargetDevice_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4cRebootTargetDeviceDUT_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: Upon a node reboot, PacketRxCount attribute value will be reset to 0\n"); - if (ShouldSkip("PICS_USER_PROMPT && DGETH.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dUponANodeRebootPacketRxCountAttributeValueWillBeResetTo0_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5a: TH reads PacketTxCount attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0003")) { - NextTest(); - return; - } - err = TestStep5aThReadsPacketTxCountAttributeConstraints_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5b: TH reads PacketTxCount attribute constraints, Upon a node reboot, the value will be reset to 0\n"); - if (ShouldSkip("PICS_USER_PROMPT && DGETH.S.A0003")) { - NextTest(); - return; - } - err = TestStep5bThReadsPacketTxCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads TxErrCount attribute constraints, Upon a node reboot, the value will be reset to 0\n"); - if (ShouldSkip("DGETH.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsTxErrCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads CollisionCount attribute , Upon a node reboot, the value will be reset to 0\n"); - if (ShouldSkip("DGETH.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsCollisionCountAttributeUponANodeRebootTheValueWillBeResetTo0_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 8: TH reads OverrunCount attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsOverrunCountAttributeConstraints_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 9: TH reads CarrierDetect attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsCarrierDetectAttributeConstraints_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 10: TH reads TimeSinceReset attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsTimeSinceResetAttributeConstraints_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsPHYRateAttributeConstraints_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads PHYRate attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads PHYRate attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFullDuplexAttributeConstraints_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFullDuplexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FullDuplex attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FullDuplex attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("fullDuplex", "boolean", "boolean")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsPacketRxCountAttributeConstraints_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads PacketRxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads PacketRxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("packetRxCount", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("packetRxCount", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("packetRxCount", [value unsignedLongLongValue], 18446744073709551615ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bRebootTargetDevice_4() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep4cRebootTargetDeviceDUT_5() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep4dUponANodeRebootPacketRxCountAttributeValueWillBeResetTo0_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5aThReadsPacketTxCountAttributeConstraints_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH reads PacketTxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 5a: TH reads PacketTxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("packetTxCount", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("packetTxCount", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("packetTxCount", [value unsignedLongLongValue], 18446744073709551615ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsPacketTxCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6ThReadsTxErrCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTxErrCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads TxErrCount attribute constraints, Upon a node reboot, the value will be reset to 0: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads TxErrCount attribute constraints, Upon a node reboot, the value will be reset to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TxErrCount", actualValue, 0ULL)); - } - - VerifyOrReturn(CheckConstraintType("txErrCount", "int64u", "int64u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsCollisionCountAttributeUponANodeRebootTheValueWillBeResetTo0_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCollisionCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads CollisionCount attribute , Upon a node reboot, the value will be reset to 0: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads CollisionCount attribute , Upon a node reboot, the value will be reset to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CollisionCount", actualValue, 0ULL)); - } - - VerifyOrReturn(CheckConstraintType("collisionCount", "int64u", "int64u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsOverrunCountAttributeConstraints_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads OverrunCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads OverrunCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OverrunCount", actualValue, 0ULL)); - } - - VerifyOrReturn(CheckConstraintType("overrunCount", "int64u", "int64u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsCarrierDetectAttributeConstraints_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCarrierDetectWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads CarrierDetect attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads CarrierDetect attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("carrierDetect", "boolean", "boolean")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsTimeSinceResetAttributeConstraints_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeSinceResetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads TimeSinceReset attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads TimeSinceReset attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("timeSinceReset", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("timeSinceReset", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("timeSinceReset", [value unsignedLongLongValue], 18446744073709551615ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGETH_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGETH_2_2() - : TestCommandBridge("Test_TC_DGETH_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGETH_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGETH_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGETH_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a.1: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a1ThReadsPHYRateAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a.2: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a2ThReadsPHYRateAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a.3: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a3ThReadsPHYRateAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a.4: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a4ThReadsPHYRateAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a.5: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a5ThReadsPHYRateAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a.6: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a6ThReadsPHYRateAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a.7: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a7ThReadsPHYRateAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2a.8: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a8ThReadsPHYRateAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a.9: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a9ThReadsPHYRateAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2a.10: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a10ThReadsPHYRateAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2b: TH reads PacketRxCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0002")) { - NextTest(); - return; - } - err = TestStep2bThReadsPacketRxCountAttributeValueFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2c: TH reads PacketTxCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0003")) { - NextTest(); - return; - } - err = TestStep2cThReadsPacketTxCountAttributeValueFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2d: TH reads TxErrCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0004")) { - NextTest(); - return; - } - err = TestStep2dThReadsTxErrCountAttributeValueFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2e: TH reads CollisionCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0005")) { - NextTest(); - return; - } - err = TestStep2eThReadsCollisionCountAttributeValueFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 2f: TH reads OverrunCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0006")) { - NextTest(); - return; - } - err = TestStep2fThReadsOverrunCountAttributeValueFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 2g: Sends ResetCounts command\n"); - if (ShouldSkip("DGETH.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2gSendsResetCountsCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 2h: TH reads PacketRxCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0002 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2hThReadsPacketRxCountAttributeValueFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 2i: TH reads PacketTxCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0003 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2iThReadsPacketTxCountAttributeValueFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 2j: TH reads TxErrCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0004")) { - NextTest(); - return; - } - err = TestStep2jThReadsTxErrCountAttributeValueFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 2k: TH reads CollisionCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0005")) { - NextTest(); - return; - } - err = TestStep2kThReadsCollisionCountAttributeValueFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 2l: TH reads OverrunCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0006")) { - NextTest(); - return; - } - err = TestStep2lThReadsOverrunCountAttributeValueFromDut_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2a1ThReadsPHYRateAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.1: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.1: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a2ThReadsPHYRateAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.2: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.2: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a3ThReadsPHYRateAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.3: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.3: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a4ThReadsPHYRateAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.4: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.4: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a5ThReadsPHYRateAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.5: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.5: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a6ThReadsPHYRateAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.6: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.6: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a7ThReadsPHYRateAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.7: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.7: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a8ThReadsPHYRateAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.8: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.8: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a9ThReadsPHYRateAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.9: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.9: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a10ThReadsPHYRateAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.10: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.10: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull PacketRxCountValue; - - CHIP_ERROR TestStep2bThReadsPacketRxCountAttributeValueFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads PacketRxCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads PacketRxCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - PacketRxCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull PacketTxCountValue; - - CHIP_ERROR TestStep2cThReadsPacketTxCountAttributeValueFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads PacketTxCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads PacketTxCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - PacketTxCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull TxErrCountValue; - - CHIP_ERROR TestStep2dThReadsTxErrCountAttributeValueFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTxErrCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads TxErrCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads TxErrCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - TxErrCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull CollisionCountValue; - - CHIP_ERROR TestStep2eThReadsCollisionCountAttributeValueFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCollisionCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads CollisionCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads CollisionCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - CollisionCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull OverrunCountValue; - - CHIP_ERROR TestStep2fThReadsOverrunCountAttributeValueFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads OverrunCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads OverrunCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - OverrunCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2gSendsResetCountsCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster resetCountsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: Sends ResetCounts command: Error: %@", err); - } else { - NSLog(@"Step 2g: Sends ResetCounts command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2hThReadsPacketRxCountAttributeValueFromDut_17() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2iThReadsPacketTxCountAttributeValueFromDut_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2jThReadsTxErrCountAttributeValueFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTxErrCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2j: TH reads TxErrCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2j: TH reads TxErrCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxValue("txErrCount", [value unsignedLongLongValue], TxErrCountValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2kThReadsCollisionCountAttributeValueFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCollisionCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2k: TH reads CollisionCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2k: TH reads CollisionCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxValue("collisionCount", [value unsignedLongLongValue], CollisionCountValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2lThReadsOverrunCountAttributeValueFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2l: TH reads OverrunCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2l: TH reads OverrunCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxValue("overrunCount", [value unsignedLongLongValue], OverrunCountValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FLW_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FLW_1_1() - : TestCommandBridge("Test_TC_FLW_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FLW_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLW_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLW_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1:Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("FLW.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FLABEL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FLABEL_1_1() - : TestCommandBridge("Test_TC_FLABEL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FLABEL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLABEL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLABEL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_1_1() - : TestCommandBridge("Test_TC_FAN_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !FAN.S.F00 && !FAN.S.F01 && !FAN.S.F02 && !FAN.S.F03 && !FAN.S.F04 && !FAN.S.F05 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given FAN.S.F00(SPD) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenFansf00spdEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given FAN.S.F01(AUT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenFansf01autEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given FAN.S.F02(RCK) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenFansf02rckEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given FAN.S.F03(WND) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenFansf03wndEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given FAN.S.F04(STEP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenFansf04stepEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given FAN.S.F05(DIR) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F05")) { - NextTest(); - return; - } - err = TestStep3gGivenFansf05dirEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: TH Reads the feature dependent FAN.S.F00 (SPD) attribute in AttributeList\n"); - if (ShouldSkip("FAN.S.F00")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentFansf00SpdAttributeInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: TH Reads the feature dependent FAN.S.F02(RCK) attribute in AttributeList\n"); - if (ShouldSkip("FAN.S.F02")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheFeatureDependentFansf02rckAttributeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4e: TH Reads the feature dependent FAN.S.F03(WND) attribute in AttributeList\n"); - if (ShouldSkip("FAN.S.F03")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheFeatureDependentFansf03wndAttributeInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4f: TH Reads the feature dependent FAN.S.F05(DIR) attribute in AttributeList\n"); - if (ShouldSkip("FAN.S.F05")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheFeatureDependentFansf05dirAttributeInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6:TH reads from the DUT the AcceptedCommandList attribute.\n"); - if (ShouldSkip(" !FAN.S.C00.Rsp ")) { - NextTest(); - return; - } - err = TestStep6thReadsFromTheDutTheAcceptedCommandListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6: TH Reads the optional command (Step) in AcceptedCommandList\n"); - if (ShouldSkip("FAN.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheOptionalCommandStepInAcceptedCommandList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_18(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 19; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenFansf00spdEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given FAN.S.F00(SPD) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given FAN.S.F00(SPD) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenFansf01autEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given FAN.S.F01(AUT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given FAN.S.F01(AUT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenFansf02rckEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given FAN.S.F02(RCK) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given FAN.S.F02(RCK) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenFansf03wndEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given FAN.S.F03(WND) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given FAN.S.F03(WND) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenFansf04stepEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given FAN.S.F04(STEP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given FAN.S.F04(STEP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenFansf05dirEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given FAN.S.F05(DIR) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given FAN.S.F05(DIR) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentFansf00SpdAttributeInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH Reads the feature dependent FAN.S.F00 (SPD) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH Reads the feature dependent FAN.S.F00 (SPD) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheFeatureDependentFansf02rckAttributeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH Reads the feature dependent FAN.S.F02(RCK) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH Reads the feature dependent FAN.S.F02(RCK) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheFeatureDependentFansf03wndAttributeInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH Reads the feature dependent FAN.S.F03(WND) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH Reads the feature dependent FAN.S.F03(WND) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheFeatureDependentFansf05dirAttributeInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH Reads the feature dependent FAN.S.F05(DIR) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH Reads the feature dependent FAN.S.F05(DIR) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6thReadsFromTheDutTheAcceptedCommandListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6:TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6:TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheOptionalCommandStepInAcceptedCommandList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH Reads the optional command (Step) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: TH Reads the optional command (Step) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_2_1() - : TestCommandBridge("Test_TC_FAN_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the FanMode attribute\n"); - if (ShouldSkip("FAN.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheFanModeAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the FanModeSequence attribute\n"); - if (ShouldSkip("FAN.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheFanModeSequenceAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the the PercentSetting attribute\n"); - if (ShouldSkip("FAN.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheThePercentSettingAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the the PercentCurrent attribute\n"); - if (ShouldSkip("FAN.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheThePercentCurrentAttribute_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheFanModeAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFanModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the FanMode attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the FanMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("fanMode", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheFanModeSequenceAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFanModeSequenceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the FanModeSequence attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the FanModeSequence attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("fanModeSequence", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("fanModeSequence", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("fanModeSequence", [value unsignedCharValue], 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheThePercentSettingAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the the PercentSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the the PercentSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("percentSetting", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("percentSetting", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("percentSetting", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheThePercentCurrentAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the the PercentCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the the PercentCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("percentCurrent", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("percentCurrent", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("percentCurrent", [value unsignedCharValue], 100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_2_2() - : TestCommandBridge("Test_TC_FAN_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the SpeedMax attribute\n"); - if (ShouldSkip("FAN.S.A0004")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheSpeedMaxAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the SpeedSetting attribute\n"); - if (ShouldSkip("FAN.S.A0005 && FAN.S.A0004")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheSpeedSettingAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the the SpeedCurrent attribute\n"); - if (ShouldSkip("FAN.S.A0006 && FAN.S.A0004")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheTheSpeedCurrentAttribute_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull SpeedMaxValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheSpeedMaxAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedMaxWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the SpeedMax attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the SpeedMax attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("speedMax", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("speedMax", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("speedMax", [value unsignedCharValue], 100U)); - { - SpeedMaxValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheSpeedSettingAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the SpeedSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the SpeedSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("speedSetting", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("speedSetting", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("speedSetting", [value unsignedCharValue], SpeedMaxValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheTheSpeedCurrentAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the the SpeedCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the the SpeedCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("speedCurrent", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("speedCurrent", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("speedCurrent", [value unsignedCharValue], SpeedMaxValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_2_3() - : TestCommandBridge("Test_TC_FAN_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the RockSupport attribute\n"); - if (ShouldSkip("FAN.S.A0007")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheRockSupportAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the RockSetting attribute\n"); - if (ShouldSkip("FAN.S.A0008")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheRockSettingAttribute_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheRockSupportAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRockSupportWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the RockSupport attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the RockSupport attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("rockSupport", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheRockSettingAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRockSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the RockSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the RockSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("rockSetting", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_2_4() - : TestCommandBridge("Test_TC_FAN_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the WindSupport attribute\n"); - if (ShouldSkip("FAN.S.A0009")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheWindSupportAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the WindSetting attribute\n"); - if (ShouldSkip("FAN.S.A000A")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheWindSettingAttribute_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheWindSupportAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindSupportWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the WindSupport attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the WindSupport attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("windSupport", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheWindSettingAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the WindSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the WindSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("windSetting", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_3_6 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_3_6() - : TestCommandBridge("Test_TC_FAN_3_6") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_3_6() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_3_6\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_3_6\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH writes a value of Forward to the DUT\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestStep2ThWritesAValueOfForwardToTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Wait 1000ms\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestWait1000ms_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: after a few seconds, TH reads from the DUT the AirflowDirection attribute\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestStep3AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes a value of Reverse to the DUT\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestStep4ThWritesAValueOfReverseToTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 1000ms\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestWait1000ms_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: after a few seconds, TH reads from the DUT the AirflowDirection attribute\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestStep5AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThWritesAValueOfForwardToTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id airflowDirectionArgument; - airflowDirectionArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeAirflowDirectionWithValue:airflowDirectionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH writes a value of Forward to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH writes a value of Forward to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAirflowDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Error: %@", err); - } else { - NSLog(@"Step 3: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AirflowDirection", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThWritesAValueOfReverseToTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id airflowDirectionArgument; - airflowDirectionArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeAirflowDirectionWithValue:airflowDirectionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes a value of Reverse to the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH writes a value of Reverse to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAirflowDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Error: %@", err); - } else { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AirflowDirection", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CGEN_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CGEN_1_1() - : TestCommandBridge("Test_TC_CGEN_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CGEN_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CGEN_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CGEN_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Read the global attribute: FeatureMap\n"); - err = TestStep3ReadTheGlobalAttributeFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ReadTheGlobalAttributeAttributeList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ReadTheGlobalAttributeAttributeList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ReadTheGlobalAttributeFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Read the global attribute: FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 3: Read the global attribute: FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CGEN_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CGEN_2_1() - : TestCommandBridge("Test_TC_CGEN_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CGEN_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CGEN_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CGEN_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH1 reads the BreadCrumb Attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0000")) { - NextTest(); - return; - } - err = TestStep1Th1ReadsTheBreadCrumbAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH1 writes the BreadCrumb attribute as 1 to the DUT\n"); - if (ShouldSkip("CGEN.S.A0000")) { - NextTest(); - return; - } - err = TestStep2Th1WritesTheBreadCrumbAttributeAs1ToTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH1 reads the BreadCrumb attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0000")) { - NextTest(); - return; - } - err = TestStep3Th1ReadsTheBreadCrumbAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH1 reads the RegulatoryConfig attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0002")) { - NextTest(); - return; - } - err = TestStep4Th1ReadsTheRegulatoryConfigAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH1 reads the LocationCapability attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0003")) { - NextTest(); - return; - } - err = TestStep5Th1ReadsTheLocationCapabilityAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH1 reads BasicCommissioningInfo attribute from DUT and Verify that the BasicCommissioningInfo attribute has the following field: FailSafeExpiryLengthSeconds field value is within a duration range of 0 to 65535\n"); - if (ShouldSkip("CGEN.S.A0001")) { - NextTest(); - return; - } - err = TestStep6Th1ReadsBasicCommissioningInfoAttributeFromDutAndVerifyThatTheBasicCommissioningInfoAttributeHasTheFollowingFieldFailSafeExpiryLengthSecondsFieldValueIsWithinADurationRangeOf0To65535_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH1 reads SupportsConcurrentConnection attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0004")) { - NextTest(); - return; - } - err = TestStep7Th1ReadsSupportsConcurrentConnectionAttributeFromTheDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1Th1ReadsTheBreadCrumbAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH1 reads the BreadCrumb Attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH1 reads the BreadCrumb Attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("breadcrumb", "int64u", "int64u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2Th1WritesTheBreadCrumbAttributeAs1ToTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH1 writes the BreadCrumb attribute as 1 to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH1 writes the BreadCrumb attribute as 1 to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3Th1ReadsTheBreadCrumbAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH1 reads the BreadCrumb attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH1 reads the BreadCrumb attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4Th1ReadsTheRegulatoryConfigAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRegulatoryConfigWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH1 reads the RegulatoryConfig attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH1 reads the RegulatoryConfig attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("regulatoryConfig", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("regulatoryConfig", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5Th1ReadsTheLocationCapabilityAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationCapabilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH1 reads the LocationCapability attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH1 reads the LocationCapability attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("locationCapability", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("locationCapability", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6Th1ReadsBasicCommissioningInfoAttributeFromDutAndVerifyThatTheBasicCommissioningInfoAttributeHasTheFollowingFieldFailSafeExpiryLengthSecondsFieldValueIsWithinADurationRangeOf0To65535_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBasicCommissioningInfoWithCompletion:^(MTRGeneralCommissioningClusterBasicCommissioningInfo * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH1 reads BasicCommissioningInfo attribute from DUT and Verify that the BasicCommissioningInfo attribute has the following field: FailSafeExpiryLengthSeconds field value is within a duration range of 0 to 65535: Error: %@", err); - } else { - NSLog(@"Step 6: TH1 reads BasicCommissioningInfo attribute from DUT and Verify that the BasicCommissioningInfo attribute has the following field: FailSafeExpiryLengthSeconds field value is within a duration range of 0 to 65535: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7Th1ReadsSupportsConcurrentConnectionAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportsConcurrentConnectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH1 reads SupportsConcurrentConnection attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH1 reads SupportsConcurrentConnection attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportsConcurrentConnection", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGGEN_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGGEN_1_1() - : TestCommandBridge("Test_TC_DGGEN_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGGEN_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGGEN_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGGEN_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: Validate presence of mandatory attribute(UpTime) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bValidatePresenceOfMandatoryAttributeUpTimeInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads optional attribute(TotalOperationalHours) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0003")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributeTotalOperationalHoursInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads optional attribute(BootReason) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0004")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeBootReasonInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: TH reads optional attribute(ActiveHardwareFaults) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0005")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeActiveHardwareFaultsInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: TH reads optional attribute(ActiveRadioFaults) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0006")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributeActiveRadioFaultsInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: TH reads optional attribute(ActiveNetworkFaults) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0007")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributeActiveNetworkFaultsInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5a: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5b: TH reads optional event(HardwareFaultChange) in EventList\n"); - if (ShouldSkip("DGGEN.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5c: TH reads optional event(RadioFaultChange) in EventList\n"); - if (ShouldSkip("DGGEN.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5d: TH reads optional event(NetworkFaultChange) in EventList\n"); - if (ShouldSkip("DGGEN.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6: TH reads from the DUT the AcceptedCommandList attribute\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bValidatePresenceOfMandatoryAttributeUpTimeInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Validate presence of mandatory attribute(UpTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Validate presence of mandatory attribute(UpTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributeTotalOperationalHoursInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(TotalOperationalHours) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(TotalOperationalHours) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeBootReasonInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(BootReason) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(BootReason) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeActiveHardwareFaultsInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(ActiveHardwareFaults) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(ActiveHardwareFaults) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributeActiveRadioFaultsInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(ActiveRadioFaults) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(ActiveRadioFaults) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributeActiveNetworkFaultsInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(ActiveNetworkFaults) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(ActiveNetworkFaults) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 2UL)); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_GRPKEY_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_GRPKEY_1_1() - : TestCommandBridge("Test_TC_GRPKEY_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_GRPKEY_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_GRPKEY_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_GRPKEY_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !GRPKEY.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given GRPKEY.S.F00(CS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("GRPKEY.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenGrpkeysf00csEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip(" !PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenGrpkeysf00csEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given GRPKEY.S.F00(CS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given GRPKEY.S.F00(CS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_GRPKEY_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_GRPKEY_2_2() - : TestCommandBridge("Test_TC_GRPKEY_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_GRPKEY_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_GRPKEY_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_GRPKEY_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads MaxGroupKeysPerFabric attribute from GroupKeyManagement cluster on DUT using a fabric-filtered read. Save the value as Max_GrpKey for future use.\n"); - if (ShouldSkip("GRPKEY.S.A0003")) { - NextTest(); - return; - } - err = TestStep1ThReadsMaxGroupKeysPerFabricAttributeFromGroupKeyManagementClusterOnDutUsingAFabricFilteredReadSaveTheValueAsMaxGrpKeyForFutureUse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a\n"); - if (ShouldSkip("GRPKEY.S.C01.Rsp && GRPKEY.S.C02.Tx")) { - NextTest(); - return; - } - err = TestStep3ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1:null 7)EpochKey2: null 8)EpochStartTime2:null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1null7EpochKey2Null8EpochStartTime2null_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: null 8)EpochStartTime2:null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime2null_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with command fields as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: null 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithCommandFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0Null4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: null 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0Null5EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 0 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 10: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 11: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 18446744073709551613 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 1 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep11ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0184467440737095516135EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime117EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 12: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614 Note: EpochKey1 and EpochStartTime1 are null when EpochKey2 and EpochStartTime2 are not null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep12ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614NoteEpochKey1AndEpochStartTime1AreNullWhenEpochKey2AndEpochStartTime2AreNotNull_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 13: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: null 8)EpochStartTime2: 18446744073709551614 Note: EpochKey2 is set to null and EpochStartTime2 is not null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime218446744073709551614NoteEpochKey2IsSetToNullAndEpochStartTime2IsNotNull_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 14: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: null Note: EpochKey2 is not null and EpochStartTime2 is null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep14ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime2NullNoteEpochKey2IsNotNullAndEpochStartTime2IsNull_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 15: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 6)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 7)EpochStartTime1: 18446744073709551613 8)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 9)EpochStartTime2: 1 Note: EpochStartTime2 is earlier than EpochStartTime1\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep15ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime016EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf7EpochStartTime1184467440737095516138EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf9EpochStartTime21NoteEpochStartTime2IsEarlierThanEpochStartTime1_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 16: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 1 Note1: Repeat the step by sending EpochKey1 and EpochKey2 with 1 byte value (< 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D04EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime21Note1RepeatTheStepBySendingEpochKey1AndEpochKey2With1ByteValue16Bytes_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 16: Repeat the step by sending EpochKey1 with 1 byte value (< 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16RepeatTheStepBySendingEpochKey1With1ByteValue16Bytes_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 16: Note: Repeat the step by sending EpochKey2 with 1 byte value (< 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16NoteRepeatTheStepBySendingEpochKey2With1ByteValue16Bytes_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 16a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 15 bytes value (< 16 byte)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having15BytesValue16Byte_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey1 having 15 bytes value (< 16 byte)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey1Having15BytesValue16Byte_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey2 having 15 bytes value (< 16 byte)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey2Having15BytesValue16Byte_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 16b: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 17 bytes value (> 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16bThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having17BytesValue16Bytes_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey1 having 17 bytes value (> 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey1Having17BytesValue16Bytes_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey2 having 17 bytes value (> 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey2Having17BytesValue16Bytes_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 17: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d3d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d4d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 17446744073709551613 7)EpochKey2: d5d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 17446744073709551614 Note: KeySetWrite command is sent with different EpochKeys,EpochStartTime1 and EpochStartTime2 values\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep17ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D3d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D4d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1174467440737095516137EpochKey2D5d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime217446744073709551614NoteKeySetWriteCommandIsSentWithDifferentEpochKeysEpochStartTime1AndEpochStartTime2Values_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 18: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a\n"); - if (ShouldSkip("GRPKEY.S.C01.Rsp && GRPKEY.S.C02.Tx")) { - NextTest(); - return; - } - err = TestStep18ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 19: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01b that does not exist in the GroupKeyMap attribute list.\n"); - if (ShouldSkip("GRPKEY.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep19ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 20: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a.\n"); - if (ShouldSkip("GRPKEY.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep20ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 21: TH sends KeySetWrite command to DUT until size of list for TH’s fabric in GroupKeyMap attribute contains Max_GrpKey entries, starting with GroupKeySetID 1 and incrementing by 1 each time.\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep21ThSendsKeySetWriteCommandToDutUntilSizeOfListForTHsFabricInGroupKeyMapAttributeContainsMaxGrpKeyEntriesStartingWithGroupKeySetID1AndIncrementingBy1EachTime_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 22: TH again sends KeySetWrite command to DUT with any other GroupKeySetID not used yet.\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep22ThAgainSendsKeySetWriteCommandToDutWithAnyOtherGroupKeySetIDNotUsedYet_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 23: TH sends KeySetReadAllIndices command to DUT.\n"); - if (ShouldSkip("GRPKEY.S.C04.Rsp && GRPKEY.S.C05.Tx && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep23ThSendsKeySetReadAllIndicesCommandToDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 24: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x0\n"); - if (ShouldSkip("GRPKEY.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep24ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x0_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 25: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01b that does not exist in the GroupKeyMap attribute list.\n"); - if (ShouldSkip("GRPKEY.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep25ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_33(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 34; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull Max_GrpKey; - - CHIP_ERROR TestStep1ThReadsMaxGroupKeysPerFabricAttributeFromGroupKeyManagementClusterOnDutUsingAFabricFilteredReadSaveTheValueAsMaxGrpKeyForFutureUse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxGroupKeysPerFabricWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads MaxGroupKeysPerFabric attribute from GroupKeyManagement cluster on DUT using a fabric-filtered read. Save the value as Max_GrpKey for future use.: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads MaxGroupKeysPerFabric attribute from GroupKeyManagement cluster on DUT using a fabric-filtered read. Save the value as Max_GrpKey for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - Max_GrpKey = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetReadParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - [cluster keySetReadWithParams:params completion: - ^(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.groupKeySet; - VerifyOrReturn(CheckValue("GroupKeySetID", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySetID, 26U)); - VerifyOrReturn(CheckValue("GroupKeySecurityPolicy", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySecurityPolicy, 0U)); - VerifyOrReturn(CheckValueNull("EpochKey0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey0)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0)); - VerifyOrReturn(CheckValue("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0, 1ULL)); - VerifyOrReturn(CheckValueNull("EpochKey1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey1)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1)); - VerifyOrReturn(CheckValue("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1, 18446744073709551613ULL)); - VerifyOrReturn(CheckValueNull("EpochKey2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey2)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2)); - VerifyOrReturn(CheckValue("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1null7EpochKey2Null8EpochStartTime2null_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1:null 7)EpochKey2: null 8)EpochStartTime2:null: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1:null 7)EpochKey2: null 8)EpochStartTime2:null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime2null_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: null 8)EpochStartTime2:null: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: null 8)EpochStartTime2:null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithCommandFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0Null4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with command fields as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: null 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with command fields as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: null 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0Null5EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: null 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: null 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 0 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 0 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0184467440737095516135EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime117EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 18446744073709551613 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 1 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 18446744073709551613 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 1 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614NoteEpochKey1AndEpochStartTime1AreNullWhenEpochKey2AndEpochStartTime2AreNotNull_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614 Note: EpochKey1 and EpochStartTime1 are null when EpochKey2 and EpochStartTime2 are not null: Error: %@", err); - } else { - NSLog(@"Step 12: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614 Note: EpochKey1 and EpochStartTime1 are null when EpochKey2 and EpochStartTime2 are not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime218446744073709551614NoteEpochKey2IsSetToNullAndEpochStartTime2IsNotNull_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: null 8)EpochStartTime2: 18446744073709551614 Note: EpochKey2 is set to null and EpochStartTime2 is not null: Error: %@", err); - } else { - NSLog(@"Step 13: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: null 8)EpochStartTime2: 18446744073709551614 Note: EpochKey2 is set to null and EpochStartTime2 is not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime2NullNoteEpochKey2IsNotNullAndEpochStartTime2IsNull_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: null Note: EpochKey2 is not null and EpochStartTime2 is null: Error: %@", err); - } else { - NSLog(@"Step 14: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: null Note: EpochKey2 is not null and EpochStartTime2 is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime016EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf7EpochStartTime1184467440737095516138EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf9EpochStartTime21NoteEpochStartTime2IsEarlierThanEpochStartTime1_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 6)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 7)EpochStartTime1: 18446744073709551613 8)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 9)EpochStartTime2: 1 Note: EpochStartTime2 is earlier than EpochStartTime1: Error: %@", err); - } else { - NSLog(@"Step 15: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 6)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 7)EpochStartTime1: 18446744073709551613 8)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 9)EpochStartTime2: 1 Note: EpochStartTime2 is earlier than EpochStartTime1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D04EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime21Note1RepeatTheStepBySendingEpochKey1AndEpochKey2With1ByteValue16Bytes_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0" length:1]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 1 Note1: Repeat the step by sending EpochKey1 and EpochKey2 with 1 byte value (< 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 1 Note1: Repeat the step by sending EpochKey1 and EpochKey2 with 1 byte value (< 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16RepeatTheStepBySendingEpochKey1With1ByteValue16Bytes_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1" length:1]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: Repeat the step by sending EpochKey1 with 1 byte value (< 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16: Repeat the step by sending EpochKey1 with 1 byte value (< 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16NoteRepeatTheStepBySendingEpochKey2With1ByteValue16Bytes_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2" length:1]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: Note: Repeat the step by sending EpochKey2 with 1 byte value (< 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16: Note: Repeat the step by sending EpochKey2 with 1 byte value (< 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having15BytesValue16Byte_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde" length:15]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 15 bytes value (< 16 byte): Error: %@", err); - } else { - NSLog(@"Step 16a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 15 bytes value (< 16 byte): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey1Having15BytesValue16Byte_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde" length:15]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey1 having 15 bytes value (< 16 byte): Error: %@", err); - } else { - NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey1 having 15 bytes value (< 16 byte): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey2Having15BytesValue16Byte_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde" length:15]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey2 having 15 bytes value (< 16 byte): Error: %@", err); - } else { - NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey2 having 15 bytes value (< 16 byte): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16bThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having17BytesValue16Bytes_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xde" length:17]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16b: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 17 bytes value (> 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16b: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 17 bytes value (> 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey1Having17BytesValue16Bytes_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xde" length:17]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey1 having 17 bytes value (> 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey1 having 17 bytes value (> 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey2Having17BytesValue16Bytes_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xde" length:17]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey2 having 17 bytes value (> 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey2 having 17 bytes value (> 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D3d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D4d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1174467440737095516137EpochKey2D5d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime217446744073709551614NoteKeySetWriteCommandIsSentWithDifferentEpochKeysEpochStartTime1AndEpochStartTime2Values_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd3\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd4\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:17446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd5\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:17446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d3d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d4d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 17446744073709551613 7)EpochKey2: d5d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 17446744073709551614 Note: KeySetWrite command is sent with different EpochKeys,EpochStartTime1 and EpochStartTime2 values: Error: %@", err); - } else { - NSLog(@"Step 17: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d3d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d4d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 17446744073709551613 7)EpochKey2: d5d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 17446744073709551614 Note: KeySetWrite command is sent with different EpochKeys,EpochStartTime1 and EpochStartTime2 values: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetReadParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - [cluster keySetReadWithParams:params completion: - ^(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Error: %@", err); - } else { - NSLog(@"Step 18: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.groupKeySet; - VerifyOrReturn(CheckValue("GroupKeySetID", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySetID, 26U)); - VerifyOrReturn(CheckValue("GroupKeySecurityPolicy", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySecurityPolicy, 0U)); - VerifyOrReturn(CheckValueNull("EpochKey0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey0)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0)); - VerifyOrReturn(CheckValue("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0, 1ULL)); - VerifyOrReturn(CheckValueNull("EpochKey1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey1)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1)); - VerifyOrReturn(CheckValue("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1, 17446744073709551613ULL)); - VerifyOrReturn(CheckValueNull("EpochKey2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey2)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2)); - VerifyOrReturn(CheckValue("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2, 17446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetReadParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:27U]; - [cluster keySetReadWithParams:params completion: - ^(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01b that does not exist in the GroupKeyMap attribute list.: Error: %@", err); - } else { - NSLog(@"Step 19: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01b that does not exist in the GroupKeyMap attribute list.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_NOT_FOUND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - [cluster keySetRemoveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a.: Error: %@", err); - } else { - NSLog(@"Step 20: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21ThSendsKeySetWriteCommandToDutUntilSizeOfListForTHsFabricInGroupKeyMapAttributeContainsMaxGrpKeyEntriesStartingWithGroupKeySetID1AndIncrementingBy1EachTime_29() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep22ThAgainSendsKeySetWriteCommandToDutWithAnyOtherGroupKeySetIDNotUsedYet_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: TH again sends KeySetWrite command to DUT with any other GroupKeySetID not used yet.: Error: %@", err); - } else { - NSLog(@"Step 22: TH again sends KeySetWrite command to DUT with any other GroupKeySetID not used yet.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23ThSendsKeySetReadAllIndicesCommandToDut_31() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep24ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x0_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:0U]; - [cluster keySetRemoveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x0: Error: %@", err); - } else { - NSLog(@"Step 24: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:27U]; - [cluster keySetRemoveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 25: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01b that does not exist in the GroupKeyMap attribute list.: Error: %@", err); - } else { - NSLog(@"Step 25: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01b that does not exist in the GroupKeyMap attribute list.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_NOT_FOUND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ICDM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ICDM_1_1() - : TestCommandBridge("Test_TC_ICDM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ICDM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ICDM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ICDM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads ClusterRevision attribute from DUT\n"); - err = TestStep2ThReadsClusterRevisionAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FeatureMap attribute from DUT\n"); - if (ShouldSkip(" !ICDM.S.F00 && !ICDM.S.F01 && !ICDM.S.F02 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFeatureMapAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads FeatureMap attribute from DUT, bit 0 is set to 1 if ICDM.S.F00(UAT) is true,\n"); - if (ShouldSkip("ICDM.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFeatureMapAttributeFromDutBit0IsSetTo1IfIcdmsf00uatIsTrue_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads FeatureMap attribute from DUT, bit 1 is set to 1 if ICDM.S.F01(CIP) is true\n"); - if (ShouldSkip("ICDM.S.F01")) { - NextTest(); - return; - } - err = TestStep3ThReadsFeatureMapAttributeFromDutBit1IsSetTo1IfIcdmsf01cipIsTrue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads FeatureMap attribute from DUT, bit 2 is set to 1 if ICDM.S.F02(UAT) is true,\n"); - if (ShouldSkip("ICDM.S.F02")) { - NextTest(); - return; - } - err = TestStep3ThReadsFeatureMapAttributeFromDutBit2IsSetTo1IfIcdmsf02uatIsTrue_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads AttributeList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH reads AttributeList attribute from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: Read the optional attribute(RegisteredClients) in AttributeList\n"); - if (ShouldSkip("ICDM.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeRegisteredClientsInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: Read the optional attribute(IcdCounter) in AttributeList\n"); - if (ShouldSkip("ICDM.S.A0004")) { - NextTest(); - return; - } - err = TestStep4cReadTheOptionalAttributeIcdCounterInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: Read the optional attribute(ClientsSupportedPerFabric) in AttributeList\n"); - if (ShouldSkip("ICDM.S.A0005")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalAttributeClientsSupportedPerFabricInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4d: Read the optional attribute(UserActiveModeTriggerHint) in AttributeList\n"); - if (ShouldSkip("ICDM.S.A0006")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalAttributeUserActiveModeTriggerHintInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: Read the optional attribute(UserActiveModeTriggerInstruction) in AttributeList\n"); - if (ShouldSkip("ICDM.S.A0007")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalAttributeUserActiveModeTriggerInstructionInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6a: TH reads AcceptedCommandList attribute from DUT\n"); - if (ShouldSkip(" !ICDM.S.F00 && !ICDM.S.C03.Rsp ")) { - NextTest(); - return; - } - err = TestStep6aThReadsAcceptedCommandListAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6b: TH reads AcceptedCommandList attribute from DUT if ICDM.S.F00 is true\n"); - if (ShouldSkip("ICDM.S.F00")) { - NextTest(); - return; - } - err = TestStep6bThReadsAcceptedCommandListAttributeFromDutIfIcdmsf00IsTrue_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6c: Read the optional command (StayActiveRequest) in AttributeList\n"); - if (ShouldSkip("ICDM.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6cReadTheOptionalCommandStayActiveRequestInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - if (ShouldSkip(" !ICDM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - if (ShouldSkip("ICDM.S.F00")) { - NextTest(); - return; - } - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: TH reads GeneratedCommandList attribute from DUT. The list MAY include these optional entries: 0x04: SHALL be included if and only if ICDM.S.C04.Tx(StayActiveResponse) \n"); - if (ShouldSkip("ICDM.S.C04.Tx")) { - NextTest(); - return; - } - err = TestStep7ThReadsGeneratedCommandListAttributeFromDutTheListMayIncludeTheseOptionalEntries0x04ShallBeIncludedIfAndOnlyIfICDMSC04TxStayActiveResponse_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsClusterRevisionAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDutBit0IsSetTo1IfIcdmsf00uatIsTrue_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT, bit 0 is set to 1 if ICDM.S.F00(UAT) is true,: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT, bit 0 is set to 1 if ICDM.S.F00(UAT) is true,: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDutBit1IsSetTo1IfIcdmsf01cipIsTrue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT, bit 1 is set to 1 if ICDM.S.F01(CIP) is true: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT, bit 1 is set to 1 if ICDM.S.F01(CIP) is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDutBit2IsSetTo1IfIcdmsf02uatIsTrue_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT, bit 2 is set to 1 if ICDM.S.F02(UAT) is true,: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT, bit 2 is set to 1 if ICDM.S.F02(UAT) is true,: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeRegisteredClientsInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute(RegisteredClients) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute(RegisteredClients) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cReadTheOptionalAttributeIcdCounterInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Read the optional attribute(IcdCounter) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: Read the optional attribute(IcdCounter) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalAttributeClientsSupportedPerFabricInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional attribute(ClientsSupportedPerFabric) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional attribute(ClientsSupportedPerFabric) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalAttributeUserActiveModeTriggerHintInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional attribute(UserActiveModeTriggerHint) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional attribute(UserActiveModeTriggerHint) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalAttributeUserActiveModeTriggerInstructionInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional attribute(UserActiveModeTriggerInstruction) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional attribute(UserActiveModeTriggerInstruction) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsAcceptedCommandListAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads AcceptedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsAcceptedCommandListAttributeFromDutIfIcdmsf00IsTrue_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads AcceptedCommandList attribute from DUT if ICDM.S.F00 is true: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads AcceptedCommandList attribute from DUT if ICDM.S.F00 is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cReadTheOptionalCommandStayActiveRequestInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: Read the optional command (StayActiveRequest) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 6c: Read the optional command (StayActiveRequest) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDutTheListMayIncludeTheseOptionalEntries0x04ShallBeIncludedIfAndOnlyIfICDMSC04TxStayActiveResponse_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT. The list MAY include these optional entries: 0x04: SHALL be included if and only if ICDM.S.C04.Tx(StayActiveResponse) : Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT. The list MAY include these optional entries: 0x04: SHALL be included if and only if ICDM.S.C04.Tx(StayActiveResponse) : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_I_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_I_1_1() - : TestCommandBridge("Test_TC_I_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_I_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1:Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the optional command(TriggerEffect) in AcceptedCommandList\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheOptionalCommandTriggerEffectInAcceptedCommandList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheOptionalCommandTriggerEffectInAcceptedCommandList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the optional command(TriggerEffect) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the optional command(TriggerEffect) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_I_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_I_2_1() - : TestCommandBridge("Test_TC_I_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_I_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the IdentifyTime attribute from the DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheIdentifyTimeAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the IdentifyType attribute from the DUT\n"); - if (ShouldSkip("I.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheIdentifyTypeAttributeFromTheDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheIdentifyTimeAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the IdentifyTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the IdentifyTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("identifyTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheIdentifyTypeAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the IdentifyType attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the IdentifyType attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("identifyType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("identifyType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyType", [value unsignedCharValue], 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_I_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_I_2_2() - : TestCommandBridge("Test_TC_I_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_I_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1a: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1aCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1b: TH reads the IdentifyType attribute from the DUT.\n"); - if (ShouldSkip("I.S.A0001")) { - NextTest(); - return; - } - err = TestStep1bThReadsTheIdentifyTypeAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH sends Identify command to DUT, with the IdentifyTime field set to 0x003c (60s).\n"); - if (ShouldSkip("I.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x003c60s_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH reads immediately IdentifyTime attribute from DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep2bThReadsImmediatelyIdentifyTimeAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 10000ms\n"); - err = TestWait10000ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2c: After 10 seconds, the TH reads IdentifyTime attribute from DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep2cAfter10SecondsTheThReadsIdentifyTimeAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: Before 60 seconds expire, TH sends Identify command to DUT, with the identify time field set to 0x0000 (stop identifying).\n"); - if (ShouldSkip("I.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4aBefore60SecondsExpireThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x0000StopIdentifying_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads immediately IdentifyTime attribute from DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bThReadsImmediatelyIdentifyTimeAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6a: Verify that the device enters its identification state using the IdentifyType from Step 1b, in order to indicate to an observer which of several nodes and/or endpoints it is.\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.A0001")) { - NextTest(); - return; - } - err = TestStep6aVerifyThatTheDeviceEntersItsIdentificationStateUsingTheIdentifyTypeFromStep1bInOrderToIndicateToAnObserverWhichOfSeveralNodesAndOrEndpointsItIs_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH writes a value of 0x000f (15s) to IdentifyTime attribute of DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep6aThWritesAValueOf0x000f15sToIdentifyTimeAttributeOfDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 15000ms\n"); - err = TestWait15000ms_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6b: After 15 seconds, the TH reads IdentifyTime attribute from DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep6bAfter15SecondsTheThReadsIdentifyTimeAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6b: Verify that the device terminates its identification state\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.A0001")) { - NextTest(); - return; - } - err = TestStep6bVerifyThatTheDeviceTerminatesItsIdentificationState_12(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1aCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull IdentifyTypeValue; - - CHIP_ERROR TestStep1bThReadsTheIdentifyTypeAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads the IdentifyType attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads the IdentifyType attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("identifyType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("identifyType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyType", [value unsignedCharValue], 5U)); - { - IdentifyTypeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x003c60s_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterIdentifyParams alloc] init]; - params.identifyTime = - [NSNumber numberWithUnsignedShort:60U]; - [cluster identifyWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Identify command to DUT, with the IdentifyTime field set to 0x003c (60s).: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Identify command to DUT, with the IdentifyTime field set to 0x003c (60s).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsImmediatelyIdentifyTimeAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads immediately IdentifyTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads immediately IdentifyTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 51U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 69U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10000ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cAfter10SecondsTheThReadsIdentifyTimeAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: After 10 seconds, the TH reads IdentifyTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: After 10 seconds, the TH reads IdentifyTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 42U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 58U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aBefore60SecondsExpireThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x0000StopIdentifying_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterIdentifyParams alloc] init]; - params.identifyTime = - [NSNumber numberWithUnsignedShort:0U]; - [cluster identifyWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Before 60 seconds expire, TH sends Identify command to DUT, with the identify time field set to 0x0000 (stop identifying).: Error: %@", err); - } else { - NSLog(@"Step 4a: Before 60 seconds expire, TH sends Identify command to DUT, with the identify time field set to 0x0000 (stop identifying).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsImmediatelyIdentifyTimeAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads immediately IdentifyTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads immediately IdentifyTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("IdentifyTime", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aVerifyThatTheDeviceEntersItsIdentificationStateUsingTheIdentifyTypeFromStep1bInOrderToIndicateToAnObserverWhichOfSeveralNodesAndOrEndpointsItIs_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6aThWritesAValueOf0x000f15sToIdentifyTimeAttributeOfDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id identifyTimeArgument; - identifyTimeArgument = - [NSNumber numberWithUnsignedShort:15U]; - [cluster writeAttributeIdentifyTimeWithValue:identifyTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH writes a value of 0x000f (15s) to IdentifyTime attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH writes a value of 0x000f (15s) to IdentifyTime attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait15000ms_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 15000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep6bAfter15SecondsTheThReadsIdentifyTimeAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: After 15 seconds, the TH reads IdentifyTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: After 15 seconds, the TH reads IdentifyTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bVerifyThatTheDeviceTerminatesItsIdentificationState_12() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_I_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_I_2_3() - : TestCommandBridge("Test_TC_I_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_I_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x00 (blink) and the effect variant field set to 0x00 (default)\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x00Default_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : DUT executes a blink effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesABlinkEffect_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : DUT executes a breathe effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesABreatheEffect_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2c: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x02 (okay) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x02OkayAndTheEffectVariantFieldSetTo0x00Default_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : DUT executes an okay effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesAnOkayEffect_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2d:TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x0b (channel change) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2dTHSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x0bChannelChangeAndTheEffectVariantFieldSetTo0x00Default_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : DUT executes a channel change effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesAChannelChangeEffect_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2e: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : DUT executes a breathe effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesABreatheEffect_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2f: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xfe (finish effect) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xfeFinishEffectAndTheEffectVariantFieldSetTo0x00Default_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : DUT stops the breathe effect after the current effect sequence\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutStopsTheBreatheEffectAfterTheCurrentEffectSequence_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2g: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2gThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : DUT executes a breathe effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesABreatheEffect_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 2h: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xff (stop effect) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2hThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : DUT stops the breathe effect as soon as possible.\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutStopsTheBreatheEffectAsSoonAsPossible_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3a: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x00 (blink) and the effect variant field set to 0x42 (unknown).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x42Unknown_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Check DUT executes a blink effect.\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestCheckDutExecutesABlinkEffect_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3b: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xff (stop effect) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : DUT stops any effect that may be still running as soon as possible\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutStopsAnyEffectThatMayBeStillRunningAsSoonAsPossible_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x00Default_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:0U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x00 (blink) and the effect variant field set to 0x00 (default): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x00 (blink) and the effect variant field set to 0x00 (default): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesABlinkEffect_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:1U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesABreatheEffect_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2cThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x02OkayAndTheEffectVariantFieldSetTo0x00Default_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:2U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x02 (okay) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 2c: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x02 (okay) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesAnOkayEffect_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2dTHSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x0bChannelChangeAndTheEffectVariantFieldSetTo0x00Default_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:11U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d:TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x0b (channel change) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 2d:TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x0b (channel change) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesAChannelChangeEffect_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2eThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:1U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 2e: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesABreatheEffect_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2fThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xfeFinishEffectAndTheEffectVariantFieldSetTo0x00Default_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:254U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xfe (finish effect) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 2f: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xfe (finish effect) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutStopsTheBreatheEffectAfterTheCurrentEffectSequence_12() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2gThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:1U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 2g: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesABreatheEffect_14() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2hThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:255U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2h: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xff (stop effect) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 2h: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xff (stop effect) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutStopsTheBreatheEffectAsSoonAsPossible_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x42Unknown_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:0U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:66U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x00 (blink) and the effect variant field set to 0x42 (unknown).: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x00 (blink) and the effect variant field set to 0x42 (unknown).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckDutExecutesABlinkEffect_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:255U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xff (stop effect) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xff (stop effect) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutStopsAnyEffectThatMayBeStillRunningAsSoonAsPossible_20() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_ILL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ILL_1_1() - : TestCommandBridge("Test_TC_ILL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ILL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ILL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ILL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT.\n"); - err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap attribute from the DUT.\n"); - err = TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("ILL.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads the optional attribute(LightSensorType) in AttributeList\n"); - if (ShouldSkip("ILL.S.A0004")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeLightSensorTypeInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the EventList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the AcceptedCommandList attribute from the DUT.\n"); - err = TestStep6ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads the GeneratedCommandList attribute from the DUT.\n"); - err = TestStep7ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeLightSensorTypeInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional attribute(LightSensorType) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional attribute(LightSensorType) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the AcceptedCommandList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the AcceptedCommandList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the GeneratedCommandList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the GeneratedCommandList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ILL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ILL_2_1() - : TestCommandBridge("Test_TC_ILL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ILL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ILL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ILL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Test Harness Client reads MinMeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0001")) { - NextTest(); - return; - } - err = TestStep2TestHarnessClientReadsMinMeasuredValueAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Test Harness Client reads MaxMeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0002")) { - NextTest(); - return; - } - err = TestStep3TestHarnessClientReadsMaxMeasuredValueAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: Test Harness Client reads MeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4TestHarnessClientReadsMeasuredValueAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads the Tolerance attribute from the DUT.\n"); - if (ShouldSkip("ILL.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheToleranceAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads the LightSensorType attribute from the DUT\n"); - if (ShouldSkip("ILL.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheLightSensorTypeAttributeFromTheDut_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2TestHarnessClientReadsMinMeasuredValueAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Test Harness Client reads MinMeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2: Test Harness Client reads MinMeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("minMeasuredValue", [value unsignedShortValue], 65533U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3TestHarnessClientReadsMaxMeasuredValueAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Test Harness Client reads MaxMeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 3: Test Harness Client reads MaxMeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value unsignedShortValue], 2U)); - VerifyOrReturn(CheckConstraintMaxValue("maxMeasuredValue", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4TestHarnessClientReadsMeasuredValueAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Test Harness Client reads MeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4: Test Harness Client reads MeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheToleranceAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("tolerance", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("tolerance", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("tolerance", [value unsignedShortValue], 2048U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheLightSensorTypeAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLightSensorTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the LightSensorType attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the LightSensorType attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lightSensorType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("lightSensorType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("lightSensorType", [value unsignedCharValue], 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ILL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ILL_2_2() - : TestCommandBridge("Test_TC_ILL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ILL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ILL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ILL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH reads MinMeasuredValue attribute from DUT\n"); - if (ShouldSkip("ILL.S.A0001")) { - NextTest(); - return; - } - err = TestStep2aThReadsMinMeasuredValueAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads MaxMeasuredValue attribute from DUT\n"); - if (ShouldSkip("ILL.S.A0002")) { - NextTest(); - return; - } - err = TestStep2bThReadsMaxMeasuredValueAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Cover the sensor or darken the room\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep3CoverTheSensorOrDarkenTheRoom_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 1s\n"); - err = TestWait1s_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: After a few seconds, TH reads MeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0000 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: Expose the sensor again to light\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep5ExposeTheSensorAgainToLight_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait 1s\n"); - err = TestWait1s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: After a few seconds, TH reads MeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0000 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep6AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2aThReadsMinMeasuredValueAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads MinMeasuredValue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads MinMeasuredValue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "int16u", "int16u")); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep2bThReadsMaxMeasuredValueAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads MaxMeasuredValue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads MaxMeasuredValue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "int16u", "int16u")); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3CoverTheSensorOrDarkenTheRoom_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for Successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait1s_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: After a few seconds, TH reads MeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4: After a few seconds, TH reads MeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value unsignedShortValue], 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ExposeTheSensorAgainToLight_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for Successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait1s_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep6AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: After a few seconds, TH reads MeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 6: After a few seconds, TH reads MeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_1_1() - : TestCommandBridge("Test_TC_LVL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !LVL.S.F00 && !LVL.S.F01 && !LVL.S.F02 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given LVL.S.F00(OO) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("LVL.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenLvlsf00ooEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given LVL.S.F01(LT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenLvlsf01ltEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given LVL.S.F02(FQ) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("LVL.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenLvlsf02fqEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads the optional attribute(StartUpCurrentLevel and RemainingTime) in AttributeList\n"); - if (ShouldSkip("LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheOptionalAttributeStartUpCurrentLevelAndRemainingTimeInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4b: TH reads the optional attribute(CurrentFrequency, MinFrequency and MinFrequency) in AttributeList\n"); - if (ShouldSkip("LVL.S.F02")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeCurrentFrequencyMinFrequencyAndMinFrequencyInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4c: TH reads the optional attribute(MinLevel) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeMinLevelInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4d: TH reads the optional attribute(MaxLevel) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0003")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeMaxLevelInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4e: TH reads the optional attribute(OnOffTransitionTime) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeOnOffTransitionTimeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4f: TH reads the optional attribute(OnTransitionTime) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalAttributeOnTransitionTimeInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4g: TH reads the optional attribute(OffTransitionTime) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalAttributeOffTransitionTimeInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4h: TH reads the optional attribute(DefaultMoveRate) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalAttributeDefaultMoveRateInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6a.1: TH reads the Feature-dependent(LVL.S.F02) command in AcceptedCommandList\n"); - if (ShouldSkip("LVL.S.F02")) { - NextTest(); - return; - } - err = TestStep6a1ThReadsTheFeatureDependentLVLSF02CommandInAcceptedCommandList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 5U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenLvlsf00ooEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given LVL.S.F00(OO) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given LVL.S.F00(OO) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenLvlsf01ltEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given LVL.S.F01(LT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given LVL.S.F01(LT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenLvlsf02fqEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given LVL.S.F02(FQ) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given LVL.S.F02(FQ) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheOptionalAttributeStartUpCurrentLevelAndRemainingTimeInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the optional attribute(StartUpCurrentLevel and RemainingTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the optional attribute(StartUpCurrentLevel and RemainingTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16384UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeCurrentFrequencyMinFrequencyAndMinFrequencyInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(CurrentFrequency, MinFrequency and MinFrequency) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(CurrentFrequency, MinFrequency and MinFrequency) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeMinLevelInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional attribute(MinLevel) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional attribute(MinLevel) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeMaxLevelInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional attribute(MaxLevel) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional attribute(MaxLevel) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeOnOffTransitionTimeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional attribute(OnOffTransitionTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional attribute(OnOffTransitionTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalAttributeOnTransitionTimeInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional attribute(OnTransitionTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional attribute(OnTransitionTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalAttributeOffTransitionTimeInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional attribute(OffTransitionTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional attribute(OffTransitionTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalAttributeDefaultMoveRateInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional attribute(DefaultMoveRate) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional attribute(DefaultMoveRate) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6a1ThReadsTheFeatureDependentLVLSF02CommandInAcceptedCommandList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a.1: TH reads the Feature-dependent(LVL.S.F02) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a.1: TH reads the Feature-dependent(LVL.S.F02) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_2_1() - : TestCommandBridge("Test_TC_LVL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the CurrentLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheCurrentLevelAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the RemainingTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheRemainingTimeAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the MinLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0002 && LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheMinLevelAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads the MinLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0002 && !LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheMinLevelAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads the MaxLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0003 && LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheMaxLevelAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads the MaxLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0003 && !LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheMaxLevelAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b & 4C TH reads the CurrentLevel attribute\n"); - if (ShouldSkip("LVL.S.F01 && LVL.S.A0002 && LVL.S.A0003")) { - NextTest(); - return; - } - err = TestStep4b4cThReadsTheCurrentLevelAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b & 4C TH reads the CurrentLevel attribute\n"); - if (ShouldSkip("LVL.S.A0002 && LVL.S.A0003 && !LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep4b4cThReadsTheCurrentLevelAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the CurrentFrequency attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0004")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheCurrentFrequencyAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the MinFrequency attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0005")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheMinFrequencyAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads the MaxFrequency attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0006")) { - NextTest(); - return; - } - err = TestStep7ThReadsTheMaxFrequencyAttributeFromTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7b & 7C TH reads the CurrentFrequency attribute\n"); - if (ShouldSkip("LVL.S.A0004 && LVL.S.A0005 && LVL.S.A0006")) { - NextTest(); - return; - } - err = TestStep7b7cThReadsTheCurrentFrequencyAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 8: TH reads the OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep8ThReadsTheOnOffTransitionTimeAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 9a: TH reads the OnLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.F01 && LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep9aThReadsTheOnLevelAttributeFromTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 9b: TH reads the OnLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0011 && !LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep9bThReadsTheOnLevelAttributeFromTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 10: TH reads the OnTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep10ThReadsTheOnTransitionTimeAttributeFromTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 11: TH reads the OffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep11ThReadsTheOffTransitionTimeAttributeFromTheDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 12: TH reads the DefaultMoveRate attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep12ThReadsTheDefaultMoveRateAttributeFromTheDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 13: TH reads the Options attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep13ThReadsTheOptionsAttributeFromTheDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 14: TH reads the StartUpCurrentLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A4000")) { - NextTest(); - return; - } - err = TestStep14ThReadsTheStartUpCurrentLevelAttributeFromTheDut_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable CurrentLevelValue; - - CHIP_ERROR TestStep1ThReadsTheCurrentLevelAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the CurrentLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the CurrentLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 254U)); - } - { - CurrentLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheRemainingTimeAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRemainingTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the RemainingTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the RemainingTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("remainingTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("remainingTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("remainingTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MinLevelValue; - - CHIP_ERROR TestStep3aThReadsTheMinLevelAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the MinLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the MinLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("MinLevel", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("minLevel", "int8u", "int8u")); - { - MinLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MinLevelFeatureMapNotSupportedValue; - - CHIP_ERROR TestStep3bThReadsTheMinLevelAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the MinLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the MinLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("minLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minLevel", [value unsignedCharValue], 254U)); - { - MinLevelFeatureMapNotSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxLevelValue; - - CHIP_ERROR TestStep4ThReadsTheMaxLevelAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the MaxLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the MaxLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("MaxLevel", actualValue, 254U)); - } - - VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], MinLevelValue)); - { - MaxLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxLevelFeatureMapNotSupportedValue; - - CHIP_ERROR TestStep4aThReadsTheMaxLevelAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the MaxLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the MaxLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], MinLevelFeatureMapNotSupportedValue)); - VerifyOrReturn(CheckConstraintMaxValue("maxLevel", [value unsignedCharValue], 254U)); - { - MaxLevelFeatureMapNotSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4b4cThReadsTheCurrentLevelAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], MinLevelValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], MaxLevelValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4b4cThReadsTheCurrentLevelAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], MinLevelFeatureMapNotSupportedValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], MaxLevelFeatureMapNotSupportedValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheCurrentFrequencyAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the CurrentFrequency attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the CurrentFrequency attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MinFrequencyValue; - - CHIP_ERROR TestStep6ThReadsTheMinFrequencyAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the MinFrequency attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the MinFrequency attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minFrequency", [value unsignedShortValue], 65535U)); - { - MinFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxFrequencyValue; - - CHIP_ERROR TestStep7ThReadsTheMaxFrequencyAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the MaxFrequency attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the MaxFrequency attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxFrequency", [value unsignedShortValue], 65535U)); - { - MaxFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7b7cThReadsTheCurrentFrequencyAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b & 7C TH reads the CurrentFrequency attribute: Error: %@", err); - } else { - NSLog(@"Step 7b & 7C TH reads the CurrentFrequency attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], MinFrequencyValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], MaxFrequencyValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsTheOnOffTransitionTimeAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads the OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads the OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onOffTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onOffTransitionTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9aThReadsTheOnLevelAttributeFromTheDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9a: TH reads the OnLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 9a: TH reads the OnLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("onLevel", [value unsignedCharValue], MinLevelValue)); - VerifyOrReturn(CheckConstraintMaxValue("onLevel", [value unsignedCharValue], MaxLevelValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9bThReadsTheOnLevelAttributeFromTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9b: TH reads the OnLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 9b: TH reads the OnLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("onLevel", [value unsignedCharValue], MinLevelFeatureMapNotSupportedValue)); - VerifyOrReturn(CheckConstraintMaxValue("onLevel", [value unsignedCharValue], MaxLevelFeatureMapNotSupportedValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsTheOnTransitionTimeAttributeFromTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads the OnTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads the OnTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onTransitionTime", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsTheOffTransitionTimeAttributeFromTheDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads the OffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads the OffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("offTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("offTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("offTransitionTime", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsTheDefaultMoveRateAttributeFromTheDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDefaultMoveRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads the DefaultMoveRate attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads the DefaultMoveRate attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("defaultMoveRate", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("defaultMoveRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("defaultMoveRate", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsTheOptionsAttributeFromTheDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads the Options attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads the Options attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("options", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsTheStartUpCurrentLevelAttributeFromTheDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads the StartUpCurrentLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads the StartUpCurrentLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpCurrentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("startUpCurrentLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpCurrentLevel", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_2_2() - : TestCommandBridge("Test_TC_LVL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("OnOffTransitionTimeConfigValue", 0, UINT16_MAX, &mOnOffTransitionTimeConfigValue); - AddArgument("OnLevelConfigValue", 0, UINT8_MAX, &mOnLevelConfigValue); - AddArgument("OnTransitionTimeConfigValue", 0, UINT16_MAX, &mOnTransitionTimeConfigValue); - AddArgument("OffTransitionTimeConfigValue", 0, UINT16_MAX, &mOffTransitionTimeConfigValue); - AddArgument("DefaultMoveRateConfigValue", 0, UINT8_MAX, &mDefaultMoveRateConfigValue); - AddArgument("StartUpCurrentLevelConfigValue", 0, UINT8_MAX, &mStartUpCurrentLevelConfigValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads the OnOffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep1aThReadsTheOnOffTransitionTimeAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH writes the OnOffTransitionTime attribute on the DUT with a different value than that read in 1a\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep1bThWritesTheOnOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn1a_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH reads the OnOffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep1cThReadsTheOnOffTransitionTimeAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH reads the OnLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheOnLevelAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH writes the OnLevel attribute on the DUT with a different value than that read in 2a\n"); - if (ShouldSkip("LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep2bThWritesTheOnLevelAttributeOnTheDutWithADifferentValueThanThatReadIn2a_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: TH reads the OnLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep2cThReadsTheOnLevelAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH reads the OnTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheOnTransitionTimeAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH writes the OnTransitionTime attribute on the DUT with a different value than that read in 3a\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep3bThWritesTheOnTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn3a_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3c: TH reads the OnTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOnTransitionTimeAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads the OffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheOffTransitionTimeAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4b: TH writes the OffTransitionTime attribute on the DUT with a different value than that read in 4a\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep4bThWritesTheOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn4a_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4c: TH reads the OffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOffTransitionTimeAttributeFromTheDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: TH reads the DefaultMoveRate attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep5aThReadsTheDefaultMoveRateAttributeFromTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: TH writes the DefaultMoveRate attribute on the DUT with a different value than that read in 5a\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep5bThWritesTheDefaultMoveRateAttributeOnTheDutWithADifferentValueThanThatReadIn5a_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5c: TH reads the DefaultMoveRate attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep5cThReadsTheDefaultMoveRateAttributeFromTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6a: TH reads the StartUpCurrentLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A4000")) { - NextTest(); - return; - } - err = TestStep6aThReadsTheStartUpCurrentLevelAttributeFromTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6b: TH writes the StartUpCurrentLevel attribute on the DUT with a different value than that read in 6a\n"); - if (ShouldSkip("LVL.S.A4000")) { - NextTest(); - return; - } - err = TestStep6bThWritesTheStartUpCurrentLevelAttributeOnTheDutWithADifferentValueThanThatReadIn6a_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6c: TH reads the StartUpCurrentLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A4000")) { - NextTest(); - return; - } - err = TestStep6cThReadsTheStartUpCurrentLevelAttributeFromTheDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : writes back default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestWritesBackDefaultValueOfOnOffTransitionTimeAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mOnOffTransitionTimeConfigValue; - chip::Optional mOnLevelConfigValue; - chip::Optional mOnTransitionTimeConfigValue; - chip::Optional mOffTransitionTimeConfigValue; - chip::Optional mDefaultMoveRateConfigValue; - chip::Optional mStartUpCurrentLevelConfigValue; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull OnOffTransitionTimeValue; - - CHIP_ERROR TestStep1aThReadsTheOnOffTransitionTimeAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads the OnOffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads the OnOffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onOffTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onOffTransitionTime", [value unsignedShortValue], 65535U)); - { - OnOffTransitionTimeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWritesTheOnOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn1a_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = mOnOffTransitionTimeConfigValue.HasValue() ? [NSNumber numberWithUnsignedShort:mOnOffTransitionTimeConfigValue.Value()] : [NSNumber numberWithUnsignedShort:10U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH writes the OnOffTransitionTime attribute on the DUT with a different value than that read in 1a: Error: %@", err); - } else { - NSLog(@"Step 1b: TH writes the OnOffTransitionTime attribute on the DUT with a different value than that read in 1a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsTheOnOffTransitionTimeAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads the OnOffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads the OnOffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOffTransitionTime", actualValue, mOnOffTransitionTimeConfigValue.HasValue() ? mOnOffTransitionTimeConfigValue.Value() : 10U)); - } - - VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintNotValue("onOffTransitionTime", value, OnOffTransitionTimeValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable OnLevelValue; - - CHIP_ERROR TestStep2aThReadsTheOnLevelAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the OnLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the OnLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("onLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onLevel", [value unsignedCharValue], 254U)); - } - { - OnLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWritesTheOnLevelAttributeOnTheDutWithADifferentValueThanThatReadIn2a_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onLevelArgument; - onLevelArgument = mOnLevelConfigValue.HasValue() ? [NSNumber numberWithUnsignedChar:mOnLevelConfigValue.Value()] : [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH writes the OnLevel attribute on the DUT with a different value than that read in 2a: Error: %@", err); - } else { - NSLog(@"Step 2b: TH writes the OnLevel attribute on the DUT with a different value than that read in 2a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsTheOnLevelAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads the OnLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads the OnLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OnLevel", actualValue)); - VerifyOrReturn(CheckValue("OnLevel", actualValue, mOnLevelConfigValue.HasValue() ? mOnLevelConfigValue.Value() : 5U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); - } - VerifyOrReturn(CheckConstraintNotValue("onLevel", value, OnLevelValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable OnTransitionTimeValue; - - CHIP_ERROR TestStep3aThReadsTheOnTransitionTimeAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the OnTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the OnTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onTransitionTime", [value unsignedShortValue], 65535U)); - } - { - OnTransitionTimeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThWritesTheOnTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn3a_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onTransitionTimeArgument; - onTransitionTimeArgument = mOnTransitionTimeConfigValue.HasValue() ? [NSNumber numberWithUnsignedShort:mOnTransitionTimeConfigValue.Value()] : [NSNumber numberWithUnsignedShort:5U]; - [cluster writeAttributeOnTransitionTimeWithValue:onTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH writes the OnTransitionTime attribute on the DUT with a different value than that read in 3a: Error: %@", err); - } else { - NSLog(@"Step 3b: TH writes the OnTransitionTime attribute on the DUT with a different value than that read in 3a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOnTransitionTimeAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the OnTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the OnTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OnTransitionTime", actualValue)); - VerifyOrReturn(CheckValue("OnTransitionTime", actualValue, mOnTransitionTimeConfigValue.HasValue() ? mOnTransitionTimeConfigValue.Value() : 5U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onTransitionTime", "int16u", "int16u")); - } - VerifyOrReturn(CheckConstraintNotValue("onTransitionTime", value, OnTransitionTimeValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable OffTransitionTimeValue; - - CHIP_ERROR TestStep4aThReadsTheOffTransitionTimeAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the OffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the OffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("offTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("offTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("offTransitionTime", [value unsignedShortValue], 65535U)); - } - { - OffTransitionTimeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWritesTheOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn4a_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id offTransitionTimeArgument; - offTransitionTimeArgument = mOffTransitionTimeConfigValue.HasValue() ? [NSNumber numberWithUnsignedShort:mOffTransitionTimeConfigValue.Value()] : [NSNumber numberWithUnsignedShort:10U]; - [cluster writeAttributeOffTransitionTimeWithValue:offTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH writes the OffTransitionTime attribute on the DUT with a different value than that read in 4a: Error: %@", err); - } else { - NSLog(@"Step 4b: TH writes the OffTransitionTime attribute on the DUT with a different value than that read in 4a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOffTransitionTimeAttributeFromTheDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the OffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the OffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OffTransitionTime", actualValue)); - VerifyOrReturn(CheckValue("OffTransitionTime", actualValue, mOffTransitionTimeConfigValue.HasValue() ? mOffTransitionTimeConfigValue.Value() : 10U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("offTransitionTime", "int16u", "int16u")); - } - VerifyOrReturn(CheckConstraintNotValue("offTransitionTime", value, OffTransitionTimeValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable DefaultMoveRatevalue; - - CHIP_ERROR TestStep5aThReadsTheDefaultMoveRateAttributeFromTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDefaultMoveRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH reads the DefaultMoveRate attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH reads the DefaultMoveRate attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("defaultMoveRate", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("defaultMoveRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("defaultMoveRate", [value unsignedCharValue], 255U)); - } - { - DefaultMoveRatevalue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThWritesTheDefaultMoveRateAttributeOnTheDutWithADifferentValueThanThatReadIn5a_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id defaultMoveRateArgument; - defaultMoveRateArgument = mDefaultMoveRateConfigValue.HasValue() ? [NSNumber numberWithUnsignedChar:mDefaultMoveRateConfigValue.Value()] : [NSNumber numberWithUnsignedChar:111U]; - [cluster writeAttributeDefaultMoveRateWithValue:defaultMoveRateArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH writes the DefaultMoveRate attribute on the DUT with a different value than that read in 5a: Error: %@", err); - } else { - NSLog(@"Step 5b: TH writes the DefaultMoveRate attribute on the DUT with a different value than that read in 5a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThReadsTheDefaultMoveRateAttributeFromTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDefaultMoveRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH reads the DefaultMoveRate attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH reads the DefaultMoveRate attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("DefaultMoveRate", actualValue)); - VerifyOrReturn(CheckValue("DefaultMoveRate", actualValue, mDefaultMoveRateConfigValue.HasValue() ? mDefaultMoveRateConfigValue.Value() : 111U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("defaultMoveRate", "int8u", "int8u")); - } - VerifyOrReturn(CheckConstraintNotValue("defaultMoveRate", value, DefaultMoveRatevalue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable StartUpCurrentLevelValue; - - CHIP_ERROR TestStep6aThReadsTheStartUpCurrentLevelAttributeFromTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads the StartUpCurrentLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads the StartUpCurrentLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpCurrentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("startUpCurrentLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpCurrentLevel", [value unsignedCharValue], 255U)); - } - { - StartUpCurrentLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThWritesTheStartUpCurrentLevelAttributeOnTheDutWithADifferentValueThanThatReadIn6a_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpCurrentLevelArgument; - startUpCurrentLevelArgument = mStartUpCurrentLevelConfigValue.HasValue() ? [NSNumber numberWithUnsignedChar:mStartUpCurrentLevelConfigValue.Value()] : [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeStartUpCurrentLevelWithValue:startUpCurrentLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH writes the StartUpCurrentLevel attribute on the DUT with a different value than that read in 6a: Error: %@", err); - } else { - NSLog(@"Step 6b: TH writes the StartUpCurrentLevel attribute on the DUT with a different value than that read in 6a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsTheStartUpCurrentLevelAttributeFromTheDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads the StartUpCurrentLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads the StartUpCurrentLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StartUpCurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("StartUpCurrentLevel", actualValue, mStartUpCurrentLevelConfigValue.HasValue() ? mStartUpCurrentLevelConfigValue.Value() : 5U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpCurrentLevel", "int8u", "int8u")); - } - VerifyOrReturn(CheckConstraintNotValue("startUpCurrentLevel", value, StartUpCurrentLevelValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWritesBackDefaultValueOfOnOffTransitionTimeAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"writes back default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"writes back default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_3_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_3_1() - : TestCommandBridge("Test_TC_LVL_3_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_3_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_3_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_3_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition Send On Command\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOnCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Check on/off attribute value is true after on command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep1ThWrites0ToTheOptionsAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1a: TH writes NULL to the OnLevel attribute\n"); - if (ShouldSkip("LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep1aThWritesNullToTheOnLevelAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: TH sends Off command to DUT\n"); - if (ShouldSkip("LVL.S.C04.Rsp && OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsOffCommandToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH sends a MoveToLevelWithOnOff command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsAMoveToLevelWithOnOffCommandToDutWithLevel50AndTransitionTime0Immediate_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT\n"); - if (ShouldSkip("OO.S.A0000 && LVL.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C04.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentLevelAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3a: TH sends On command to DUT\n"); - if (ShouldSkip("LVL.S.C04.Rsp && OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsOnCommandToDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentLevelAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4a: TH sends a MoveToLevel command to the DUT with Level = 200 and TransitionTime = 300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAMoveToLevelCommandToTheDutWithLevel200AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 10000ms\n"); - err = TestWait10000ms_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 10000ms\n"); - err = TestWait10000ms_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10000ms\n"); - err = TestWait10000ms_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d:After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 5000ms\n"); - err = TestWait5000ms_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition)\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && !LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 5a: TH writes 0x00 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep5aThWrites0x00ToTheOptionsAttribute_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 5b: TH reads the Options attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep5bThReadsTheOptionsAttributeFromTheDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 5c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep5cThSendsOnCommandToDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 5d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5e: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep5eThReadsCurrentLevelAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 5f: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5fThSendsOffCommandToDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 5g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 5h: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep5hThReadsCurrentLevelAttributeFromDut_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 5i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 5j: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep5jThReadsCurrentLevelAttributeFromDut_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 5k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 5l: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep5lThReadsCurrentLevelAttributeFromDut_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 6a: TH writes 0x01 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep6aThWrites0x01ToTheOptionsAttribute_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 6b: TH reads the Options attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheOptionsAttributeFromTheDut_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 6c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThSendsOnCommandToDut_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 6d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 6e: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6eThReadsCurrentLevelAttributeFromDut_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 6f: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6fThSendsOffCommandToDut_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 6g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 6h: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6hThReadsCurrentLevelAttributeFromDut_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 6i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 6j: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6jThReadsCurrentLevelAttributeFromDut_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 6k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 6l: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6lThReadsCurrentLevelAttributeFromDut_46(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 47; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionSendOnCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition Send On Command: Error: %@", err); - } else { - NSLog(@"Precondition Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThWrites0ToTheOptionsAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThWritesNullToTheOnLevelAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onLevelArgument; - onLevelArgument = nil; - [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes NULL to the OnLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes NULL to the OnLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsOffCommandToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsAMoveToLevelWithOnOffCommandToDutWithLevel50AndTransitionTime0Immediate_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends a MoveToLevelWithOnOff command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends a MoveToLevelWithOnOff command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThReadsCurrentLevelAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsOnCommandToDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentLevelAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAMoveToLevelCommandToTheDutWithLevel200AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a MoveToLevel command to the DUT with Level = 200 and TransitionTime = 300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a MoveToLevel command to the DUT with Level = 200 and TransitionTime = 300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10000ms_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10000ms_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 127U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 173U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10000ms_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d:After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d:After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5000ms_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrites0x00ToTheOptionsAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH writes 0x00 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 5a: TH writes 0x00 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsTheOptionsAttributeFromTheDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads the Options attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads the Options attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Options", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThSendsOnCommandToDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:100U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 5d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5eThReadsCurrentLevelAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5e: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5e: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5fThSendsOffCommandToDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5f: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5f: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:120U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 5g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5hThReadsCurrentLevelAttributeFromDut_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5h: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5h: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:140U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 5i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5jThReadsCurrentLevelAttributeFromDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5j: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5j: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:160U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Error: %@", err); - } else { - NSLog(@"Step 5k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5lThReadsCurrentLevelAttributeFromDut_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5l: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5l: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 160U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThWrites0x01ToTheOptionsAttribute_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH writes 0x01 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 6a: TH writes 0x01 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheOptionsAttributeFromTheDut_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the Options attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the Options attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Options", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThSendsOnCommandToDut_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 6c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:100U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 6d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eThReadsCurrentLevelAttributeFromDut_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6e: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fThSendsOffCommandToDut_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 6f: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:120U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 6g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6hThReadsCurrentLevelAttributeFromDut_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6h: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6h: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 120U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:140U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 6i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6jThReadsCurrentLevelAttributeFromDut_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6j: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6j: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 120U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:160U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Error: %@", err); - } else { - NSLog(@"Step 6k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6lThReadsCurrentLevelAttributeFromDut_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6l: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6l: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 160U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_4_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_4_1() - : TestCommandBridge("Test_TC_LVL_4_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_4_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_4_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_4_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition Send On Command\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOnCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Check on/off attribute value is true after on command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1b: TH reads the MaxLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0003")) { - NextTest(); - return; - } - err = TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp && LVL.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsOffCommandToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH sends a MoveWithOnOff command to DUT, with MoveMode =0x00 (up) and Rate =10 (units/s)\n"); - if (ShouldSkip("LVL.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsAMoveWithOnOffCommandToDutWithMoveMode0x00UpAndRate10UnitsS_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT\n"); - if (ShouldSkip("OO.S.A0000 && LVL.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C05.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentLevelAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5000ms\n"); - err = TestWait5000ms_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: After 5 seconds TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C05.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2eAfter5SecondsThReadsCurrentLevelAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsOnCommandToDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3c: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentLevelAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH sends a Move command to the DUT with MoveMode =0x00 (up) and Rate =5 (units/s)\n"); - if (ShouldSkip("LVL.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAMoveCommandToTheDutWithMoveMode0x00UpAndRate5UnitsS_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 10s\n"); - err = TestWait10s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10s\n"); - err = TestWait10s_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 10s\n"); - err = TestWait10s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 19s\n"); - err = TestWait19s_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4e: After another 19 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4eAfterAnother19SecondsThReadsCurrentLevelAttributeFromDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Precondition send Off Command\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOffCommand_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_25(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 26; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionSendOnCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition Send On Command: Error: %@", err); - } else { - NSLog(@"Precondition Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxLevel", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsOffCommandToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsAMoveWithOnOffCommandToDutWithMoveMode0x00UpAndRate10UnitsS_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveWithOnOffParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:10U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends a MoveWithOnOff command to DUT, with MoveMode =0x00 (up) and Rate =10 (units/s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends a MoveWithOnOff command to DUT, with MoveMode =0x00 (up) and Rate =10 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable CurrentLevelValue; - - CHIP_ERROR TestStep2dThReadsCurrentLevelAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); - } - { - CurrentLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5000ms_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eAfter5SecondsThReadsCurrentLevelAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: After 5 seconds TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: After 5 seconds TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsOnCommandToDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentLevelAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAMoveCommandToTheDutWithMoveMode0x00UpAndRate5UnitsS_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a Move command to the DUT with MoveMode =0x00 (up) and Rate =5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a Move command to the DUT with MoveMode =0x00 (up) and Rate =5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 127U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 173U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 230U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait19s_22() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 19000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4eAfterAnother19SecondsThReadsCurrentLevelAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: After another 19 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: After another 19 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionSendOffCommand_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition send Off Command: Error: %@", err); - } else { - NSLog(@"Precondition send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_5_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_5_1() - : TestCommandBridge("Test_TC_LVL_5_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_5_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_5_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_5_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition Send On Command\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOnCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Check on/off attribute value is true after on command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1: TH writes 0x00 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep1ThWrites0x00ToTheOptionsAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp && LVL.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsOffCommandToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b: TH sends a StepWithOnOff command to DUT, with StepMode =0x00 (up), StepSize =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsAStepWithOnOffCommandToDutWithStepMode0x00UpStepSize50AndTransitionTime0Immediate_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT\n"); - if (ShouldSkip("OO.S.A0000 && LVL.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3a: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsOnCommandToDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3c: Reads current level attribute from DUT\n"); - if (ShouldSkip("LVL.S.A0000 && LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3cReadsCurrentLevelAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH sends a Step command to the DUT with StepMode_ =0x00 (up), StepSize =150 and TransitionTime =300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s.\n"); - if (ShouldSkip("LVL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAStepCommandToTheDutWithStepMode0x00UpStepSize150AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 10s\n"); - err = TestWait10s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 10s\n"); - err = TestWait10s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 10s\n"); - err = TestWait10s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 5000ms\n"); - err = TestWait5000ms_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition)\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && !LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Precondition send Off Command\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOffCommand_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionSendOnCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition Send On Command: Error: %@", err); - } else { - NSLog(@"Precondition Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThWrites0x00ToTheOptionsAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes 0x00 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1: TH writes 0x00 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsOffCommandToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsAStepWithOnOffCommandToDutWithStepMode0x00UpStepSize50AndTransitionTime0Immediate_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterStepWithOnOffParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:0U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends a StepWithOnOff command to DUT, with StepMode =0x00 (up), StepSize =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends a StepWithOnOff command to DUT, with StepMode =0x00 (up), StepSize =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsOnCommandToDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cReadsCurrentLevelAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Reads current level attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: Reads current level attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAStepCommandToTheDutWithStepMode0x00UpStepSize150AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterStepParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:0U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:150U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a Step command to the DUT with StepMode_ =0x00 (up), StepSize =150 and TransitionTime =300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a Step command to the DUT with StepMode_ =0x00 (up), StepSize =150 and TransitionTime =300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 127U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 173U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5000ms_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionSendOffCommand_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition send Off Command: Error: %@", err); - } else { - NSLog(@"Precondition send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_6_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_6_1() - : TestCommandBridge("Test_TC_LVL_6_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_6_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_6_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_6_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1a: TH writes 0x00 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0x00ToTheOptionsAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.A0000 && LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentLevelAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s)\n"); - if (ShouldSkip("LVL.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2d: Wait 5000ms\n"); - err = TestStep2dWait5000ms_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3: After 5 seconds, TH sends a Stop command to the DUT\n"); - if (ShouldSkip("LVL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep3After5SecondsThSendsAStopCommandToTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Physically verify that the device has stopped transitioning\n"); - if (ShouldSkip("PICS_USER_PROMPT && LVL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.C03.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsCurrentLevelAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s)\n"); - if (ShouldSkip("LVL.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5000ms\n"); - err = TestWait5000ms_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: After 5 seconds, TH sends a StopWithOnOff command to the DUT\n"); - if (ShouldSkip("LVL.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep6After5SecondsThSendsAStopWithOnOffCommandToTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Physically verify that the device has stopped transitioning\n"); - if (ShouldSkip("PICS_USER_PROMPT && LVL.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.C07.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep7ThReadsCurrentLevelAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Precondition send Off Command\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOffCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThWrites0x00ToTheOptionsAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0x00 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0x00 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsCurrentLevelAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Error: %@", err); - } else { - NSLog(@"Step 2c: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dWait5000ms_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3After5SecondsThSendsAStopCommandToTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterStopParams alloc] init]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stopWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: After 5 seconds, TH sends a Stop command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: After 5 seconds, TH sends a Stop command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThReadsCurrentLevelAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 64U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 86U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Error: %@", err); - } else { - NSLog(@"Step 5: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5000ms_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep6After5SecondsThSendsAStopWithOnOffCommandToTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterStopWithOnOffParams alloc] init]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stopWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: After 5 seconds, TH sends a StopWithOnOff command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: After 5 seconds, TH sends a StopWithOnOff command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_14() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThReadsCurrentLevelAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionSendOffCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition send Off Command: Error: %@", err); - } else { - NSLog(@"Precondition send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_7_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_7_1() - : TestCommandBridge("Test_TC_LVL_7_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("RandomLevelValue", 0, UINT8_MAX, &mRandomLevelValue); - AddArgument("RandomFrequencyValue", 0, UINT16_MAX, &mRandomFrequencyValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_7_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_7_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_7_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0a: TH writes 0x00 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0x00ToTheOptionsAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1a: TH reads the MinLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0002")) { - NextTest(); - return; - } - err = TestStep1aThReadsTheMinLevelAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1b: TH reads the MaxLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0003")) { - NextTest(); - return; - } - err = TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1c: TH sends a MoveToLevel command to DUT, with the Level field set to a value between the MinLevel and MaxLevel values (if present, otherwise between 0x01 and 0xFE) and the TransitionTime field set to 0x0000 (move immediately).\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1cThSendsAMoveToLevelCommandToDutWithTheLevelFieldSetToAValueBetweenTheMinLevelAndMaxLevelValuesIfPresentOtherwiseBetween0x01And0xFEAndTheTransitionTimeFieldSetTo0x0000MoveImmediately_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait 100ms\n"); - err = TestWait100ms_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 1d: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1dThReadsCurrentLevelAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a: TH reads the CurrentFrequency attribute.\n"); - if (ShouldSkip("LVL.S.A0004")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheCurrentFrequencyAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2b: TH reads the MinFrequency attribute.\n"); - if (ShouldSkip("LVL.S.A0005")) { - NextTest(); - return; - } - err = TestStep2bThReadsTheMinFrequencyAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2c: TH reads the MaxFrequency attribute and check, if fmax < fmin, FAIL the test.\n"); - if (ShouldSkip("LVL.S.A0006")) { - NextTest(); - return; - } - err = TestStep2cThReadsTheMaxFrequencyAttributeAndCheckIfFmaxFminFailTheTest_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2d: sanity check on values read in steps 2a..2c, if fc < fmin, FAIL the test and fc > fmax, FAIL the test\n"); - if (ShouldSkip("LVL.S.A0004")) { - NextTest(); - return; - } - err = TestStep2dSanityCheckOnValuesReadInSteps2a2cIfFcFminFailTheTestAndFcFmaxFailTheTest_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to a random value frand, chosen such that: fmin < frand < fmax\n"); - if (ShouldSkip("LVL.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToARandomValueFrandChosenSuchThatFminFrandFmax_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 100ms\n"); - err = TestWait100ms_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3b: TH reads the CurrentFrequency attribute.\n"); - if (ShouldSkip("LVL.S.C08.Rsp && LVL.S.A0004")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheCurrentFrequencyAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to fmax + 1\n"); - if (ShouldSkip("LVL.S.C08.Rsp && PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep4aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmax1_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the CurrentFrequency attribute.\n"); - if (ShouldSkip("LVL.S.C08.Rsp && LVL.S.A0004 && PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheCurrentFrequencyAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to fmin - 1\n"); - if (ShouldSkip("LVL.S.C08.Rsp && PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep5aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmin1_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 5b: TH reads the CurrentFrequency attribute.\n"); - if (ShouldSkip("LVL.S.C08.Rsp && LVL.S.A0004 && PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep5bThReadsTheCurrentFrequencyAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mRandomLevelValue; - chip::Optional mRandomFrequencyValue; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0aThWrites0x00ToTheOptionsAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0x00 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0x00 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull minLevelValue; - - CHIP_ERROR TestStep1aThReadsTheMinLevelAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads the MinLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads the MinLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("minLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minLevel", [value unsignedCharValue], 254U)); - { - minLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull maxLevelValue; - - CHIP_ERROR TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxLevel", [value unsignedCharValue], 254U)); - { - maxLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThSendsAMoveToLevelCommandToDutWithTheLevelFieldSetToAValueBetweenTheMinLevelAndMaxLevelValuesIfPresentOtherwiseBetween0x01And0xFEAndTheTransitionTimeFieldSetTo0x0000MoveImmediately_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = mRandomLevelValue.HasValue() ? [NSNumber numberWithUnsignedChar:mRandomLevelValue.Value()] : [NSNumber numberWithUnsignedChar:100U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH sends a MoveToLevel command to DUT, with the Level field set to a value between the MinLevel and MaxLevel values (if present, otherwise between 0x01 and 0xFE) and the TransitionTime field set to 0x0000 (move immediately).: Error: %@", err); - } else { - NSLog(@"Step 1c: TH sends a MoveToLevel command to DUT, with the Level field set to a value between the MinLevel and MaxLevel values (if present, otherwise between 0x01 and 0xFE) and the TransitionTime field set to 0x0000 (move immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1dThReadsCurrentLevelAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, mRandomLevelValue.HasValue() ? mRandomLevelValue.Value() : 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull CurrentFrequencyValue; - - CHIP_ERROR TestStep2aThReadsTheCurrentFrequencyAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the CurrentFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the CurrentFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], 65535U)); - { - CurrentFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MinFrequencyValue; - - CHIP_ERROR TestStep2bThReadsTheMinFrequencyAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads the MinFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads the MinFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minFrequency", [value unsignedShortValue], 65535U)); - { - MinFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxFrequencyValue; - - CHIP_ERROR TestStep2cThReadsTheMaxFrequencyAttributeAndCheckIfFmaxFminFailTheTest_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads the MaxFrequency attribute and check, if fmax < fmin, FAIL the test.: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads the MaxFrequency attribute and check, if fmax < fmin, FAIL the test.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxFrequency", [value unsignedShortValue], MinFrequencyValue)); - VerifyOrReturn(CheckConstraintMaxValue("maxFrequency", [value unsignedShortValue], 65535U)); - { - MaxFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dSanityCheckOnValuesReadInSteps2a2cIfFcFminFailTheTestAndFcFmaxFailTheTest_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: sanity check on values read in steps 2a..2c, if fc < fmin, FAIL the test and fc > fmax, FAIL the test: Error: %@", err); - } else { - NSLog(@"Step 2d: sanity check on values read in steps 2a..2c, if fc < fmin, FAIL the test and fc > fmax, FAIL the test: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], MinFrequencyValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], MaxFrequencyValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToARandomValueFrandChosenSuchThatFminFrandFmax_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToClosestFrequencyParams alloc] init]; - params.frequency = mRandomFrequencyValue.HasValue() ? [NSNumber numberWithUnsignedShort:mRandomFrequencyValue.Value()] : [NSNumber numberWithUnsignedShort:30000U]; - [cluster moveToClosestFrequencyWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to a random value frand, chosen such that: fmin < frand < fmax: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to a random value frand, chosen such that: fmin < frand < fmax: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsTheCurrentFrequencyAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the CurrentFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the CurrentFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentFrequency", actualValue, mRandomFrequencyValue.HasValue() ? mRandomFrequencyValue.Value() : 30000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmax1_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4bThReadsTheCurrentFrequencyAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the CurrentFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the CurrentFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentFrequency", actualValue, mRandomFrequencyValue.HasValue() ? mRandomFrequencyValue.Value() : 30000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmin1_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5bThReadsTheCurrentFrequencyAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads the CurrentFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads the CurrentFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentFrequency", actualValue, mRandomFrequencyValue.HasValue() ? mRandomFrequencyValue.Value() : 30000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LCFG_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LCFG_1_1() - : TestCommandBridge("Test_TC_LCFG_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LCFG_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LCFG_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LCFG_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LUNIT_1_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LUNIT_1_2() - : TestCommandBridge("Test_TC_LUNIT_1_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LUNIT_1_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LUNIT_1_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LUNIT_1_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !LUNIT.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Given LUNIT.S.F00(TEMP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("LUNIT.S.F00")) { - NextTest(); - return; - } - err = TestStep3GivenLunitsf00tempEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads Feature dependent(LUNIT.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("LUNIT.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentLUNITSF00AttributeInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3GivenLunitsf00tempEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Given LUNIT.S.F00(TEMP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3: Given LUNIT.S.F00(TEMP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentLUNITSF00AttributeInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent(LUNIT.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent(LUNIT.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LUNIT_3_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LUNIT_3_1() - : TestCommandBridge("Test_TC_LUNIT_3_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LUNIT_3_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LUNIT_3_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LUNIT_3_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads from the DUT the TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsFromTheDutTheTemperatureUnit_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH writes 0 to TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Fahrenheit")) { - NextTest(); - return; - } - err = TestStep2ThWrites0ToTemperatureUnit_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Fahrenheit")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTemperatureUnit_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes 1 to TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Celsius")) { - NextTest(); - return; - } - err = TestStep4ThWrites1ToTemperatureUnit_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Celsius")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheTemperatureUnit_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH writes 2 to TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Kelvin")) { - NextTest(); - return; - } - err = TestStep6ThWrites2ToTemperatureUnit_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Kelvin")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheTemperatureUnit_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH writes 5 to TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000")) { - NextTest(); - return; - } - err = TestStep8ThWrites5ToTemperatureUnit_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsFromTheDutTheTemperatureUnit_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads from the DUT the TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads from the DUT the TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("temperatureUnit", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThWrites0ToTemperatureUnit_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureUnitArgument; - temperatureUnitArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH writes 0 to TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 2: TH writes 0 to TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTemperatureUnit_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureUnit", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThWrites1ToTemperatureUnit_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureUnitArgument; - temperatureUnitArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes 1 to TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 4: TH writes 1 to TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheTemperatureUnit_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureUnit", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThWrites2ToTemperatureUnit_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureUnitArgument; - temperatureUnitArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH writes 2 to TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 6: TH writes 2 to TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheTemperatureUnit_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureUnit", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThWrites5ToTemperatureUnit_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureUnitArgument; - temperatureUnitArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH writes 5 to TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 8: TH writes 5 to TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LTIME_1_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LTIME_1_2() - : TestCommandBridge("Test_TC_LTIME_1_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LTIME_1_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LTIME_1_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LTIME_1_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads Feature dependent attribute(ActiveCalendarType) in AttributeList from DUT\n"); - if (ShouldSkip("LTIME.S.F00 && LTIME.S.A0001")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentAttributeActiveCalendarTypeInAttributeListFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads Feature dependent attribute(SupportedCalendarTypes) in AttributeList from DUT\n"); - if (ShouldSkip("LTIME.S.F00 && LTIME.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentAttributeSupportedCalendarTypesInAttributeListFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - VerifyOrReturn(CheckConstraintMinValue("featureMap", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("featureMap", [value unsignedIntValue], 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentAttributeActiveCalendarTypeInAttributeListFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent attribute(ActiveCalendarType) in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent attribute(ActiveCalendarType) in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentAttributeSupportedCalendarTypesInAttributeListFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads Feature dependent attribute(SupportedCalendarTypes) in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads Feature dependent attribute(SupportedCalendarTypes) in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LTIME_3_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LTIME_3_1() - : TestCommandBridge("Test_TC_LTIME_3_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LTIME_3_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LTIME_3_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LTIME_3_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads HourFormat attribute from DUT\n"); - if (ShouldSkip("LTIME.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsHourFormatAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: If (LTIME.S.A0000.12HR) TH writes 0 to HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.M.12HR")) { - NextTest(); - return; - } - err = TestStep2IfLtimesa000012hrThWrites0ToHourFormatAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.A0000")) { - NextTest(); - return; - } - err = TestStep3ThReadsHourFormatAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: If (LTIME.S.A0000.24HR) TH writes 1 to HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.M.24HR")) { - NextTest(); - return; - } - err = TestStep4IfLtimesa000024hrThWrites1ToHourFormatAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.A0000")) { - NextTest(); - return; - } - err = TestStep5ThReadsHourFormatAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads ActiveCalendarType attribute from DUT\n"); - if (ShouldSkip("LTIME.S.A0001")) { - NextTest(); - return; - } - err = TestStep6ThReadsActiveCalendarTypeAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads SupportedCalendarTypes attribute from DUT\n"); - if (ShouldSkip("LTIME.S.A0002")) { - NextTest(); - return; - } - err = TestStep7ThReadsSupportedCalendarTypesAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH writes value in PIXIT.LTIME.SCT to ActiveCalendarType attribute, followed by reading the ActiveCalendarType attribute value\n"); - if (ShouldSkip("LTIME.S.A0001 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep8ThWritesValueInPixitltimesctToActiveCalendarTypeAttributeFollowedByReadingTheActiveCalendarTypeAttributeValue_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: Repeat step 8 for all the values in PIXIT.LTIME.SCT\n"); - if (ShouldSkip("LTIME.S.A0001 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep9RepeatStep8ForAllTheValuesInPixitltimesct_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 10: TH writes 50 to ActiveCalendarType attribute\n"); - if (ShouldSkip("LTIME.S.A0001")) { - NextTest(); - return; - } - err = TestStep10ThWrites50ToActiveCalendarTypeAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 11: TH writes 5 to HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.A0000")) { - NextTest(); - return; - } - err = TestStep11ThWrites5ToHourFormatAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsHourFormatAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeHourFormatWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads HourFormat attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads HourFormat attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("hourFormat", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2IfLtimesa000012hrThWrites0ToHourFormatAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id hourFormatArgument; - hourFormatArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeHourFormatWithValue:hourFormatArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: If (LTIME.S.A0000.12HR) TH writes 0 to HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 2: If (LTIME.S.A0000.12HR) TH writes 0 to HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsHourFormatAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeHourFormatWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("HourFormat", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4IfLtimesa000024hrThWrites1ToHourFormatAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id hourFormatArgument; - hourFormatArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeHourFormatWithValue:hourFormatArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: If (LTIME.S.A0000.24HR) TH writes 1 to HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 4: If (LTIME.S.A0000.24HR) TH writes 1 to HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsHourFormatAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeHourFormatWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("HourFormat", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsActiveCalendarTypeAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeActiveCalendarTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads ActiveCalendarType attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads ActiveCalendarType attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("activeCalendarType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("activeCalendarType", [value unsignedCharValue], 11U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsSupportedCalendarTypesAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedCalendarTypesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads SupportedCalendarTypes attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads SupportedCalendarTypes attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxLength("supportedCalendarTypes", value, 12)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThWritesValueInPixitltimesctToActiveCalendarTypeAttributeFollowedByReadingTheActiveCalendarTypeAttributeValue_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep9RepeatStep8ForAllTheValuesInPixitltimesct_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10ThWrites50ToActiveCalendarTypeAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id activeCalendarTypeArgument; - activeCalendarTypeArgument = - [NSNumber numberWithUnsignedChar:50U]; - [cluster writeAttributeActiveCalendarTypeWithValue:activeCalendarTypeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH writes 50 to ActiveCalendarType attribute: Error: %@", err); - } else { - NSLog(@"Step 10: TH writes 50 to ActiveCalendarType attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThWrites5ToHourFormatAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id hourFormatArgument; - hourFormatArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeHourFormatWithValue:hourFormatArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH writes 5 to HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 11: TH writes 5 to HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LWM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LWM_1_1() - : TestCommandBridge("Test_TC_LWM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LWM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LWM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LWM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3:TH reads from the DUT the FeatureMap attribute., bit 0: SHALL be 1 if and only if LWM.S.F00(DEPONOFF)\n"); - if (ShouldSkip("LWM.S.F00")) { - NextTest(); - return; - } - err = TestStep3thReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfLwmsf00deponoff_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !LWM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList\n"); - if (ShouldSkip("LWM.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the Feature dependent attribute(DEPONOFF) in AttributeList\n"); - if (ShouldSkip("LWM.S.F00")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentAttributeDEPONOFFInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3thReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfLwmsf00deponoff_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3:TH reads from the DUT the FeatureMap attribute., bit 0: SHALL be 1 if and only if LWM.S.F00(DEPONOFF): Error: %@", err); - } else { - NSLog(@"Step 3:TH reads from the DUT the FeatureMap attribute., bit 0: SHALL be 1 if and only if LWM.S.F00(DEPONOFF): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentAttributeDEPONOFFInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent attribute(DEPONOFF) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent attribute(DEPONOFF) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LWM_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LWM_2_1() - : TestCommandBridge("Test_TC_LWM_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("NewMode_CHANGE_OK", 0, UINT8_MAX, &mNewModeChangeOk); - AddArgument("NewMode_CHANGE_FAIL", 0, UINT8_MAX, &mNewModeChangeFail); - AddArgument("invalid_mode_th", 0, UINT8_MAX, &mInvalidModeTh); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LWM_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LWM_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LWM_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1:Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the SupportedModes attribute.\n"); - if (ShouldSkip("LWM.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheSupportedModesAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the CurrentMode attribute.\n"); - if (ShouldSkip("LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheCurrentModeAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH sends a ChangeToMode command to the DUT with NewMode set to new_mode_th\n"); - if (ShouldSkip("LWM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsAChangeToModeCommandToTheDutWithNewModeSetToNewModeTh_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: Manually put the device in a state from which it will FAIL to transition to PIXIT.LWM.MODE_CHANGE_FAIL\n"); - if (ShouldSkip("LWM.S.M.CAN_TEST_MODE_FAILURE && LWM.S.M.CAN_MANUALLY_CONTROLLED && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep5ManuallyPutTheDeviceInAStateFromWhichItWillFailToTransitionToPixitlwmmodeChangeFail_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the CurrentMode attribute.\n"); - if (ShouldSkip("LWM.S.A0001 && LWM.S.M.CAN_MANUALLY_CONTROLLED")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheCurrentModeAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_FAIL\n"); - if (ShouldSkip("LWM.S.M.CAN_TEST_MODE_FAILURE && LWM.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep7ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeFail_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the CurrentMode attribute.\n"); - if (ShouldSkip("LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheCurrentModeAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: Manually put the device in a state from which it will SUCCESSFULLY transition to PIXIT.LWM.MODE_CHANGE_OK\n"); - if (ShouldSkip("LWM.S.M.CAN_MANUALLY_CONTROLLED && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep9ManuallyPutTheDeviceInAStateFromWhichItWillSuccessfullyTransitionToPixitlwmmodeChangeOk_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the CurrentMode attribute.\n"); - if (ShouldSkip("LWM.S.M.CAN_MANUALLY_CONTROLLED && LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheCurrentModeAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_OK\n"); - if (ShouldSkip("LWM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep11ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeOk_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK\n"); - if (ShouldSkip("LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH sends a ChangeToMode command to the DUT with NewMode set to invalid_mode_th\n"); - if (ShouldSkip("LWM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsAChangeToModeCommandToTheDutWithNewModeSetToInvalidModeTh_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK\n"); - if (ShouldSkip("LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep14ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mNewModeChangeOk; - chip::Optional mNewModeChangeFail; - chip::Optional mInvalidModeTh; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheSupportedModesAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedModesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the SupportedModes attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the SupportedModes attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedModes", "list", "list")); - VerifyOrReturn(CheckConstraintMinLength("supportedModes", value, 2)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull old_current_mode_dut; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheCurrentModeAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the CurrentMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); - { - old_current_mode_dut = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsAChangeToModeCommandToTheDutWithNewModeSetToNewModeTh_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLaundryWasherModeClusterChangeToModeParams alloc] init]; - params.newMode = - [old_current_mode_dut copy]; - [cluster changeToModeWithParams:params completion: - ^(MTRLaundryWasherModeClusterChangeToModeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a ChangeToMode command to the DUT with NewMode set to new_mode_th: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a ChangeToMode command to the DUT with NewMode set to new_mode_th: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ManuallyPutTheDeviceInAStateFromWhichItWillFailToTransitionToPixitlwmmodeChangeFail_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nonnull Step6_current_mode_dut; - - CHIP_ERROR TestStep6ThReadsFromTheDutTheCurrentModeAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the CurrentMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); - { - Step6_current_mode_dut = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeFail_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheCurrentModeAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the CurrentMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, Step6_current_mode_dut)); - } - - VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ManuallyPutTheDeviceInAStateFromWhichItWillSuccessfullyTransitionToPixitlwmmodeChangeOk_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nonnull Step10_current_mode_dut; - - CHIP_ERROR TestStep10ThReadsFromTheDutTheCurrentModeAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the CurrentMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); - { - Step10_current_mode_dut = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeOk_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLaundryWasherModeClusterChangeToModeParams alloc] init]; - params.newMode = mNewModeChangeOk.HasValue() ? [NSNumber numberWithUnsignedChar:mNewModeChangeOk.Value()] : [NSNumber numberWithUnsignedChar:2U]; - [cluster changeToModeWithParams:params completion: - ^(MTRLaundryWasherModeClusterChangeToModeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_OK: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, mNewModeChangeOk.HasValue() ? mNewModeChangeOk.Value() : 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThSendsAChangeToModeCommandToTheDutWithNewModeSetToInvalidModeTh_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLaundryWasherModeClusterChangeToModeParams alloc] init]; - params.newMode = mInvalidModeTh.HasValue() ? [NSNumber numberWithUnsignedChar:mInvalidModeTh.Value()] : [NSNumber numberWithUnsignedChar:5U]; - [cluster changeToModeWithParams:params completion: - ^(MTRLaundryWasherModeClusterChangeToModeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends a ChangeToMode command to the DUT with NewMode set to invalid_mode_th: Error: %@", err); - } else { - NSLog(@"Step 13: TH sends a ChangeToMode command to the DUT with NewMode set to invalid_mode_th: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, mNewModeChangeOk.HasValue() ? mNewModeChangeOk.Value() : 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WASHERCTRL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WASHERCTRL_1_1() - : TestCommandBridge("Test_TC_WASHERCTRL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WASHERCTRL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WASHERCTRL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WASHERCTRL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH\n"); - err = TestCommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute. If WASHERCTRL.S.F00(SPIN) & WASHERCTRL.S.F01(RINSE) are false\n"); - if (ShouldSkip("!WASHERCTRL.S.F00 && !WASHERCTRL.S.F01")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeIfWasherctrlsf00spinWasherctrlsf01rinseAreFalse_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute, bit 0 set to 1 if the DUT is capable of controlling the washer using the spin attributes (WASHERCTRL.S.F00(SPIN) is true)\n"); - if (ShouldSkip("WASHERCTRL.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0SetTo1IfTheDutIsCapableOfControllingTheWasherUsingTheSpinAttributesWasherctrlsf00spinIsTrue_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads from the DUT the FeatureMap attribute, bit 1 set to 1 if the DUT supports rinse attributes (WASHERCTRL.S.F01(RINSE) is true)\n"); - if (ShouldSkip("WASHERCTRL.S.F01")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit1SetTo1IfTheDutSupportsRinseAttributesWasherctrlsf01rinseIsTrue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads the feature dependent(WASHERCTRL.S.F00) attributes in AttributeList from DUT.\n"); - if (ShouldSkip("WASHERCTRL.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentWASHERCTRLSF00AttributesInAttributeListFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads the feature dependent(WASHERCTRL.S.F01) attributes in AttributeList from DUT.\n"); - if (ShouldSkip("WASHERCTRL.S.F01")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentWASHERCTRLSF01AttributesInAttributeListFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeIfWasherctrlsf00spinWasherctrlsf01rinseAreFalse_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. If WASHERCTRL.S.F00(SPIN) & WASHERCTRL.S.F01(RINSE) are false: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. If WASHERCTRL.S.F00(SPIN) & WASHERCTRL.S.F01(RINSE) are false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0SetTo1IfTheDutIsCapableOfControllingTheWasherUsingTheSpinAttributesWasherctrlsf00spinIsTrue_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0 set to 1 if the DUT is capable of controlling the washer using the spin attributes (WASHERCTRL.S.F00(SPIN) is true): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0 set to 1 if the DUT is capable of controlling the washer using the spin attributes (WASHERCTRL.S.F00(SPIN) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit1SetTo1IfTheDutSupportsRinseAttributesWasherctrlsf01rinseIsTrue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 1 set to 1 if the DUT supports rinse attributes (WASHERCTRL.S.F01(RINSE) is true): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 1 set to 1 if the DUT supports rinse attributes (WASHERCTRL.S.F01(RINSE) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentWASHERCTRLSF00AttributesInAttributeListFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the feature dependent(WASHERCTRL.S.F00) attributes in AttributeList from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the feature dependent(WASHERCTRL.S.F00) attributes in AttributeList from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentWASHERCTRLSF01AttributesInAttributeListFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the feature dependent(WASHERCTRL.S.F01) attributes in AttributeList from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the feature dependent(WASHERCTRL.S.F01) attributes in AttributeList from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WASHERCTRL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WASHERCTRL_2_1() - : TestCommandBridge("Test_TC_WASHERCTRL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("SpinSpeedCurrentValue", 0, UINT8_MAX, &mSpinSpeedCurrentValue); - AddArgument("unsupportedSpinSpeedCurrentValue", 0, UINT8_MAX, &mUnsupportedSpinSpeedCurrentValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WASHERCTRL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WASHERCTRL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WASHERCTRL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the SpinSpeeds attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheSpinSpeedsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the SpinSpeedCurrent attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheSpinSpeedCurrentAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Verify that the DUT response contains a uint8 with value between 0 and numSpinSpeeds-1 inclusive.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyThatTheDutResponseContainsAUint8WithValueBetween0AndNumSpinSpeeds1Inclusive_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes a supported SpinSpeedCurrent attribute that is a valid index into the list of spin speeds (0 to numSpinSpeeds-1)\n"); - if (ShouldSkip("WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep4ThWritesASupportedSpinSpeedCurrentAttributeThatIsAValidIndexIntoTheListOfSpinSpeeds0ToNumSpinSpeeds1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 2 seconds\n"); - err = TestWait2Seconds_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: after a few seconds, TH reads from the DUT the SpinSpeedCurrent attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep5AfterAFewSecondsThReadsFromTheDutTheSpinSpeedCurrentAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH writes an unsupported SpinSpeedCurrent attribute that is other than 0 to DUT\n"); - if (ShouldSkip("WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep6ThWritesAnUnsupportedSpinSpeedCurrentAttributeThatIsOtherThan0ToDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mSpinSpeedCurrentValue; - chip::Optional mUnsupportedSpinSpeedCurrentValue; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheSpinSpeedsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpinSpeedsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the SpinSpeeds attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the SpinSpeeds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("spinSpeeds", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("spinSpeeds", value, 16)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheSpinSpeedCurrentAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpinSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the SpinSpeedCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the SpinSpeedCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("spinSpeedCurrent", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("spinSpeedCurrent", [value unsignedCharValue], 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheDutResponseContainsAUint8WithValueBetween0AndNumSpinSpeeds1Inclusive_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThWritesASupportedSpinSpeedCurrentAttributeThatIsAValidIndexIntoTheListOfSpinSpeeds0ToNumSpinSpeeds1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id spinSpeedCurrentArgument; - spinSpeedCurrentArgument = mSpinSpeedCurrentValue.HasValue() ? [NSNumber numberWithUnsignedChar:mSpinSpeedCurrentValue.Value()] : [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeSpinSpeedCurrentWithValue:spinSpeedCurrentArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes a supported SpinSpeedCurrent attribute that is a valid index into the list of spin speeds (0 to numSpinSpeeds-1): Error: %@", err); - } else { - NSLog(@"Step 4: TH writes a supported SpinSpeedCurrent attribute that is a valid index into the list of spin speeds (0 to numSpinSpeeds-1): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2Seconds_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheSpinSpeedCurrentAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpinSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SpinSpeedCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SpinSpeedCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpinSpeedCurrent", actualValue)); - VerifyOrReturn(CheckValue("SpinSpeedCurrent", actualValue, mSpinSpeedCurrentValue.HasValue() ? mSpinSpeedCurrentValue.Value() : 3U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("spinSpeedCurrent", "int8u", "int8u")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThWritesAnUnsupportedSpinSpeedCurrentAttributeThatIsOtherThan0ToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id spinSpeedCurrentArgument; - spinSpeedCurrentArgument = mUnsupportedSpinSpeedCurrentValue.HasValue() ? [NSNumber numberWithUnsignedChar:mUnsupportedSpinSpeedCurrentValue.Value()] : [NSNumber numberWithUnsignedChar:17U]; - [cluster writeAttributeSpinSpeedCurrentWithValue:spinSpeedCurrentArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH writes an unsupported SpinSpeedCurrent attribute that is other than 0 to DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH writes an unsupported SpinSpeedCurrent attribute that is other than 0 to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WASHERCTRL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WASHERCTRL_2_2() - : TestCommandBridge("Test_TC_WASHERCTRL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("NumberOfRinsesValue", 0, UINT8_MAX, &mNumberOfRinsesValue); - AddArgument("unsupportedNumberOfRinsesValue", 0, UINT8_MAX, &mUnsupportedNumberOfRinsesValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WASHERCTRL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WASHERCTRL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WASHERCTRL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the NumberOfRinses attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0002")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheNumberOfRinsesAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the SupportedRinses attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0003")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheSupportedRinsesAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH writes a supported NumberOfRinses attribute to DUT within the range of the SupportedRinses list\n"); - if (ShouldSkip("WASHERCTRL.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThWritesASupportedNumberOfRinsesAttributeToDutWithinTheRangeOfTheSupportedRinsesList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 2 seconds\n"); - err = TestWait2Seconds_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: after a few seconds, TH reads from the DUT the NumberOfRinses attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0002")) { - NextTest(); - return; - } - err = TestStep5AfterAFewSecondsThReadsFromTheDutTheNumberOfRinsesAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: Operate device to set the condition to read only\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && WASHERCTRL.S.M.ManuallyControlled")) { - NextTest(); - return; - } - err = TestStep6OperateDeviceToSetTheConditionToReadOnly_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH writes an unsupported NumberOfRinses attribute to DUT while DUT is not in a valid state.\n"); - if (ShouldSkip("WASHERCTRL.S.M.ManuallyControlled && WASHERCTRL.S.A0002")) { - NextTest(); - return; - } - err = TestStep7ThWritesAnUnsupportedNumberOfRinsesAttributeToDutWhileDutIsNotInAValidState_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_IN_STATE)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mNumberOfRinsesValue; - chip::Optional mUnsupportedNumberOfRinsesValue; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheNumberOfRinsesAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfRinsesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the NumberOfRinses attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the NumberOfRinses attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("numberOfRinses", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("numberOfRinses", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfRinses", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheSupportedRinsesAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedRinsesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the SupportedRinses attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the SupportedRinses attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedRinses", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("supportedRinses", value, 4)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThWritesASupportedNumberOfRinsesAttributeToDutWithinTheRangeOfTheSupportedRinsesList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id numberOfRinsesArgument; - numberOfRinsesArgument = mNumberOfRinsesValue.HasValue() ? [NSNumber numberWithUnsignedChar:mNumberOfRinsesValue.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeNumberOfRinsesWithValue:numberOfRinsesArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes a supported NumberOfRinses attribute to DUT within the range of the SupportedRinses list: Error: %@", err); - } else { - NSLog(@"Step 4: TH writes a supported NumberOfRinses attribute to DUT within the range of the SupportedRinses list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2Seconds_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheNumberOfRinsesAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfRinsesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the NumberOfRinses attribute: Error: %@", err); - } else { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the NumberOfRinses attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfRinses", actualValue, mNumberOfRinsesValue.HasValue() ? mNumberOfRinsesValue.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6OperateDeviceToSetTheConditionToReadOnly_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThWritesAnUnsupportedNumberOfRinsesAttributeToDutWhileDutIsNotInAValidState_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id numberOfRinsesArgument; - numberOfRinsesArgument = mUnsupportedNumberOfRinsesValue.HasValue() ? [NSNumber numberWithUnsignedChar:mUnsupportedNumberOfRinsesValue.Value()] : [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeNumberOfRinsesWithValue:numberOfRinsesArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH writes an unsupported NumberOfRinses attribute to DUT while DUT is not in a valid state.: Error: %@", err); - } else { - NSLog(@"Step 7: TH writes an unsupported NumberOfRinses attribute to DUT while DUT is not in a valid state.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_IN_STATE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OTCCM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OTCCM_1_1() - : TestCommandBridge("Test_TC_OTCCM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OTCCM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OTCCM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OTCCM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if OTCCM.S.F00(DEPONOFF)\n"); - if (ShouldSkip("OTCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfOtccmsf00deponoff_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!OTCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: Read the optional attribute(StartUpMode) in AttributeList\n"); - if (ShouldSkip("OTCCM.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeStartUpModeInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: Read the Feature dependent attribute(DEPONOFF) in AttributeList\n"); - if (ShouldSkip("OTCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep4cReadTheFeatureDependentAttributeDEPONOFFInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfOtccmsf00deponoff_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if OTCCM.S.F00(DEPONOFF): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if OTCCM.S.F00(DEPONOFF): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeStartUpModeInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute(StartUpMode) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute(StartUpMode) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cReadTheFeatureDependentAttributeDEPONOFFInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Read the Feature dependent attribute(DEPONOFF) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: Read the Feature dependent attribute(DEPONOFF) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRYERCTRL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRYERCTRL_1_1() - : TestCommandBridge("Test_TC_DRYERCTRL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRYERCTRL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRYERCTRL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRYERCTRL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRYERCTRL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRYERCTRL_2_1() - : TestCommandBridge("Test_TC_DRYERCTRL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("unsupportedSelectedDrynessLevel", 0, UINT8_MAX, &mUnsupportedSelectedDrynessLevel); - AddArgument("SupportedDrynessLevel", 0, UINT8_MAX, &mSupportedDrynessLevel); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRYERCTRL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRYERCTRL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRYERCTRL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the mandatory attribute: SupportedDrynessLevels\n"); - if (ShouldSkip("DRYERCTRL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMandatoryAttributeSupportedDrynessLevels_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the mandatory attribute: SelectedDrynessLevel\n"); - if (ShouldSkip("DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMandatoryAttributeSelectedDrynessLevel_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4:TH writes a supported SelectedDrynessLevel attribute that is within the list of SupportedDrynessLevels\n"); - if (ShouldSkip("DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep4thWritesASupportedSelectedDrynessLevelAttributeThatIsWithinTheListOfSupportedDrynessLevels_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 2 seconds\n"); - err = TestWait2Seconds_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: after a few seconds, TH reads from the DUT the SelectedDrynessLevel attribute\n"); - if (ShouldSkip("DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep5AfterAFewSecondsThReadsFromTheDutTheSelectedDrynessLevelAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH writes an unsupported SelectedDrynessLevel attribute that is not in list of SupportedDrynessLevels to DUT\n"); - if (ShouldSkip("DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep6ThWritesAnUnsupportedSelectedDrynessLevelAttributeThatIsNotInListOfSupportedDrynessLevelsToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: Operate device to set the condition to read only\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DRYERCTRL.S.M.ManuallyControlled")) { - NextTest(); - return; - } - err = TestStep6OperateDeviceToSetTheConditionToReadOnly_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH writes a supported SelectedDrynessLevel attribute to DUT while DUT is not in a valid state.\n"); - if (ShouldSkip("DRYERCTRL.S.M.ManuallyControlled && DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep7ThWritesASupportedSelectedDrynessLevelAttributeToDutWhileDutIsNotInAValidState_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_IN_STATE)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mUnsupportedSelectedDrynessLevel; - chip::Optional mSupportedDrynessLevel; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMandatoryAttributeSupportedDrynessLevels_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedDrynessLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the mandatory attribute: SupportedDrynessLevels: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the mandatory attribute: SupportedDrynessLevels: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedDrynessLevels", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("supportedDrynessLevels", value, 16)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMandatoryAttributeSelectedDrynessLevel_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedDrynessLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the mandatory attribute: SelectedDrynessLevel: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the mandatory attribute: SelectedDrynessLevel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("selectedDrynessLevel", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("selectedDrynessLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("selectedDrynessLevel", [value unsignedCharValue], 15U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4thWritesASupportedSelectedDrynessLevelAttributeThatIsWithinTheListOfSupportedDrynessLevels_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id selectedDrynessLevelArgument; - selectedDrynessLevelArgument = mSupportedDrynessLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mSupportedDrynessLevel.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeSelectedDrynessLevelWithValue:selectedDrynessLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4:TH writes a supported SelectedDrynessLevel attribute that is within the list of SupportedDrynessLevels: Error: %@", err); - } else { - NSLog(@"Step 4:TH writes a supported SelectedDrynessLevel attribute that is within the list of SupportedDrynessLevels: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2Seconds_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheSelectedDrynessLevelAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedDrynessLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SelectedDrynessLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SelectedDrynessLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SelectedDrynessLevel", actualValue)); - VerifyOrReturn(CheckValue("SelectedDrynessLevel", actualValue, mSupportedDrynessLevel.HasValue() ? mSupportedDrynessLevel.Value() : 1U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("selectedDrynessLevel", "enum8", "enum8")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThWritesAnUnsupportedSelectedDrynessLevelAttributeThatIsNotInListOfSupportedDrynessLevelsToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id selectedDrynessLevelArgument; - selectedDrynessLevelArgument = mUnsupportedSelectedDrynessLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mUnsupportedSelectedDrynessLevel.Value()] : [NSNumber numberWithUnsignedChar:4U]; - [cluster writeAttributeSelectedDrynessLevelWithValue:selectedDrynessLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH writes an unsupported SelectedDrynessLevel attribute that is not in list of SupportedDrynessLevels to DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH writes an unsupported SelectedDrynessLevel attribute that is not in list of SupportedDrynessLevels to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6OperateDeviceToSetTheConditionToReadOnly_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThWritesASupportedSelectedDrynessLevelAttributeToDutWhileDutIsNotInAValidState_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id selectedDrynessLevelArgument; - selectedDrynessLevelArgument = mSupportedDrynessLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mSupportedDrynessLevel.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeSelectedDrynessLevelWithValue:selectedDrynessLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH writes a supported SelectedDrynessLevel attribute to DUT while DUT is not in a valid state.: Error: %@", err); - } else { - NSLog(@"Step 7: TH writes a supported SelectedDrynessLevel attribute to DUT while DUT is not in a valid state.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_IN_STATE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LOWPOWER_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LOWPOWER_1_1() - : TestCommandBridge("Test_TC_LOWPOWER_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LOWPOWER_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LOWPOWER_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LOWPOWER_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AttributeList", [actualValue count], static_cast(6))); - VerifyOrReturn(CheckValue("", actualValue[0], 65528UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 65529UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 65530UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 65531UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 65532UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 65533UL)); - } - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AttributeList", [actualValue count], static_cast(5))); - VerifyOrReturn(CheckValue("", actualValue[0], 65528UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 65529UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 65531UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 65532UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 65533UL)); - } - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_KEYPADINPUT_1_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_KEYPADINPUT_1_2() - : TestCommandBridge("Test_TC_KEYPADINPUT_1_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_KEYPADINPUT_1_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_KEYPADINPUT_1_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_KEYPADINPUT_1_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !KEYPADINPUT.S.F00 && KEYPADINPUT.S.F01 && !KEYPADINPUT.S.F02 ")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given (KEYPADINPUT.S.F00(NV)) FeatureMap bit mask is set or not\n"); - if (ShouldSkip("KEYPADINPUT.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenKeypadinputsf00nvFeatureMapBitMaskIsSetOrNot_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given (KEYPADINPUT.S.F01(LK)) FeatureMap bit mask is set or not\n"); - if (ShouldSkip("KEYPADINPUT.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenKeypadinputsf01lkFeatureMapBitMaskIsSetOrNot_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2d: Given (KEYPADINPUT.S.F02(NK)) FeatureMap bit mask is set or not\n"); - if (ShouldSkip("KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep2dGivenKeypadinputsf02nkFeatureMapBitMaskIsSetOrNot_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenKeypadinputsf00nvFeatureMapBitMaskIsSetOrNot_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given (KEYPADINPUT.S.F00(NV)) FeatureMap bit mask is set or not: Error: %@", err); - } else { - NSLog(@"Step 2b: Given (KEYPADINPUT.S.F00(NV)) FeatureMap bit mask is set or not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenKeypadinputsf01lkFeatureMapBitMaskIsSetOrNot_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given (KEYPADINPUT.S.F01(LK)) FeatureMap bit mask is set or not: Error: %@", err); - } else { - NSLog(@"Step 2c: Given (KEYPADINPUT.S.F01(LK)) FeatureMap bit mask is set or not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dGivenKeypadinputsf02nkFeatureMapBitMaskIsSetOrNot_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: Given (KEYPADINPUT.S.F02(NK)) FeatureMap bit mask is set or not: Error: %@", err); - } else { - NSLog(@"Step 2d: Given (KEYPADINPUT.S.F02(NK)) FeatureMap bit mask is set or not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APPLAUNCHER_1_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APPLAUNCHER_1_3() - : TestCommandBridge("Test_TC_APPLAUNCHER_1_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APPLAUNCHER_1_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APPLAUNCHER_1_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APPLAUNCHER_1_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip("APPLAUNCHER.S.F00")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !APPLAUNCHER.S.F00 ")) { - NextTest(); - return; - } - err = TestStep2bThReadsTheFeatureMapAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3b: TH reads the optional attribute(CatalogList) in AttributeList\n"); - if (ShouldSkip("APPLAUNCHER.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeCatalogListInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3c: TH reads the optional attribute(CurrentApp) in AttributeList\n"); - if (ShouldSkip("APPLAUNCHER.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeCurrentAppInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsTheFeatureMapAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeCatalogListInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(CatalogList) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(CatalogList) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeCurrentAppInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(CurrentApp) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(CurrentApp) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_1_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_1_4() - : TestCommandBridge("Test_TC_MEDIAINPUT_1_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_1_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_1_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_1_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !MEDIAINPUT.S.F00 ")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: Given MEDIAINPUT.S.F00(NU) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("MEDIAINPUT.S.F00")) { - NextTest(); - return; - } - err = TestStep2GivenMediainputsf00nuEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3b: TH reads the optional attribute(InputList) in AttributeList\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeInputListInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3c: TH reads the optional attribute(CurrentInput) in AttributeList\n"); - if (ShouldSkip("MEDIAINPUT.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeCurrentInputInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2GivenMediainputsf00nuEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Given MEDIAINPUT.S.F00(NU) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2: Given MEDIAINPUT.S.F00(NU) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeInputListInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(InputList) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(InputList) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeCurrentInputInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(CurrentInput) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(CurrentInput) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WAKEONLAN_1_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WAKEONLAN_1_5() - : TestCommandBridge("Test_TC_WAKEONLAN_1_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WAKEONLAN_1_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WAKEONLAN_1_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WAKEONLAN_1_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3b: TH reads the optional attribute(MACAddress) in AttributeList\n"); - if (ShouldSkip("WAKEONLAN.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeMACAddressInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the global attribute: AcceptedCommandList\n"); - err = TestStep4ThReadsTheGlobalAttributeAcceptedCommandList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the global attribute: GeneratedCommandList\n"); - err = TestStep5ThReadsTheGlobalAttributeGeneratedCommandList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeMACAddressInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(MACAddress) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(MACAddress) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheGlobalAttributeAcceptedCommandList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGlobalAttributeGeneratedCommandList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CHANNEL_1_6 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CHANNEL_1_6() - : TestCommandBridge("Test_TC_CHANNEL_1_6") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CHANNEL_1_6() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_1_6\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_1_6\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: read the global attribute: ClusterRevision\n"); - err = TestStep1ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: Read the global attribute: FeatureMap\n"); - if (ShouldSkip("( !CHANNEL.S.F00 && !CHANNEL.S.F01 )")) { - NextTest(); - return; - } - err = TestStep2aReadTheGlobalAttributeFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given CCHANNEL.S.F00(CL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CHANNEL.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenCchannelsf00clEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given CHANNEL.S.F01(LI) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CHANNEL.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenChannelsf01liEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aReadTheGlobalAttributeAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aReadTheGlobalAttributeAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: Read the optional attribute(ChannelList): AttributeList\n"); - if (ShouldSkip("CHANNEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bReadTheOptionalAttributeChannelListAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: Reading optional attribute(Lineup) in AttributeList\n"); - if (ShouldSkip("CHANNEL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cReadingOptionalAttributeLineupInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: Read the optional attribute(CurrentChannel): AttributeList\n"); - if (ShouldSkip("CHANNEL.S.A0002")) { - NextTest(); - return; - } - err = TestStep3dReadTheOptionalAttributeCurrentChannelAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: Read the optional command(ChangeChannel) in AcceptedCommandList\n"); - if (ShouldSkip("CHANNEL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4aReadTheOptionalCommandChangeChannelInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4b: Read the optional command(ChangeChannelByNumber) in AcceptedCommandList\n"); - if (ShouldSkip("CHANNEL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalCommandChangeChannelByNumberInAcceptedCommandList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4c: Read the optional command(SkipChannel) in AcceptedCommandList\n"); - if (ShouldSkip("CHANNEL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4cReadTheOptionalCommandSkipChannelInAcceptedCommandList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: Read the global attribute: GeneratedCommandList\n"); - if (ShouldSkip("( !CHANNEL.S.F00 && !CHANNEL.S.F01 )")) { - NextTest(); - return; - } - err = TestStep5aReadTheGlobalAttributeGeneratedCommandList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: Read the global attribute: GeneratedCommandList\n"); - if (ShouldSkip("CHANNEL.S.F00 || CHANNEL.S.F01")) { - NextTest(); - return; - } - err = TestStep5bReadTheGlobalAttributeGeneratedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 16; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 1: read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aReadTheGlobalAttributeFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: Read the global attribute: FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 2a: Read the global attribute: FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenCchannelsf00clEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given CCHANNEL.S.F00(CL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2b: Given CCHANNEL.S.F00(CL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenChannelsf01liEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given CHANNEL.S.F01(LI) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2c: Given CHANNEL.S.F01(LI) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bReadTheOptionalAttributeChannelListAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Read the optional attribute(ChannelList): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: Read the optional attribute(ChannelList): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cReadingOptionalAttributeLineupInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Reading optional attribute(Lineup) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: Reading optional attribute(Lineup) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dReadTheOptionalAttributeCurrentChannelAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Read the optional attribute(CurrentChannel): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3d: Read the optional attribute(CurrentChannel): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheOptionalCommandChangeChannelInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the optional command(ChangeChannel) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the optional command(ChangeChannel) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalCommandChangeChannelByNumberInAcceptedCommandList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional command(ChangeChannelByNumber) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional command(ChangeChannelByNumber) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cReadTheOptionalCommandSkipChannelInAcceptedCommandList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Read the optional command(SkipChannel) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4c: Read the optional command(SkipChannel) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aReadTheGlobalAttributeGeneratedCommandList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 5a: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bReadTheGlobalAttributeGeneratedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 5b: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAPLAYBACK_1_7 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_1_7() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_1_7") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_1_7() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_1_7\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_1_7\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !MEDIAPLAYBACK.S.F00 && !MEDIAPLAYBACK.S.F01 ")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given MEDIAPLAYBACK.S.F00(AS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenMediaplaybacksf00asEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given MEDIAPLAYBACK.S.F01(VS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenMediaplaybacksf01vsEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: TH reads the optional attribute(StartTime) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeStartTimeInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: TH reads the optional attribute(Duration) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0002")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeDurationInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: TH reads the optional attribute(SampledPosition) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0003")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheOptionalAttributeSampledPositionInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3e: TH reads the optional attribute(PlaybackSpeed) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004")) { - NextTest(); - return; - } - err = TestStep3eThReadsTheOptionalAttributePlaybackSpeedInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3f: TH reads the optional attribute(SeekRangeEnd) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0005")) { - NextTest(); - return; - } - err = TestStep3fThReadsTheOptionalAttributeSeekRangeEndInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3g: TH reads the optional attribute(SeekRangeStart) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0006")) { - NextTest(); - return; - } - err = TestStep3gThReadsTheOptionalAttributeSeekRangeStartInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4a: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4aThReadsTheAcceptedCommandListAttributeFromTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4b: TH reads the optional command(StartOver) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalCommandStartOverInAcceptedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4c: TH reads the optional command(Previous) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalCommandPreviousInAcceptedCommandList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4d: TH reads the optional command(Next) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalCommandNextInAcceptedCommandList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4e: TH reads the optional command(Rewind) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalCommandRewindInAcceptedCommandList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4f: TH reads the optional command(FastForward) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalCommandFastForwardInAcceptedCommandList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4g: TH reads the optional command(SkipForward) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalCommandSkipForwardInAcceptedCommandList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4h: TH reads the optional command(SkipBackward) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalCommandSkipBackwardInAcceptedCommandList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4i: TH reads the optional command(Seek) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep4iThReadsTheOptionalCommandSeekInAcceptedCommandList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenMediaplaybacksf00asEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given MEDIAPLAYBACK.S.F00(AS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2b: Given MEDIAPLAYBACK.S.F00(AS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenMediaplaybacksf01vsEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given MEDIAPLAYBACK.S.F01(VS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2c: Given MEDIAPLAYBACK.S.F01(VS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeStartTimeInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(StartTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(StartTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeDurationInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(Duration) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(Duration) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsTheOptionalAttributeSampledPositionInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the optional attribute(SampledPosition) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the optional attribute(SampledPosition) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThReadsTheOptionalAttributePlaybackSpeedInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads the optional attribute(PlaybackSpeed) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads the optional attribute(PlaybackSpeed) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsTheOptionalAttributeSeekRangeEndInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads the optional attribute(SeekRangeEnd) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads the optional attribute(SeekRangeEnd) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gThReadsTheOptionalAttributeSeekRangeStartInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH reads the optional attribute(SeekRangeStart) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3g: TH reads the optional attribute(SeekRangeStart) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAcceptedCommandListAttributeFromTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalCommandStartOverInAcceptedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional command(StartOver) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional command(StartOver) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalCommandPreviousInAcceptedCommandList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional command(Previous) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional command(Previous) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalCommandNextInAcceptedCommandList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional command(Next) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional command(Next) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalCommandRewindInAcceptedCommandList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional command(Rewind) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional command(Rewind) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalCommandFastForwardInAcceptedCommandList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional command(FastForward) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional command(FastForward) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalCommandSkipForwardInAcceptedCommandList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional command(SkipForward) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional command(SkipForward) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalCommandSkipBackwardInAcceptedCommandList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional command(SkipBackward) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional command(SkipBackward) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsTheOptionalCommandSeekInAcceptedCommandList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads the optional command(Seek) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads the optional command(Seek) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_AUDIOOUTPUT_1_8 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AUDIOOUTPUT_1_8() - : TestCommandBridge("Test_TC_AUDIOOUTPUT_1_8") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AUDIOOUTPUT_1_8() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AUDIOOUTPUT_1_8\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AUDIOOUTPUT_1_8\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip("AUDIOOUTPUT.S.F00")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TTH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !AUDIOOUTPUT.S.F00 ")) { - NextTest(); - return; - } - err = TestStep2bTthReadsTheFeatureMapAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bTthReadsTheFeatureMapAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TTH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TTH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TGTNAV_1_9 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TGTNAV_1_9() - : TestCommandBridge("Test_TC_TGTNAV_1_9") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TGTNAV_1_9() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TGTNAV_1_9\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TGTNAV_1_9\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3b: TH reads the optional attribute(CurrentTarget) in AttributeList\n"); - if (ShouldSkip("TGTNAV.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeCurrentTargetInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeCurrentTargetInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(CurrentTarget) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(CurrentTarget) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APBSC_1_10 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APBSC_1_10() - : TestCommandBridge("Test_TC_APBSC_1_10") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APBSC_1_10() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APBSC_1_10\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APBSC_1_10\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3b: TH reads the optional attribute(VendorName) in AttributeList\n"); - if (ShouldSkip("APBSC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeVendorNameInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3c: TH reads the optional attribute(VendorID) in AttributeList\n"); - if (ShouldSkip("APBSC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeVendorIDInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3d: TH reads the optional attribute(ProductID) in AttributeList\n"); - if (ShouldSkip("APBSC.S.A0003")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheOptionalAttributeProductIDInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeVendorNameInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(VendorName) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(VendorName) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeVendorIDInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(VendorID) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(VendorID) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsTheOptionalAttributeProductIDInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the optional attribute(ProductID) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the optional attribute(ProductID) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CONTENTLAUNCHER_1_11 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_1_11() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_1_11") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_1_11() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_1_11\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_1_11\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip("( !CONTENTLAUNCHER.S.F00 && !CONTENTLAUNCHER.S.F01 )")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given CONTENTLAUNCHER.S.F00 (CS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenContentlaunchersf00CsEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given CONTENTLAUNCHER.S.F01(UP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenContentlaunchersf01upEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: TH reads the optional attribute(AcceptHeader): AttributeList\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeAcceptHeaderAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: TH reads the optional attribute(SupportedStreamingProtocols): AttributeList\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeSupportedStreamingProtocolsAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads the optional command(LaunchContent) in AcceptedCommandList attribute\n"); - if (ShouldSkip("CONTENTLAUNCHER.C.C00.Tx")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheOptionalCommandLaunchContentInAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads the optional command(LaunchURL) in AcceptedCommandList attribute\n"); - if (ShouldSkip("CONTENTLAUNCHER.C.C01.Tx")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalCommandLaunchURLInAcceptedCommandListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenContentlaunchersf00CsEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given CONTENTLAUNCHER.S.F00 (CS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2b: Given CONTENTLAUNCHER.S.F00 (CS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenContentlaunchersf01upEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given CONTENTLAUNCHER.S.F01(UP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2c: Given CONTENTLAUNCHER.S.F01(UP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeAcceptHeaderAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(AcceptHeader): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(AcceptHeader): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeSupportedStreamingProtocolsAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(SupportedStreamingProtocols): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(SupportedStreamingProtocols): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheOptionalCommandLaunchContentInAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the optional command(LaunchContent) in AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the optional command(LaunchContent) in AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalCommandLaunchURLInAcceptedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional command(LaunchURL) in AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional command(LaunchURL) in AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ALOGIN_1_12 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ALOGIN_1_12() - : TestCommandBridge("Test_TC_ALOGIN_1_12") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ALOGIN_1_12() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ALOGIN_1_12\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ALOGIN_1_12\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LOWPOWER_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LOWPOWER_2_1() - : TestCommandBridge("Test_TC_LOWPOWER_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LOWPOWER_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LOWPOWER_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LOWPOWER_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends Sleep command to DUT\n"); - if (ShouldSkip("LOWPOWER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsSleepCommandToDut_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsSleepCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster sleepWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends Sleep command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends Sleep command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_KEYPADINPUT_3_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_KEYPADINPUT_3_2() - : TestCommandBridge("Test_TC_KEYPADINPUT_3_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_KEYPADINPUT_3_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_KEYPADINPUT_3_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_KEYPADINPUT_3_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends CEC Settings Keys(0x0A) to DUT\n"); - if (ShouldSkip("KEYPADINPUT.S.F01 && KEYPADINPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsCecSettingsKeys0x0AToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends CEC Home Keys(0x09) to DUT\n"); - if (ShouldSkip("KEYPADINPUT.S.F01 && KEYPADINPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsCecHomeKeys0x09ToDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsCecSettingsKeys0x0AToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:10U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends CEC Settings Keys(0x0A) to DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends CEC Settings Keys(0x0A) to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsCecHomeKeys0x09ToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:9U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends CEC Home Keys(0x09) to DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends CEC Home Keys(0x09) to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_KEYPADINPUT_3_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_KEYPADINPUT_3_3() - : TestCommandBridge("Test_TC_KEYPADINPUT_3_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_KEYPADINPUT_3_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_KEYPADINPUT_3_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_KEYPADINPUT_3_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends Numbers1\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1aThSendsNumbers1_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends Numbers2\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1bThSendsNumbers2_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH sends Numbers3\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1cThSendsNumbers3_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH sends Numbers4\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1dThSendsNumbers4_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH sends Numbers5\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1eThSendsNumbers5_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: TH sends Numbers6\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1fThSendsNumbers6_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1g: TH sends Numbers7\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1gThSendsNumbers7_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 1h: TH sends Numbers8\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1hThSendsNumbers8_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 1i: TH sends Numbers9\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1iThSendsNumbers9_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsNumbers1_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:33U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends Numbers1: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends Numbers1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsNumbers2_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:34U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends Numbers2: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends Numbers2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThSendsNumbers3_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:35U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH sends Numbers3: Error: %@", err); - } else { - NSLog(@"Step 1c: TH sends Numbers3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThSendsNumbers4_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:36U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH sends Numbers4: Error: %@", err); - } else { - NSLog(@"Step 1d: TH sends Numbers4: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eThSendsNumbers5_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:37U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH sends Numbers5: Error: %@", err); - } else { - NSLog(@"Step 1e: TH sends Numbers5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fThSendsNumbers6_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:38U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1f: TH sends Numbers6: Error: %@", err); - } else { - NSLog(@"Step 1f: TH sends Numbers6: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1gThSendsNumbers7_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:39U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1g: TH sends Numbers7: Error: %@", err); - } else { - NSLog(@"Step 1g: TH sends Numbers7: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1hThSendsNumbers8_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:40U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1h: TH sends Numbers8: Error: %@", err); - } else { - NSLog(@"Step 1h: TH sends Numbers8: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1iThSendsNumbers9_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:41U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1i: TH sends Numbers9: Error: %@", err); - } else { - NSLog(@"Step 1i: TH sends Numbers9: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APPLAUNCHER_3_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APPLAUNCHER_3_5() - : TestCommandBridge("Test_TC_APPLAUNCHER_3_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APPLAUNCHER_3_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APPLAUNCHER_3_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APPLAUNCHER_3_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads CatalogList attribute from the DUT for the list of supported application catalogs and where each entry in the list is a CSA-issued Vendor Id of type unsigned 16 bit integer ranging between 0-65536 for the catalog\n"); - if (ShouldSkip("APPLAUNCHER.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsCatalogListAttributeFromTheDutForTheListOfSupportedApplicationCatalogsAndWhereEachEntryInTheListIsACsaIssuedVendorIdOfTypeUnsigned16BitIntegerRangingBetween065536ForTheCatalog_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsCatalogListAttributeFromTheDutForTheListOfSupportedApplicationCatalogsAndWhereEachEntryInTheListIsACsaIssuedVendorIdOfTypeUnsigned16BitIntegerRangingBetween065536ForTheCatalog_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCatalogListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads CatalogList attribute from the DUT for the list of supported application catalogs and where each entry in the list is a CSA-issued Vendor Id of type unsigned 16 bit integer ranging between 0-65536 for the catalog: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads CatalogList attribute from the DUT for the list of supported application catalogs and where each entry in the list is a CSA-issued Vendor Id of type unsigned 16 bit integer ranging between 0-65536 for the catalog: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APPLAUNCHER_3_6 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APPLAUNCHER_3_6() - : TestCommandBridge("Test_TC_APPLAUNCHER_3_6") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APPLAUNCHER_3_6() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APPLAUNCHER_3_6\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APPLAUNCHER_3_6\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads CurrentApp attribute from the DUT and Verify the in-focus application attributes, which should include the display Application ID(type:uint16) Catalog Vendor ID(type:string) or Null if there is no current in-focus application\n"); - if (ShouldSkip("APPLAUNCHER.S.A0001")) { - NextTest(); - return; - } - err = TestStep1ThReadsCurrentAppAttributeFromTheDutAndVerifyTheInFocusApplicationAttributesWhichShouldIncludeTheDisplayApplicationIDtypeuint16CatalogVendorIDtypestringOrNullIfThereIsNoCurrentInFocusApplication_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsCurrentAppAttributeFromTheDutAndVerifyTheInFocusApplicationAttributesWhichShouldIncludeTheDisplayApplicationIDtypeuint16CatalogVendorIDtypestringOrNullIfThereIsNoCurrentInFocusApplication_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentAppWithCompletion:^(MTRApplicationLauncherClusterApplicationEPStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads CurrentApp attribute from the DUT and Verify the in-focus application attributes, which should include the display Application ID(type:uint16) Catalog Vendor ID(type:string) or Null if there is no current in-focus application: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads CurrentApp attribute from the DUT and Verify the in-focus application attributes, which should include the display Application ID(type:uint16) Catalog Vendor ID(type:string) or Null if there is no current in-focus application: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_3_10 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_3_10() - : TestCommandBridge("Test_TC_MEDIAINPUT_3_10") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_3_10() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_10\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_10\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String)\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_3_11 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_3_11() - : TestCommandBridge("Test_TC_MEDIAINPUT_3_11") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Index", 0, UINT8_MAX, &mIndex); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_3_11() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_11\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_11\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String)\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends SelectInput command to DUT to select an input by passing the index of the preferred input.\n"); - if (ShouldSkip("MEDIAINPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsSelectInputCommandToDutToSelectAnInputByPassingTheIndexOfThePreferredInput_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads _CurrentInput attribute from the DUT to show the current input selected.\n"); - if (ShouldSkip("MEDIAINPUT.S.A0001 && MEDIAINPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsCurrentInputAttributeFromTheDutToShowTheCurrentInputSelected_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mIndex; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsSelectInputCommandToDutToSelectAnInputByPassingTheIndexOfThePreferredInput_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaInputClusterSelectInputParams alloc] init]; - params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster selectInputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends SelectInput command to DUT to select an input by passing the index of the preferred input.: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends SelectInput command to DUT to select an input by passing the index of the preferred input.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsCurrentInputAttributeFromTheDutToShowTheCurrentInputSelected_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentInputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads _CurrentInput attribute from the DUT to show the current input selected.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads _CurrentInput attribute from the DUT to show the current input selected.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentInput", actualValue, mIndex.HasValue() ? mIndex.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_3_12 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_3_12() - : TestCommandBridge("Test_TC_MEDIAINPUT_3_12") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_3_12() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_12\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_12\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String)\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends ShowInputStatus command to DUT to show active status of the input list\n"); - if (ShouldSkip("MEDIAINPUT.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsShowInputStatusCommandToDutToShowActiveStatusOfTheInputList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends HideInputStatus command to DUT to hide active status of the input list\n"); - if (ShouldSkip("MEDIAINPUT.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsHideInputStatusCommandToDutToHideActiveStatusOfTheInputList_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsShowInputStatusCommandToDutToShowActiveStatusOfTheInputList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster showInputStatusWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends ShowInputStatus command to DUT to show active status of the input list: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends ShowInputStatus command to DUT to show active status of the input list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsHideInputStatusCommandToDutToHideActiveStatusOfTheInputList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster hideInputStatusWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends HideInputStatus command to DUT to hide active status of the input list: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends HideInputStatus command to DUT to hide active status of the input list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_3_13 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_3_13() - : TestCommandBridge("Test_TC_MEDIAINPUT_3_13") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Index", 0, UINT8_MAX, &mIndex); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_3_13() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_13\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_13\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a RenameInput command to DUT to rename an input from the list returned in step 1\n"); - if (ShouldSkip("MEDIAINPUT.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsARenameInputCommandToDutToRenameAnInputFromTheListReturnedInStep1_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the InputList attribute from the DUT to show list of Inputs available\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAINPUT.S.A0000 && MEDIAINPUT.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mIndex; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("inputList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsARenameInputCommandToDutToRenameAnInputFromTheListReturnedInStep1_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaInputClusterRenameInputParams alloc] init]; - params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; - params.name = @"A1"; - [cluster renameInputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a RenameInput command to DUT to rename an input from the list returned in step 1: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a RenameInput command to DUT to rename an input from the list returned in step 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_CHANNEL_5_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CHANNEL_5_1() - : TestCommandBridge("Test_TC_CHANNEL_5_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CHANNEL_5_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_5_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_5_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ChannelList attribute from the DUT to show list of Inputs available and Verify that the response contains a list of the known TV channels. Each list element should consist of the following,Major number (unsigned 16-bit integer, mandatory),Minor number (unsigned 16-bit integer, mandatory),Name (String, optional),Call sign (String, optional),Affiliate call sign (String, optional)\n"); - if (ShouldSkip("CHANNEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheChannelListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsAListOfTheKnownTvChannelsEachListElementShouldConsistOfTheFollowingMajorNumberUnsigned16BitIntegerMandatoryMinorNumberUnsigned16BitIntegerMandatoryNameStringOptionalCallSignStringOptionalAffiliateCallSignStringOptional_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheChannelListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsAListOfTheKnownTvChannelsEachListElementShouldConsistOfTheFollowingMajorNumberUnsigned16BitIntegerMandatoryMinorNumberUnsigned16BitIntegerMandatoryNameStringOptionalCallSignStringOptionalAffiliateCallSignStringOptional_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT to show list of Inputs available and Verify that the response contains a list of the known TV channels. Each list element should consist of the following,Major number (unsigned 16-bit integer, mandatory),Minor number (unsigned 16-bit integer, mandatory),Name (String, optional),Call sign (String, optional),Affiliate call sign (String, optional): Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT to show list of Inputs available and Verify that the response contains a list of the known TV channels. Each list element should consist of the following,Major number (unsigned 16-bit integer, mandatory),Minor number (unsigned 16-bit integer, mandatory),Name (String, optional),Call sign (String, optional),Affiliate call sign (String, optional): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CHANNEL_5_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CHANNEL_5_2() - : TestCommandBridge("Test_TC_CHANNEL_5_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("majornumber", 0, UINT16_MAX, &mMajornumber); - AddArgument("minornumber", 0, UINT16_MAX, &mMinornumber); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CHANNEL_5_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_5_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_5_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ChannelList attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheChannelListAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a ChangeChannelByNumber command to the DUT with channel information (major and minor numbers) from the list in step 1\n"); - if (ShouldSkip("CHANNEL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsAChangeChannelByNumberCommandToTheDutWithChannelInformationMajorAndMinorNumbersFromTheListInStep1_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: Verify that the channel has changed on the device\n"); - if (ShouldSkip("PICS_USER_PROMPT && CHANNEL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2aVerifyThatTheChannelHasChangedOnTheDevice_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads the CurrentChannel attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0002 && CHANNEL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mMajornumber; - chip::Optional mMinornumber; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheChannelListAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("channelList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsAChangeChannelByNumberCommandToTheDutWithChannelInformationMajorAndMinorNumbersFromTheListInStep1_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = mMajornumber.HasValue() ? [NSNumber numberWithUnsignedShort:mMajornumber.Value()] : [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = mMinornumber.HasValue() ? [NSNumber numberWithUnsignedShort:mMinornumber.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a ChangeChannelByNumber command to the DUT with channel information (major and minor numbers) from the list in step 1: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a ChangeChannelByNumber command to the DUT with channel information (major and minor numbers) from the list in step 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aVerifyThatTheChannelHasChangedOnTheDevice_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if channel has changed on the devicegarbage: not in length on purpose", 53); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, mMajornumber.HasValue() ? mMajornumber.Value() : 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, mMinornumber.HasValue() ? mMinornumber.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CHANNEL_5_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CHANNEL_5_3() - : TestCommandBridge("Test_TC_CHANNEL_5_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("majornumber", 0, UINT16_MAX, &mMajornumber); - AddArgument("minornumber", 0, UINT16_MAX, &mMinornumber); - AddArgument("majornumber2", 0, UINT16_MAX, &mMajornumber2); - AddArgument("minornumber2", 0, UINT16_MAX, &mMinornumber2); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CHANNEL_5_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_5_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_5_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the Lineup attribute from the DUT to show list of Inputs available and Verify that the response contains a lineup info object\n"); - if (ShouldSkip("CHANNEL.S.A0001")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheLineupAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsALineupInfoObject_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the ChannelList attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheChannelListAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the CurrentChannel attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends a SkipChannel command to the DUT with a value of 1\n"); - if (ShouldSkip("CHANNEL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsASkipChannelCommandToTheDutWithAValueOf1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: Verify that the channel has changed on the device\n"); - if (ShouldSkip("PICS_USER_PROMPT && CHANNEL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4aVerifyThatTheChannelHasChangedOnTheDevice_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the CurrentChannel attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0002 && CHANNEL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheCurrentChannelAttributeFromTheDut_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mMajornumber; - chip::Optional mMinornumber; - chip::Optional mMajornumber2; - chip::Optional mMinornumber2; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheLineupAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsALineupInfoObject_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLineupWithCompletion:^(MTRChannelClusterLineupInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the Lineup attribute from the DUT to show list of Inputs available and Verify that the response contains a lineup info object: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the Lineup attribute from the DUT to show list of Inputs available and Verify that the response contains a lineup info object: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheChannelListAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ChannelList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ChannelList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("channelList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, mMajornumber.HasValue() ? mMajornumber.Value() : 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, mMinornumber.HasValue() ? mMinornumber.Value() : 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsASkipChannelCommandToTheDutWithAValueOf1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:1]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a SkipChannel command to the DUT with a value of 1: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a SkipChannel command to the DUT with a value of 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aVerifyThatTheChannelHasChangedOnTheDevice_5() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if channel has changed on the devicegarbage: not in length on purpose", 53); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5ThReadsTheCurrentChannelAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the CurrentChannel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the CurrentChannel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, mMajornumber2.HasValue() ? mMajornumber2.Value() : 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, mMinornumber2.HasValue() ? mMinornumber2.Value() : 1U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentChannel", "ChannelInfoStruct", "ChannelInfoStruct")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAPLAYBACK_6_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_6_1() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_6_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a Play command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsAPlayCommandToTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that the media state is playing\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaStateIsPlaying_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH sends a Pause command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsAPauseCommandToTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Verify that the media is paused\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaIsPaused_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp && MEDIAPLAYBACK.S.A0000")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheCurrentStateAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH sends a Stop command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsAStopCommandToTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Verify that the media is stoped\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaIsStoped_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThReadsTheCurrentStateAttributeFromTheDut_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); - } else { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsAPlayCommandToTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster playWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a Play command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a Play command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaStateIsPlaying_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is playinggarbage: not in length on purpose", 42); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsAPauseCommandToTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a Pause command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a Pause command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaIsPaused_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is pausedgarbage: not in length on purpose", 41); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5ThReadsTheCurrentStateAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsAStopCommandToTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends a Stop command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends a Stop command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaIsStoped_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is stopedgarbage: not in length on purpose", 41); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThReadsTheCurrentStateAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAPLAYBACK_6_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_6_2() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_6_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a Play command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsAPlayCommandToTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that the media state is playing\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaStateIsPlaying_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH sends a StartOver command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsAStartOverCommandToTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Verify that the media is started over\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaIsStartedOver_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH sends a Next command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsANextCommandToTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Verify that the next media item in the queue has been loaded\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheNextMediaItemInTheQueueHasBeenLoaded_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH sends a Previous command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsAPreviousCommandToTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Verify that the previous media item in the queue has been loaded\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatThePreviousMediaItemInTheQueueHasBeenLoaded_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: TH sends a SkipForward command to the DUT with a DeltaPositionMilliseconds value of 10000\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsASkipForwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Verify that the media has skipped forward 10 seconds\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaHasSkippedForward10Seconds_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 8: TH reads the SampledPosition attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0003 && MEDIAPLAYBACK.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThReadsTheSampledPositionAttributeFromTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 9: TH sends a SkipBackward command to the DUT with a DeltaPositionMilliseconds value of 10000\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsASkipBackwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Verify that the media has skipped backward 10 seconds\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaHasSkippedBackward10Seconds_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 10: TH reads the SampledPosition attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0003 && MEDIAPLAYBACK.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThReadsTheSampledPositionAttributeFromTheDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); - } else { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsAPlayCommandToTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster playWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a Play command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a Play command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaStateIsPlaying_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is playinggarbage: not in length on purpose", 42); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsAStartOverCommandToTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster startOverWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a StartOver command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a StartOver command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaIsStartedOver_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media is started overgarbage: not in length on purpose", 41); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5ThSendsANextCommandToTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster nextWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends a Next command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends a Next command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheNextMediaItemInTheQueueHasBeenLoaded_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media item in the queue has been loadedgarbage: not in length on purpose", 59); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6ThSendsAPreviousCommandToTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster previousWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends a Previous command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends a Previous command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatThePreviousMediaItemInTheQueueHasBeenLoaded_11() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if previous media item in the queue has been loadedgarbage: not in length on purpose", 68); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThSendsASkipForwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSkipForwardParams alloc] init]; - params.deltaPositionMilliseconds = - [NSNumber numberWithUnsignedLongLong:10000ULL]; - [cluster skipForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends a SkipForward command to the DUT with a DeltaPositionMilliseconds value of 10000: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends a SkipForward command to the DUT with a DeltaPositionMilliseconds value of 10000: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaHasSkippedForward10Seconds_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media has skipped forward 10 secondsgarbage: not in length on purpose", 56); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep8ThReadsTheSampledPositionAttributeFromTheDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads the SampledPosition attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads the SampledPosition attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 10000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsASkipBackwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSkipBackwardParams alloc] init]; - params.deltaPositionMilliseconds = - [NSNumber numberWithUnsignedLongLong:10000ULL]; - [cluster skipBackwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends a SkipBackward command to the DUT with a DeltaPositionMilliseconds value of 10000: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends a SkipBackward command to the DUT with a DeltaPositionMilliseconds value of 10000: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaHasSkippedBackward10Seconds_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media has skipped backward 10 secondsgarbage: not in length on purpose", 57); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10ThReadsTheSampledPositionAttributeFromTheDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads the SampledPosition attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads the SampledPosition attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAPLAYBACK_6_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_6_3() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("SeekPosition", 0, UINT64_MAX, &mSeekPosition); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_6_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH sends a Seek command to the DUT with a Position value of 10000\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsASeekCommandToTheDutWithAPositionValueOf10000_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Verify that the media has moved to 10 seconds from the starting point\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaHasMovedTo10SecondsFromTheStartingPoint_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads the SampledPosition attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0003 && MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheSampledPositionAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the StartTime attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheStartTimeAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the SeekRangeEnd attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0005")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheSeekRangeEndAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the SeekRangeStart attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0006")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheSeekRangeStartAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the Duration attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0002")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheDurationAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH sends a Seek command to the DUT with a Position value beyond the furthest valid position (ex: beyond the duration of the media)\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsASeekCommandToTheDutWithAPositionValueBeyondTheFurthestValidPositionExBeyondTheDurationOfTheMedia_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : verify that the media has not moved.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaHasNotMoved_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mSeekPosition; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); - } else { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThSendsASeekCommandToTheDutWithAPositionValueOf10000_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSeekParams alloc] init]; - params.position = - [NSNumber numberWithUnsignedLongLong:10000ULL]; - [cluster seekWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a Seek command to the DUT with a Position value of 10000: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a Seek command to the DUT with a Position value of 10000: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaHasMovedTo10SecondsFromTheStartingPoint_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media has moved to 10 seconds from the starting pointgarbage: not in length on purpose", 73); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheSampledPositionAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the SampledPosition attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the SampledPosition attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 10000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheStartTimeAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the StartTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the StartTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startTime", "epoch_us", "epoch_us")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheSeekRangeEndAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSeekRangeEndWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the SeekRangeEnd attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the SeekRangeEnd attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("seekRangeEnd", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("seekRangeEnd", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("seekRangeEnd", [value unsignedLongLongValue], 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheSeekRangeStartAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSeekRangeStartWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the SeekRangeStart attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the SeekRangeStart attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("seekRangeStart", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("seekRangeStart", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("seekRangeStart", [value unsignedLongLongValue], 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheDurationAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDurationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the Duration attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the Duration attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("duration", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("duration", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("duration", [value unsignedLongLongValue], 18446744073709551615ULL)); - } - VerifyOrReturn(CheckConstraintNotValue("duration", value, 0ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsASeekCommandToTheDutWithAPositionValueBeyondTheFurthestValidPositionExBeyondTheDurationOfTheMedia_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSeekParams alloc] init]; - params.position = mSeekPosition.HasValue() ? [NSNumber numberWithUnsignedLongLong:mSeekPosition.Value()] : [NSNumber numberWithUnsignedLongLong:100000000ULL]; - [cluster seekWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends a Seek command to the DUT with a Position value beyond the furthest valid position (ex: beyond the duration of the media): Error: %@", err); - } else { - NSLog(@"Step 7: TH sends a Seek command to the DUT with a Position value beyond the furthest valid position (ex: beyond the duration of the media): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaHasNotMoved_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media has not movedgarbage: not in length on purpose", 39); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_MEDIAPLAYBACK_6_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_6_4() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_6_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThReadsThePlaybackSpeedAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH sends a FastForward command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsAFastForwardCommandToTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : verify that the media state is playing\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaStateIsPlaying_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheCurrentStateAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThReadsThePlaybackSpeedAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH sends a FastForward command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsAFastForwardCommandToTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : verify that the media play speed has increased.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaPlaySpeedHasIncreased_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThReadsThePlaybackSpeedAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 8: TH sends a Rewind command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsARewindCommandToTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : verify that the media play has reversed direction.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaPlayHasReversedDirection_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 9: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThReadsTheCurrentStateAttributeFromTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 10: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThReadsThePlaybackSpeedAttributeFromTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 11: TH sends a Rewind command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep11ThSendsARewindCommandToTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : verify that the media play speed has increased in the reverse direction.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaPlaySpeedHasIncreasedInTheReverseDirection_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 12: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep12ThReadsThePlaybackSpeedAttributeFromTheDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 13: TH sends a Play command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsAPlayCommandToTheDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : verify that the media is has resumed playing forward at the default speed.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaIsHasResumedPlayingForwardAtTheDefaultSpeed_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 14: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep14ThReadsThePlaybackSpeedAttributeFromTheDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 15: STH sends consecutive FastForward commands up to the manufacturer defined max speed\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep15SthSendsConsecutiveFastForwardCommandsUpToTheManufacturerDefinedMaxSpeed_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 16: TH sends consecutive Rewind commands up to the manufacturer defined max speed\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep16ThSendsConsecutiveRewindCommandsUpToTheManufacturerDefinedMaxSpeed_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); - } else { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsThePlaybackSpeedAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsAFastForwardCommandToTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterFastForwardParams alloc] init]; - [cluster fastForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a FastForward command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a FastForward command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaStateIsPlaying_5() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is playinggarbage: not in length on purpose", 42); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThReadsTheCurrentStateAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsThePlaybackSpeedAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 1.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsAFastForwardCommandToTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterFastForwardParams alloc] init]; - [cluster fastForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends a FastForward command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends a FastForward command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaPlaySpeedHasIncreased_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media play speed has increased.garbage: not in length on purpose", 51); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThReadsThePlaybackSpeedAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 2.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsARewindCommandToTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterRewindParams alloc] init]; - [cluster rewindWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends a Rewind command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends a Rewind command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaPlayHasReversedDirection_12() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media play has reversed directiongarbage: not in length on purpose", 53); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep9ThReadsTheCurrentStateAttributeFromTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsThePlaybackSpeedAttributeFromTheDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, -1.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThSendsARewindCommandToTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterRewindParams alloc] init]; - [cluster rewindWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends a Rewind command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends a Rewind command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaPlaySpeedHasIncreasedInTheReverseDirection_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media play speed has increased in the reverse directiongarbage: not in length on purpose", 75); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep12ThReadsThePlaybackSpeedAttributeFromTheDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, -2.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThSendsAPlayCommandToTheDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster playWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends a Play command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 13: TH sends a Play command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaIsHasResumedPlayingForwardAtTheDefaultSpeed_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media is has resumed playing forward at the default speedgarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep14ThReadsThePlaybackSpeedAttributeFromTheDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 1.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15SthSendsConsecutiveFastForwardCommandsUpToTheManufacturerDefinedMaxSpeed_21() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep16ThSendsConsecutiveRewindCommandsUpToTheManufacturerDefinedMaxSpeed_22() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_AUDIOOUTPUT_7_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AUDIOOUTPUT_7_1() - : TestCommandBridge("Test_TC_AUDIOOUTPUT_7_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Index", 0, UINT8_MAX, &mIndex); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AUDIOOUTPUT_7_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AUDIOOUTPUT_7_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AUDIOOUTPUT_7_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the OutputList attribute\n"); - if (ShouldSkip("AUDIOOUTPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheOutputListAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a SelectAudioOutput command to the DUT with an index from the list in step 1\n"); - if (ShouldSkip("AUDIOOUTPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsASelectAudioOutputCommandToTheDutWithAnIndexFromTheListInStep1_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the CurrentOutput attribute from the DUT\n"); - if (ShouldSkip("AUDIOOUTPUT.S.A0001 && AUDIOOUTPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentOutputAttributeFromTheDut_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mIndex; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheOutputListAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the OutputList attribute: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the OutputList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("outputList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsASelectAudioOutputCommandToTheDutWithAnIndexFromTheListInStep1_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAudioOutputClusterSelectOutputParams alloc] init]; - params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster selectOutputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a SelectAudioOutput command to the DUT with an index from the list in step 1: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a SelectAudioOutput command to the DUT with an index from the list in step 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheCurrentOutputAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentOutputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentOutput attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentOutput attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentOutput", actualValue, mIndex.HasValue() ? mIndex.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_AUDIOOUTPUT_7_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AUDIOOUTPUT_7_2() - : TestCommandBridge("Test_TC_AUDIOOUTPUT_7_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Index", 0, UINT8_MAX, &mIndex); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AUDIOOUTPUT_7_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AUDIOOUTPUT_7_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AUDIOOUTPUT_7_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the OutputList attribute from the DUT\n"); - if (ShouldSkip("AUDIOOUTPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheOutputListAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a RenameOutput command to the DUT with an index from the list in step 1 and the name 'CertTest'\n"); - if (ShouldSkip("AUDIOOUTPUT.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsARenameOutputCommandToTheDutWithAnIndexFromTheListInStep1AndTheNameCertTest_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the OutputList attribute from the DUT. Verify that the output at the index provided in step 2 has the name CertTest\n"); - if (ShouldSkip("PICS_USER_PROMPT && AUDIOOUTPUT.S.A0001 && AUDIOOUTPUT.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheOutputListAttributeFromTheDutVerifyThatTheOutputAtTheIndexProvidedInStep2HasTheNameCertTest_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mIndex; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSArray * _Nonnull audioOutputListValues; - - CHIP_ERROR TestStep1ThReadsTheOutputListAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the OutputList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the OutputList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("outputList", "list", "list")); - { - audioOutputListValues = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsARenameOutputCommandToTheDutWithAnIndexFromTheListInStep1AndTheNameCertTest_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAudioOutputClusterRenameOutputParams alloc] init]; - params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; - params.name = @"CertTest"; - [cluster renameOutputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a RenameOutput command to the DUT with an index from the list in step 1 and the name 'CertTest': Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a RenameOutput command to the DUT with an index from the list in step 1 and the name 'CertTest': Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheOutputListAttributeFromTheDutVerifyThatTheOutputAtTheIndexProvidedInStep2HasTheNameCertTest_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_TGTNAV_8_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TGTNAV_8_1() - : TestCommandBridge("Test_TC_TGTNAV_8_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("targetvalue", 0, UINT8_MAX, &mTargetvalue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TGTNAV_8_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TGTNAV_8_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TGTNAV_8_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads the CurrentTarget attribute\n"); - if (ShouldSkip("TGTNAV.S.A0001")) { - NextTest(); - return; - } - err = TestStep1aThReadsTheCurrentTargetAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads the TargetList attribute\n"); - if (ShouldSkip("TGTNAV.S.A0000")) { - NextTest(); - return; - } - err = TestStep1bThReadsTheTargetListAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH Sends a NavigateTarget command\n"); - if (ShouldSkip("TGTNAV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsANavigateTargetCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2b: TH reads the CurrentTarget attribute\n"); - if (ShouldSkip("TGTNAV.S.A0001 && TGTNAV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsTheCurrentTargetAttribute_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTargetvalue; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThReadsTheCurrentTargetAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentTargetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads the CurrentTarget attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads the CurrentTarget attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentTarget", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentTarget", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentTarget", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSArray * _Nonnull TargetListValues; - - CHIP_ERROR TestStep1bThReadsTheTargetListAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads the TargetList attribute: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads the TargetList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("targetList", "list", "list")); - { - TargetListValues = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsANavigateTargetCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTargetNavigatorClusterNavigateTargetParams alloc] init]; - params.target = mTargetvalue.HasValue() ? [NSNumber numberWithUnsignedChar:mTargetvalue.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster navigateTargetWithParams:params completion: - ^(MTRTargetNavigatorClusterNavigateTargetResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH Sends a NavigateTarget command: Error: %@", err); - } else { - NSLog(@"Step 2a: TH Sends a NavigateTarget command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsTheCurrentTargetAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentTargetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads the CurrentTarget attribute: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads the CurrentTarget attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentTarget", actualValue, mTargetvalue.HasValue() ? mTargetvalue.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APBSC_9_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APBSC_9_1() - : TestCommandBridge("Test_TC_APBSC_9_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APBSC_9_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APBSC_9_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APBSC_9_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the VendorName attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheVendorNameAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the VendorID attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheVendorIDAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the ApplicationName attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheApplicationNameAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads the ProductID attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0003")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheProductIDAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads the Application attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0004")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheApplicationAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads the Status attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0005")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheStatusAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads the ApplicationVersion attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0006")) { - NextTest(); - return; - } - err = TestStep7ThReadsTheApplicationVersionAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH reads the AllowedVendorList attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0007")) { - NextTest(); - return; - } - err = TestStep8ThReadsTheAllowedVendorListAttributeFromTheDut_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheVendorNameAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the VendorName attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the VendorName attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("vendorName", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("vendorName", value, 32)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheVendorIDAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the VendorID attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the VendorID attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("vendorID", "vendor_id", "vendor_id")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheApplicationNameAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the ApplicationName attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the ApplicationName attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("applicationName", "long_char_string", "long_char_string")); - VerifyOrReturn(CheckConstraintMaxLength("applicationName", value, 256)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheProductIDAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeProductIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the ProductID attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the ProductID attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("productID", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("productID", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("productID", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheApplicationAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationWithCompletion:^(MTRApplicationBasicClusterApplicationStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the Application attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the Application attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("application", "ApplicationStruct", "ApplicationStruct")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheStatusAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the Status attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the Status attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("status", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("status", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsTheApplicationVersionAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationVersionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the ApplicationVersion attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the ApplicationVersion attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("applicationVersion", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("applicationVersion", value, 32)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsTheAllowedVendorListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAllowedVendorListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads the AllowedVendorList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads the AllowedVendorList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("allowedVendorList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CONTENTLAUNCHER_10_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_10_1() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_10_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the AcceptHeader attribute from the DUT\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheAcceptHeaderAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the SupportedStreamingProtocols attribute from the DUT\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheSupportedStreamingProtocolsAttributeFromTheDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheAcceptHeaderAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptHeaderWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the AcceptHeader attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the AcceptHeader attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptHeader", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheSupportedStreamingProtocolsAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedStreamingProtocolsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the SupportedStreamingProtocols attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the SupportedStreamingProtocols attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedStreamingProtocols", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WAKEONLAN_4_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WAKEONLAN_4_1() - : TestCommandBridge("Test_TC_WAKEONLAN_4_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WAKEONLAN_4_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WAKEONLAN_4_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WAKEONLAN_4_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the MACAddress attribute from the DUT\n"); - if (ShouldSkip("WAKEONLAN.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheMACAddressAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a Sleep command to DUT\n"); - if (ShouldSkip("LOWPOWER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsASleepCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends a Wake-On LAN magic packet containing the MAC address from step 1\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep3ThSendsAWakeOnLanMagicPacketContainingTheMacAddressFromStep1_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheMACAddressAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMACAddressWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the MACAddress attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the MACAddress attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("MACAddress", value, 12)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsASleepCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster sleepWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a Sleep command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a Sleep command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsAWakeOnLanMagicPacketContainingTheMacAddressFromStep1_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_ALOGIN_12_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ALOGIN_12_1() - : TestCommandBridge("Test_TC_ALOGIN_12_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("TempAccountIdentifier", &mTempAccountIdentifier); - AddArgument("catalogVendorId", 0, UINT16_MAX, &mCatalogVendorId); - AddArgument("applicationId", &mApplicationId); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ALOGIN_12_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ALOGIN_12_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ALOGIN_12_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Launch an app with the provided a application ID\n"); - if (ShouldSkip("APPLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestLaunchAnAppWithTheProvidedAApplicationId_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH sends a GetSetupPIN command to the DUT with test values provided by the product maker.\n"); - if (ShouldSkip("ALOGIN.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep1ThSendsAGetSetupPINCommandToTheDutWithTestValuesProvidedByTheProductMaker_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a Login command to the DUT with test values provided by the product maker.\n"); - if (ShouldSkip("ALOGIN.S.C02.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2ThSendsALoginCommandToTheDutWithTestValuesProvidedByTheProductMaker_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH sends a Logout command to the DUT with test values provided by the product maker.\n"); - if (ShouldSkip("ALOGIN.S.C03.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep3ThSendsALogoutCommandToTheDutWithTestValuesProvidedByTheProductMaker_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTempAccountIdentifier; - chip::Optional mCatalogVendorId; - chip::Optional mApplicationId; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestLaunchAnAppWithTheProvidedAApplicationId_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRApplicationLauncherClusterLaunchAppParams alloc] init]; - params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = mCatalogVendorId.HasValue() ? [NSNumber numberWithUnsignedShort:mCatalogVendorId.Value()] : [NSNumber numberWithUnsignedShort:123U]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = mApplicationId.HasValue() ? [[NSString alloc] initWithBytes:mApplicationId.Value().data() length:mApplicationId.Value().size() encoding:NSUTF8StringEncoding] : @"exampleid"; - - params.data = - [[NSData alloc] initWithBytes:"Hello World" length:11]; - [cluster launchAppWithParams:params completion: - ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Launch an app with the provided a application ID: Error: %@", err); - } else { - NSLog(@"Launch an app with the provided a application ID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nonnull setupPIN; - - CHIP_ERROR TestStep1ThSendsAGetSetupPINCommandToTheDutWithTestValuesProvidedByTheProductMaker_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterGetSetupPINParams alloc] init]; - params.tempAccountIdentifier = mTempAccountIdentifier.HasValue() ? [[NSString alloc] initWithBytes:mTempAccountIdentifier.Value().data() length:mTempAccountIdentifier.Value().size() encoding:NSUTF8StringEncoding] : @"1111"; - [cluster getSetupPINWithParams:params completion: - ^(MTRAccountLoginClusterGetSetupPINResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a GetSetupPIN command to the DUT with test values provided by the product maker.: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a GetSetupPIN command to the DUT with test values provided by the product maker.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("setupPIN", values.setupPIN, 8)); - { - setupPIN = values.setupPIN; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsALoginCommandToTheDutWithTestValuesProvidedByTheProductMaker_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterLoginParams alloc] init]; - params.tempAccountIdentifier = mTempAccountIdentifier.HasValue() ? [[NSString alloc] initWithBytes:mTempAccountIdentifier.Value().data() length:mTempAccountIdentifier.Value().size() encoding:NSUTF8StringEncoding] : @"1111"; - params.setupPIN = - [setupPIN copy]; - params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; - [cluster loginWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a Login command to the DUT with test values provided by the product maker.: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a Login command to the DUT with test values provided by the product maker.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsALogoutCommandToTheDutWithTestValuesProvidedByTheProductMaker_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterLogoutParams alloc] init]; - params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; - [cluster logoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a Logout command to the DUT with test values provided by the product maker.: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a Logout command to the DUT with test values provided by the product maker.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CONTENTLAUNCHER_10_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_10_3() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("data", &mData); - AddArgument("SearchValue", &mSearchValue); - AddArgument("ExternalIdName", &mExternalIdName); - AddArgument("ExternalIdValue", &mExternalIdValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_10_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to false\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToFalse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify that DUT present via its user interface a list of matches based on the provided search criteria.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutPresentViaItsUserInterfaceAListOfMatchesBasedOnTheProvidedSearchCriteria_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to true\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToTrue_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that DUT should also begin playing content that best matched the given search criteria\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldAlsoBeginPlayingContentThatBestMatchedTheGivenSearchCriteria_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mData; - chip::Optional mSearchValue; - chip::Optional mExternalIdName; - chip::Optional mExternalIdValue; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToFalse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = mSearchValue.HasValue() ? [[NSString alloc] initWithBytes:mSearchValue.Value().data() length:mSearchValue.Value().size() encoding:NSUTF8StringEncoding] : @"exampleValue"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = [[MTRContentLauncherClusterAdditionalInfoStruct alloc] init]; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).name = mExternalIdName.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdName.Value().data() length:mExternalIdName.Value().size() encoding:NSUTF8StringEncoding] : @"name"; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).value = mExternalIdValue.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdValue.Value().data() length:mExternalIdValue.Value().size() encoding:NSUTF8StringEncoding] : @"value"; - - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).externalIDList = temp_4; - } - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:false]; - params.data = mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData"; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - params.useCurrentContext = - [NSNumber numberWithBool:false]; - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to false: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutPresentViaItsUserInterfaceAListOfMatchesBasedOnTheProvidedSearchCriteria_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT present via its user interface a list of matches based on the provided search criteria.garbage: not in length on purpose", 111); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToTrue_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = mSearchValue.HasValue() ? [[NSString alloc] initWithBytes:mSearchValue.Value().data() length:mSearchValue.Value().size() encoding:NSUTF8StringEncoding] : @"exampleValue"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = [[MTRContentLauncherClusterAdditionalInfoStruct alloc] init]; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).name = mExternalIdName.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdName.Value().data() length:mExternalIdName.Value().size() encoding:NSUTF8StringEncoding] : @"name"; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).value = mExternalIdValue.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdValue.Value().data() length:mExternalIdValue.Value().size() encoding:NSUTF8StringEncoding] : @"value"; - - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).externalIDList = temp_4; - } - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.data = mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData"; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - params.useCurrentContext = - [NSNumber numberWithBool:false]; - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to true: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldAlsoBeginPlayingContentThatBestMatchedTheGivenSearchCriteria_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT begin playing content that best matched the given search criteriagarbage: not in length on purpose", 89); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_CONTENTLAUNCHER_10_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_10_5() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("GoodURL", &mGoodURL); - AddArgument("BadURL", &mBadURL); - AddArgument("UnauthorizedURL", &mUnauthorizedURL); - AddArgument("DisplayContent", &mDisplayContent); - AddArgument("providerNameString", &mProviderNameString); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_10_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends a LaunchURL command to the DUT with a known good content URL string\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlString_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify that DUT launched the content at the given URL\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutLaunchedTheContentAtTheGivenUrl_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a LaunchURL command to the DUT with a known good content URL string and a display string\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndADisplayString_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that DUT launched the content at the given URL with the given display string in the application-specific description area\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithTheGivenDisplayStringInTheApplicationSpecificDescriptionArea_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH sends a LaunchURL command to the DUT with a known good content URL string and a brand information object.\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndABrandInformationObject_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Verify that DUT launched the content at the given URL with the player interface updated as per the provided branding information\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithThePlayerInterfaceUpdatedAsPerTheProvidedBrandingInformation_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH sends a LaunchURL command to the DUT with a known unreachable content URL string.\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsALaunchURLCommandToTheDutWithAKnownUnreachableContentUrlString_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH sends a LaunchURL command to the DUT with a known un-authorized content URL string.\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsALaunchURLCommandToTheDutWithAKnownUnAuthorizedContentUrlString_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mGoodURL; - chip::Optional mBadURL; - chip::Optional mUnauthorizedURL; - chip::Optional mDisplayContent; - chip::Optional mProviderNameString; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlString_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mGoodURL.HasValue() ? [[NSString alloc] initWithBytes:mGoodURL.Value().data() length:mGoodURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a LaunchURL command to the DUT with a known good content URL string: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a LaunchURL command to the DUT with a known good content URL string: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutLaunchedTheContentAtTheGivenUrl_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT launched the content at the given URLgarbage: not in length on purpose", 61); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndADisplayString_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mGoodURL.HasValue() ? [[NSString alloc] initWithBytes:mGoodURL.Value().data() length:mGoodURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/"; - params.displayString = mDisplayContent.HasValue() ? [[NSString alloc] initWithBytes:mDisplayContent.Value().data() length:mDisplayContent.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a LaunchURL command to the DUT with a known good content URL string and a display string: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a LaunchURL command to the DUT with a known good content URL string and a display string: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, mDisplayContent.HasValue() ? [[NSString alloc] initWithBytes:mDisplayContent.Value().data() length:mDisplayContent.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithTheGivenDisplayStringInTheApplicationSpecificDescriptionArea_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT launched the content at the given URL with the given display string in the application-specific description areagarbage: not in length on purpose", 136); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndABrandInformationObject_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mGoodURL.HasValue() ? [[NSString alloc] initWithBytes:mGoodURL.Value().data() length:mGoodURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a LaunchURL command to the DUT with a known good content URL string and a brand information object.: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a LaunchURL command to the DUT with a known good content URL string and a brand information object.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithThePlayerInterfaceUpdatedAsPerTheProvidedBrandingInformation_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT launched the content at the given URL with the player interface updated as per the provided branding informationgarbage: not in length on purpose", 136); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThSendsALaunchURLCommandToTheDutWithAKnownUnreachableContentUrlString_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mBadURL.HasValue() ? [[NSString alloc] initWithBytes:mBadURL.Value().data() length:mBadURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://badurl"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a LaunchURL command to the DUT with a known unreachable content URL string.: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a LaunchURL command to the DUT with a known unreachable content URL string.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsALaunchURLCommandToTheDutWithAKnownUnAuthorizedContentUrlString_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mUnauthorizedURL.HasValue() ? [[NSString alloc] initWithBytes:mUnauthorizedURL.Value().data() length:mUnauthorizedURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/badauth"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends a LaunchURL command to the DUT with a known un-authorized content URL string.: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends a LaunchURL command to the DUT with a known un-authorized content URL string.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CONTENTLAUNCHER_10_7 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_10_7() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_7") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("PopularityName", &mPopularityName); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_10_7() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_7\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_7\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Actor and Value as An Actor’s name, for example, Gaby sHoffman\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsActorAndValueAsAnActorsNameForExampleGabySHoffman_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Channel and Value as Channel Name name, for example, PBS\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsChannelAndValueAsChannelNameNameForExamplePbs_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Character and Value as Character’s name,for example,Snow White\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsCharacterAndValueAsCharactersNameforExampleSnowWhite_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Director and Value as Director’s name, for example, Spike Lee\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsDirectorAndValueAsDirectorsNameForExampleSpikeLee_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Event and Value as An Event’s name , for example Football games\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsEventAndValueAsAnEventsNameForExampleFootballGames_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Franchise and Value as Franchise’s name,for example Star Wars\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsFranchiseAndValueAsFranchisesNameforExampleStarWars_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Genre and Value as Genre’s name, for example Horror\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsGenreAndValueAsGenresNameForExampleHorror_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 8: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As League and Value as League’s name, for example NCAA\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsLeagueAndValueAsLeaguesNameForExampleNcaa_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 9: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Popularity and Value as Popularity’s name\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsPopularityAndValueAsPopularitysName_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 10: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Provider and Value as Provider’s name, for example Netflix\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsProviderAndValueAsProvidersNameForExampleNetflix_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 11: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Sport and Value as Sport’s name, for example, football\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep11ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportAndValueAsSportsNameForExampleFootball_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 12: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As SportsTeam and Value as SportTeam’s name , for example Arsenel\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep12ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportsTeamAndValueAsSportTeamsNameForExampleArsenel_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 13: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Type and Value as Type’s name, for example TVSeries\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsTypeAndValueAsTypesNameForExampleTVSeries_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_26(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 27; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPopularityName; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsActorAndValueAsAnActorsNameForExampleGabySHoffman_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Gaby sHoffman"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Actor and Value as An Actor’s name, for example, Gaby sHoffman: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Actor and Value as An Actor’s name, for example, Gaby sHoffman: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsChannelAndValueAsChannelNameNameForExamplePbs_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"PBS"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Channel and Value as Channel Name name, for example, PBS: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Channel and Value as Channel Name name, for example, PBS: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsCharacterAndValueAsCharactersNameforExampleSnowWhite_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Snow White"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:false]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Character and Value as Character’s name,for example,Snow White: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Character and Value as Character’s name,for example,Snow White: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsDirectorAndValueAsDirectorsNameForExampleSpikeLee_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Spike Lee"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Director and Value as Director’s name, for example, Spike Lee: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Director and Value as Director’s name, for example, Spike Lee: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsEventAndValueAsAnEventsNameForExampleFootballGames_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Football games"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Event and Value as An Event’s name , for example Football games: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Event and Value as An Event’s name , for example Football games: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsFranchiseAndValueAsFranchisesNameforExampleStarWars_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Star Wars"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Franchise and Value as Franchise’s name,for example Star Wars: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Franchise and Value as Franchise’s name,for example Star Wars: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_12() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsGenreAndValueAsGenresNameForExampleHorror_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:6U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Horror"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Genre and Value as Genre’s name, for example Horror: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Genre and Value as Genre’s name, for example Horror: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_14() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep8ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsLeagueAndValueAsLeaguesNameForExampleNcaa_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:7U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"NCAA"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As League and Value as League’s name, for example NCAA: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As League and Value as League’s name, for example NCAA: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep9ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsPopularityAndValueAsPopularitysName_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:8U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = mPopularityName.HasValue() ? [[NSString alloc] initWithBytes:mPopularityName.Value().data() length:mPopularityName.Value().size() encoding:NSUTF8StringEncoding] : @"popular content"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Popularity and Value as Popularity’s name: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Popularity and Value as Popularity’s name: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsProviderAndValueAsProvidersNameForExampleNetflix_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:9U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Netflix"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Provider and Value as Provider’s name, for example Netflix: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Provider and Value as Provider’s name, for example Netflix: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_20() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep11ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportAndValueAsSportsNameForExampleFootball_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:10U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"football"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Sport and Value as Sport’s name, for example, football: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Sport and Value as Sport’s name, for example, football: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_22() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep12ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportsTeamAndValueAsSportTeamsNameForExampleArsenel_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:11U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Arsenel"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As SportsTeam and Value as SportTeam’s name , for example Arsenel: Error: %@", err); - } else { - NSLog(@"Step 12: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As SportsTeam and Value as SportTeam’s name , for example Arsenel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_24() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep13ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsTypeAndValueAsTypesNameForExampleTVSeries_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:12U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"TVSeries"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Type and Value as Type’s name, for example TVSeries: Error: %@", err); - } else { - NSLog(@"Step 13: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Type and Value as Type’s name, for example TVSeries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_26() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_MOD_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MOD_1_1() - : TestCommandBridge("Test_TC_MOD_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MOD_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MOD_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MOD_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("MOD.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !MOD.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT\n"); - if (ShouldSkip("MOD.S.A0004")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the Feature dependent attribute(OnMode) in AttributeList from the DUT\n"); - if (ShouldSkip("MOD.S.F00 && MOD.S.A0005")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentAttributeOnModeInAttributeListFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentAttributeOnModeInAttributeListFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent attribute(OnMode) in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent attribute(OnMode) in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class OTA_SuccessfulTransfer : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - OTA_SuccessfulTransfer() - : TestCommandBridge("OTA_SuccessfulTransfer") - , mTestIndex(0) - { - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("requestorNodeId", 0, UINT64_MAX, &mRequestorNodeId); - AddArgument("providerNodeId", 0, UINT64_MAX, &mProviderNodeId); - AddArgument("providerPayload", &mProviderPayload); - AddArgument("providerDiscriminator", 0, UINT16_MAX, &mProviderDiscriminator); - AddArgument("providerPort", 0, UINT16_MAX, &mProviderPort); - AddArgument("providerKvs", &mProviderKvs); - AddArgument("otaImageFilePath", &mOtaImageFilePath); - AddArgument("rawImageFilePath", &mRawImageFilePath); - AddArgument("rawImageContent", &mRawImageContent); - AddArgument("downloadImageFilePath", &mDownloadImageFilePath); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~OTA_SuccessfulTransfer() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: OTA_SuccessfulTransfer\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: OTA_SuccessfulTransfer\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Create OTA image\n"); - err = TestCreateOtaImage_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Start the provider with an image\n"); - err = TestStartTheProviderWithAnImage_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Commission the provider from alpha\n"); - err = TestCommissionTheProviderFromAlpha_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Wait for the commissioned provider to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedProviderToBeRetrievedForAlpha_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Install ACL for QueryImage\n"); - err = TestInstallAclForQueryImage_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Stop the requestor\n"); - err = TestStopTheRequestor_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Start the requestor with an OTA download path\n"); - err = TestStartTheRequestorWithAnOtaDownloadPath_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait for the commissioned requestor to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedRequestorToBeRetrievedForAlpha_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Send an announce OTA provider command to the requestor\n"); - err = TestSendAnAnnounceOtaProviderCommandToTheRequestor_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Wait for transfer complete message\n"); - err = TestWaitForTransferCompleteMessage_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Compare original file to downloaded file\n"); - err = TestCompareOriginalFileToDownloadedFile_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mEndpoint; - chip::Optional mRequestorNodeId; - chip::Optional mProviderNodeId; - chip::Optional mProviderPayload; - chip::Optional mProviderDiscriminator; - chip::Optional mProviderPort; - chip::Optional mProviderKvs; - chip::Optional mOtaImageFilePath; - chip::Optional mRawImageFilePath; - chip::Optional mRawImageContent; - chip::Optional mDownloadImageFilePath; - chip::Optional mTimeout; - - CHIP_ERROR TestCreateOtaImage_0() - { - - chip::app::Clusters::SystemCommands::Commands::CreateOtaImage::Type value; - value.otaImageFilePath = mOtaImageFilePath.HasValue() ? mOtaImageFilePath.Value() : chip::Span("/tmp/otaImage", 13); - value.rawImageFilePath = mRawImageFilePath.HasValue() ? mRawImageFilePath.Value() : chip::Span("/tmp/rawImage", 13); - value.rawImageContent = mRawImageContent.HasValue() ? mRawImageContent.Value() : chip::Span("Have a hootenanny!", 18); - return CreateOtaImage("alpha", value); - } - - CHIP_ERROR TestStartTheProviderWithAnImage_1() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-ota-provider-appgarbage: not in length on purpose", 21); - value.discriminator.Emplace(); - value.discriminator.Value() = mProviderDiscriminator.HasValue() ? mProviderDiscriminator.Value() : 50U; - value.port.Emplace(); - value.port.Value() = mProviderPort.HasValue() ? mProviderPort.Value() : 5560U; - value.kvs.Emplace(); - value.kvs.Value() = mProviderKvs.HasValue() ? mProviderKvs.Value() : chip::Span("/tmp/chip_kvs_provider", 22); - value.filepath.Emplace(); - value.filepath.Value() = mOtaImageFilePath.HasValue() ? mOtaImageFilePath.Value() : chip::Span("/tmp/otaImage", 13); - return Start("alpha", value); - } - - CHIP_ERROR TestCommissionTheProviderFromAlpha_2() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mProviderNodeId.HasValue() ? mProviderNodeId.Value() : 12648430ULL; - value.payload = mProviderPayload.HasValue() ? mProviderPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedProviderToBeRetrievedForAlpha_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mProviderNodeId.HasValue() ? mProviderNodeId.Value() : 12648430ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestInstallAclForQueryImage_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:41UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Install ACL for QueryImage: Error: %@", err); - } else { - NSLog(@"Install ACL for QueryImage: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStopTheRequestor_5() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheRequestorWithAnOtaDownloadPath_6() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.otaDownloadPath.Emplace(); - value.otaDownloadPath.Value() = mDownloadImageFilePath.HasValue() ? mDownloadImageFilePath.Value() : chip::Span("/tmp/downloadedImage", 20); - return Start("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedRequestorToBeRetrievedForAlpha_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mRequestorNodeId.HasValue() ? mRequestorNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendAnAnnounceOtaProviderCommandToTheRequestor_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOTASoftwareUpdateRequestor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROTASoftwareUpdateRequestorClusterAnnounceOTAProviderParams alloc] init]; - params.providerNodeID = mProviderNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mProviderNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:12648430ULL]; - params.vendorID = - [NSNumber numberWithUnsignedShort:0U]; - params.announcementReason = - [NSNumber numberWithUnsignedChar:0U]; - params.endpoint = mEndpoint.HasValue() ? [NSNumber numberWithUnsignedShort:mEndpoint.Value()] : [NSNumber numberWithUnsignedShort:0U]; - [cluster announceOTAProviderWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send an announce OTA provider command to the requestor: Error: %@", err); - } else { - NSLog(@"Send an announce OTA provider command to the requestor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitForTransferCompleteMessage_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMessage::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - value.message = chip::Span("OTA image downloadedgarbage: not in length on purpose", 20); - return WaitForMessage("alpha", value); - } - - CHIP_ERROR TestCompareOriginalFileToDownloadedFile_10() - { - - chip::app::Clusters::SystemCommands::Commands::CompareFiles::Type value; - value.file1 = mRawImageFilePath.HasValue() ? mRawImageFilePath.Value() : chip::Span("/tmp/rawImage", 13); - value.file2 = mDownloadImageFilePath.HasValue() ? mDownloadImageFilePath.Value() : chip::Span("/tmp/downloadedImage", 20); - return CompareFiles("alpha", value); - } -}; - -class Test_TC_OCC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OCC_1_1() - : TestCommandBridge("Test_TC_OCC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OCC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OCC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OCC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the (0xFFFC) FeatureMap attribute\n"); - err = TestStep3ThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(PIROccupiedToUnoccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0010")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributePIROccupiedToUnoccupiedDelayInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads optional attribute(PIRUnoccupiedToOccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributePIRUnoccupiedToOccupiedDelayInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads optional attribute(PIRUnoccupiedToOccupiedThreshold) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributePIRUnoccupiedToOccupiedThresholdInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: TH reads optional attribute(UltrasonicOccupiedToUnoccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeUltrasonicOccupiedToUnoccupiedDelayInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedDelayInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedThreshold) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0022")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedThresholdInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4h: TH reads optional attribute(PhysicalContactOccupiedToUnoccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0030")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributePhysicalContactOccupiedToUnoccupiedDelayInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4i: TH reads the optional attribute(PhysicalContactUnoccupiedToOccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0031")) { - NextTest(); - return; - } - err = TestStep4iThReadsTheOptionalAttributePhysicalContactUnoccupiedToOccupiedDelayInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4j: TH reads optional attribute(PhysicalContactUnoccupiedToOccupiedThreshold) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0032")) { - NextTest(); - return; - } - err = TestStep4jThReadsOptionalAttributePhysicalContactUnoccupiedToOccupiedThresholdInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5: TH reads from the DUT the (0xFFFA) EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute\n"); - err = TestStep6ThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributePIROccupiedToUnoccupiedDelayInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(PIROccupiedToUnoccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(PIROccupiedToUnoccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributePIRUnoccupiedToOccupiedDelayInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(PIRUnoccupiedToOccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(PIRUnoccupiedToOccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributePIRUnoccupiedToOccupiedThresholdInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(PIRUnoccupiedToOccupiedThreshold) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(PIRUnoccupiedToOccupiedThreshold) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeUltrasonicOccupiedToUnoccupiedDelayInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(UltrasonicOccupiedToUnoccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(UltrasonicOccupiedToUnoccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedDelayInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedThresholdInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedThreshold) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedThreshold) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributePhysicalContactOccupiedToUnoccupiedDelayInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(PhysicalContactOccupiedToUnoccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(PhysicalContactOccupiedToUnoccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsTheOptionalAttributePhysicalContactUnoccupiedToOccupiedDelayInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads the optional attribute(PhysicalContactUnoccupiedToOccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads the optional attribute(PhysicalContactUnoccupiedToOccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsOptionalAttributePhysicalContactUnoccupiedToOccupiedThresholdInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads optional attribute(PhysicalContactUnoccupiedToOccupiedThreshold) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads optional attribute(PhysicalContactUnoccupiedToOccupiedThreshold) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OCC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OCC_2_1() - : TestCommandBridge("Test_TC_OCC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OCC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OCC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OCC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0x0000) Occupancy attribute\n"); - if (ShouldSkip("OCC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutThe0x0000OccupancyAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the (0x0001) OccupancySensorType attribute\n"); - if (ShouldSkip("OCC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutThe0x0001OccupancySensorTypeAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4:TH reads from the DUT the (0x0002) OccupancySensorTypeBitmap attribute\n"); - if (ShouldSkip("OCC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4thReadsFromTheDutThe0x0002OccupancySensorTypeBitmapAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the (0x0010) PIROccupiedToUnoccupiedDelay optional attribute, if PIR sensor\n"); - if (ShouldSkip("OCC.S.A0010")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThe0x0010PIROccupiedToUnoccupiedDelayOptionalAttributeIfPirSensor_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the (0x0011) PIRUnoccupiedToOccupiedDelay optional attribute, if PIR sensor\n"); - if (ShouldSkip("OCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThe0x0011PIRUnoccupiedToOccupiedDelayOptionalAttributeIfPirSensor_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the (0x0012) PIRUnoccupiedToOccupiedThreshold optional attribute, if PIR sensor\n"); - if (ShouldSkip("OCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutThe0x0012PIRUnoccupiedToOccupiedThresholdOptionalAttributeIfPirSensor_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the (0x0020) UltrasonicOccupiedToUnoccupiedDelay optional attribute, if ultrasonic sensor\n"); - if (ShouldSkip("OCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutThe0x0020UltrasonicOccupiedToUnoccupiedDelayOptionalAttributeIfUltrasonicSensor_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the (0x0021) UltrasonicUnoccupiedToOccupiedDelay optional attribute, if ultrasonic sensor\n"); - if (ShouldSkip("OCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutThe0x0021UltrasonicUnoccupiedToOccupiedDelayOptionalAttributeIfUltrasonicSensor_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the (0x0022) UltrasonicUnoccupiedToOccupiedThreshold optional attribute, if ultrasonic sensor\n"); - if (ShouldSkip("OCC.S.A0022")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutThe0x0022UltrasonicUnoccupiedToOccupiedThresholdOptionalAttributeIfUltrasonicSensor_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11:TH reads from the DUT the (0x0030) PhysicalContactOccupiedToUnoccupiedDelay optional attribute, if Physical Contact sensor\n"); - if (ShouldSkip("OCC.S.A0030")) { - NextTest(); - return; - } - err = TestStep11thReadsFromTheDutThe0x0030PhysicalContactOccupiedToUnoccupiedDelayOptionalAttributeIfPhysicalContactSensor_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the (0x0031) PhysicalContactUnoccupiedToOccupiedDelay optional attribute, if Physical Contact sensor\n"); - if (ShouldSkip("OCC.S.A0031")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutThe0x0031PhysicalContactUnoccupiedToOccupiedDelayOptionalAttributeIfPhysicalContactSensor_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the (0x0032) PhysicalContactUnoccupiedToOccupiedThreshold optional attribute, if Physical Contact sensor\n"); - if (ShouldSkip("OCC.S.A0032")) { - NextTest(); - return; - } - err = TestStep13ThReadsFromTheDutThe0x0032PhysicalContactUnoccupiedToOccupiedThresholdOptionalAttributeIfPhysicalContactSensor_12(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0x0000OccupancyAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0x0000) Occupancy attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0x0000) Occupancy attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancy", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("occupancy", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancy", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutThe0x0001OccupancySensorTypeAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancySensorTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the (0x0001) OccupancySensorType attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the (0x0001) OccupancySensorType attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancySensorType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("occupancySensorType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancySensorType", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4thReadsFromTheDutThe0x0002OccupancySensorTypeBitmapAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancySensorTypeBitmapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4:TH reads from the DUT the (0x0002) OccupancySensorTypeBitmap attribute: Error: %@", err); - } else { - NSLog(@"Step 4:TH reads from the DUT the (0x0002) OccupancySensorTypeBitmap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancySensorTypeBitmap", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("occupancySensorTypeBitmap", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancySensorTypeBitmap", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThe0x0010PIROccupiedToUnoccupiedDelayOptionalAttributeIfPirSensor_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePIROccupiedToUnoccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the (0x0010) PIROccupiedToUnoccupiedDelay optional attribute, if PIR sensor: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the (0x0010) PIROccupiedToUnoccupiedDelay optional attribute, if PIR sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("PIROccupiedToUnoccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("PIROccupiedToUnoccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PIROccupiedToUnoccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThe0x0011PIRUnoccupiedToOccupiedDelayOptionalAttributeIfPirSensor_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePIRUnoccupiedToOccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the (0x0011) PIRUnoccupiedToOccupiedDelay optional attribute, if PIR sensor: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the (0x0011) PIRUnoccupiedToOccupiedDelay optional attribute, if PIR sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("PIRUnoccupiedToOccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("PIRUnoccupiedToOccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PIRUnoccupiedToOccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0x0012PIRUnoccupiedToOccupiedThresholdOptionalAttributeIfPirSensor_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePIRUnoccupiedToOccupiedThresholdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0x0012) PIRUnoccupiedToOccupiedThreshold optional attribute, if PIR sensor: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0x0012) PIRUnoccupiedToOccupiedThreshold optional attribute, if PIR sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("PIRUnoccupiedToOccupiedThreshold", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("PIRUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("PIRUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutThe0x0020UltrasonicOccupiedToUnoccupiedDelayOptionalAttributeIfUltrasonicSensor_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUltrasonicOccupiedToUnoccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the (0x0020) UltrasonicOccupiedToUnoccupiedDelay optional attribute, if ultrasonic sensor: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the (0x0020) UltrasonicOccupiedToUnoccupiedDelay optional attribute, if ultrasonic sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("ultrasonicOccupiedToUnoccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("ultrasonicOccupiedToUnoccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("ultrasonicOccupiedToUnoccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutThe0x0021UltrasonicUnoccupiedToOccupiedDelayOptionalAttributeIfUltrasonicSensor_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUltrasonicUnoccupiedToOccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the (0x0021) UltrasonicUnoccupiedToOccupiedDelay optional attribute, if ultrasonic sensor: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the (0x0021) UltrasonicUnoccupiedToOccupiedDelay optional attribute, if ultrasonic sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("ultrasonicUnoccupiedToOccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("ultrasonicUnoccupiedToOccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("ultrasonicUnoccupiedToOccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutThe0x0022UltrasonicUnoccupiedToOccupiedThresholdOptionalAttributeIfUltrasonicSensor_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUltrasonicUnoccupiedToOccupiedThresholdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the (0x0022) UltrasonicUnoccupiedToOccupiedThreshold optional attribute, if ultrasonic sensor: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the (0x0022) UltrasonicUnoccupiedToOccupiedThreshold optional attribute, if ultrasonic sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("ultrasonicUnoccupiedToOccupiedThreshold", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("ultrasonicUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("ultrasonicUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11thReadsFromTheDutThe0x0030PhysicalContactOccupiedToUnoccupiedDelayOptionalAttributeIfPhysicalContactSensor_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalContactOccupiedToUnoccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11:TH reads from the DUT the (0x0030) PhysicalContactOccupiedToUnoccupiedDelay optional attribute, if Physical Contact sensor: Error: %@", err); - } else { - NSLog(@"Step 11:TH reads from the DUT the (0x0030) PhysicalContactOccupiedToUnoccupiedDelay optional attribute, if Physical Contact sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalContactOccupiedToUnoccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("physicalContactOccupiedToUnoccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalContactOccupiedToUnoccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutThe0x0031PhysicalContactUnoccupiedToOccupiedDelayOptionalAttributeIfPhysicalContactSensor_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalContactUnoccupiedToOccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the (0x0031) PhysicalContactUnoccupiedToOccupiedDelay optional attribute, if Physical Contact sensor: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the (0x0031) PhysicalContactUnoccupiedToOccupiedDelay optional attribute, if Physical Contact sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalContactUnoccupiedToOccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("physicalContactUnoccupiedToOccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalContactUnoccupiedToOccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsFromTheDutThe0x0032PhysicalContactUnoccupiedToOccupiedThresholdOptionalAttributeIfPhysicalContactSensor_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalContactUnoccupiedToOccupiedThresholdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads from the DUT the (0x0032) PhysicalContactUnoccupiedToOccupiedThreshold optional attribute, if Physical Contact sensor: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads from the DUT the (0x0032) PhysicalContactUnoccupiedToOccupiedThreshold optional attribute, if Physical Contact sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalContactUnoccupiedToOccupiedThreshold", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("physicalContactUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalContactUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OCC_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OCC_2_3() - : TestCommandBridge("Test_TC_OCC_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OCC_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OCC_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OCC_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads OccupancySensorType attribute from DUT\n"); - if (ShouldSkip("OCC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsOccupancySensorTypeAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads OccupancySensorTypeBitmap attribute from DUT\n"); - if (ShouldSkip("OCC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsOccupancySensorTypeBitmapAttributeFromDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsOccupancySensorTypeAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancySensorTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads OccupancySensorType attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads OccupancySensorType attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancySensorType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("occupancySensorType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancySensorType", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsOccupancySensorTypeBitmapAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancySensorTypeBitmapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads OccupancySensorTypeBitmap attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads OccupancySensorTypeBitmap attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancySensorTypeBitmap", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("occupancySensorTypeBitmap", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancySensorTypeBitmap", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OO_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OO_1_1() - : TestCommandBridge("Test_TC_OO_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OO_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("( !OO.S.F00 && !OO.S.F01 )")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given OO.S.F00(LT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OO.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenOosf00ltEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given OO.S.F01(DF) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OO.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenOosf01dfEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads the feature dependent(OO.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("OO.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentOOSF00AttributeInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6b: TH reads the feature dependent(OO.S.F00) commands in AcceptedCommandList\n"); - if (ShouldSkip("OO.S.F00")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheFeatureDependentOOSF00CommandsInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 5U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenOosf00ltEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given OO.S.F00(LT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given OO.S.F00(LT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenOosf01dfEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given OO.S.F01(DF) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given OO.S.F01(DF) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentOOSF00AttributeInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the feature dependent(OO.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the feature dependent(OO.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16384UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16385UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16386UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16387UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheFeatureDependentOOSF00CommandsInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the feature dependent(OO.S.F00) commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the feature dependent(OO.S.F00) commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 65UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 66UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OO_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OO_2_1() - : TestCommandBridge("Test_TC_OO_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OO_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheOnOffAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the GlobalSceneControl attribute from the DUT\n"); - if (ShouldSkip("OO.S.A4000")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheGlobalSceneControlAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads the OnTime attribute from the DUT\n"); - if (ShouldSkip("OO.S.A4001")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheOnTimeAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads the OffWaitTime attribute from the DUT\n"); - if (ShouldSkip("OO.S.A4002")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheOffWaitTimeAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads the StartUpOnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheStartUpOnOffAttributeFromTheDut_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheOnOffAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("onOff", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheGlobalSceneControlAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGlobalSceneControlWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the GlobalSceneControl attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the GlobalSceneControl attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("globalSceneControl", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheOnTimeAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the OnTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the OnTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("onTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheOffWaitTimeAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOffWaitTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the OffWaitTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the OffWaitTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("offWaitTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("offWaitTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("offWaitTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheStartUpOnOffAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the StartUpOnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the StartUpOnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpOnOff", "enum8", "enum8")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OO_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OO_2_2() - : TestCommandBridge("Test_TC_OO_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OO_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsOffCommandToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep2bAfterAFewSecondsThReadsOnOffAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsOnCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bAfterAFewSecondsThReadsOnOffAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThSendsOnCommandToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3d: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dAfterAFewSecondsThReadsOnOffAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsOffCommandToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bAfterAFewSecondsThReadsOnOffAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4cThSendsOffCommandToDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep4dAfterAFewSecondsThReadsOnOffAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5c: TH sends Toggle command to DUT\n"); - if (ShouldSkip("OO.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep5cThSendsToggleCommandToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 1000ms\n"); - err = TestWait1000ms_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5d: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep5dAfterAFewSecondsThReadsOnOffAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : TH sends Toggle command to DUT\n"); - if (ShouldSkip("OO.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestThSendsToggleCommandToDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 1000ms\n"); - err = TestWait1000ms_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Check on/off attribute value is false after toggle command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterToggleCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6a: Operate on device to set OnOff attribute manually to on\n"); - if (ShouldSkip("PICS_USER_PROMPT && OO.M.ManuallyControlled && OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6aOperateOnDeviceToSetOnOffAttributeManuallyToOn_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6b: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && OO.S.A0000 && OO.M.ManuallyControlled")) { - NextTest(); - return; - } - err = TestStep6bAfterAFewSecondsThReadsOnOffAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6c: Operate on device to set OnOff attribute manually to off\n"); - if (ShouldSkip("PICS_USER_PROMPT && OO.M.ManuallyControlled && OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6cOperateOnDeviceToSetOnOffAttributeManuallyToOff_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 6d: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && OO.S.A0000 && OO.M.ManuallyControlled")) { - NextTest(); - return; - } - err = TestStep6dAfterAFewSecondsThReadsOnOffAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Reset Off Command\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestResetOffCommand_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsOffCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bAfterAFewSecondsThReadsOnOffAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsOnCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bAfterAFewSecondsThReadsOnOffAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThSendsOnCommandToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dAfterAFewSecondsThReadsOnOffAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsOffCommandToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bAfterAFewSecondsThReadsOnOffAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThSendsOffCommandToDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dAfterAFewSecondsThReadsOnOffAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThSendsToggleCommandToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster toggleWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH sends Toggle command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH sends Toggle command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5dAfterAFewSecondsThReadsOnOffAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5d: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsToggleCommandToDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster toggleWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends Toggle command to DUT: Error: %@", err); - } else { - NSLog(@"TH sends Toggle command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterToggleCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after toggle command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after toggle command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aOperateOnDeviceToSetOnOffAttributeManuallyToOn_17() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6bAfterAFewSecondsThReadsOnOffAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cOperateOnDeviceToSetOnOffAttributeManuallyToOff_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6dAfterAFewSecondsThReadsOnOffAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6d: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResetOffCommand_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reset Off Command: Error: %@", err); - } else { - NSLog(@"Reset Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OO_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OO_2_4() - : TestCommandBridge("Test_TC_OO_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OO_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsOnCommandToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH writes a value of 0 to StartUpOnOff attribute of DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep3aThWritesAValueOf0ToStartUpOnOffAttributeOfDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep3bRebootTargetDevice_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep3cRebootTargetDeviceDUT_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3d: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheOnOffAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH writes a value of 1 to StartUpOnOff attribute of DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep4aThWritesAValueOf1ToStartUpOnOffAttributeOfDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep4bRebootTargetDevice_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4cRebootTargetDeviceDUT_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4d: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOnOffAttributeFromTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5a: TH writes a value of 2 to StartUpOnOff attribute of DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep5aThWritesAValueOf2ToStartUpOnOffAttributeOfDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep5bRebootTargetDevice_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep5cRebootTargetDeviceDUT_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5d: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep5dThReadsTheOnOffAttributeFromTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5e: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep5eRebootTargetDevice_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5f: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep5fRebootTargetDeviceDUT_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5g: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep5gThReadsTheOnOffAttributeFromTheDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 6a: TH writes NULL to StartUpOnOff attribute of DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep6aThWritesNullToStartUpOnOffAttributeOfDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 6b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep6bRebootTargetDevice_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 6c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep6cRebootTargetDeviceDUT_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 6d: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6dThReadsTheOnOffAttributeFromTheDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 6e: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6eThSendsOffCommandToDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 6f: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6fThReadsTheOnOffAttributeFromTheDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6g: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep6gRebootTargetDevice_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 6h: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep6hRebootTargetDeviceDUT_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 6i: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6iThReadsTheOnOffAttributeFromTheDut_31(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 32; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsOnCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWritesAValueOf0ToStartUpOnOffAttributeOfDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH writes a value of 0 to StartUpOnOff attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH writes a value of 0 to StartUpOnOff attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bRebootTargetDevice_3() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep3cRebootTargetDeviceDUT_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsTheOnOffAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWritesAValueOf1ToStartUpOnOffAttributeOfDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH writes a value of 1 to StartUpOnOff attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH writes a value of 1 to StartUpOnOff attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bRebootTargetDevice_8() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep4cRebootTargetDeviceDUT_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep4dThReadsTheOnOffAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWritesAValueOf2ToStartUpOnOffAttributeOfDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH writes a value of 2 to StartUpOnOff attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH writes a value of 2 to StartUpOnOff attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bRebootTargetDevice_13() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep5cRebootTargetDeviceDUT_14() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep5dThReadsTheOnOffAttributeFromTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5d: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5eRebootTargetDevice_17() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep5fRebootTargetDeviceDUT_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep5gThReadsTheOnOffAttributeFromTheDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5g: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5g: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThWritesNullToStartUpOnOffAttributeOfDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = nil; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH writes NULL to StartUpOnOff attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH writes NULL to StartUpOnOff attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bRebootTargetDevice_22() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep6cRebootTargetDeviceDUT_23() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_24() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep6dThReadsTheOnOffAttributeFromTheDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eThSendsOffCommandToDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 6e: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fThReadsTheOnOffAttributeFromTheDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6f: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gRebootTargetDevice_28() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep6hRebootTargetDeviceDUT_29() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_30() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep6iThReadsTheOnOffAttributeFromTheDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6i: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6i: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OPSTATE_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OPSTATE_1_1() - : TestCommandBridge("Test_TC_OPSTATE_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OPSTATE_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OPSTATE_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OPSTATE_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT\n"); - if (ShouldSkip("OPSTATE.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5a: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5b: TH reads from the DUT the optional event(OperationCompletion) in EventList.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && OPSTATE.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6a: TH reads the optional command(Start) in AcceptedCommandList\n"); - if (ShouldSkip("OPSTATE.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsTheOptionalCommandStartInAcceptedCommandList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6b: TH reads the optional command(Stop) in AcceptedCommandList\n"); - if (ShouldSkip("OPSTATE.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6c: TH reads the optional command(Pause) in AcceptedCommandList\n"); - if (ShouldSkip("OPSTATE.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThReadsTheOptionalCommandPauseInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6d: TH reads the optional command(Resume) in AcceptedCommandList\n"); - if (ShouldSkip("OPSTATE.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: TH reads from the DUT the AcceptedCommandList attribute\n"); - if (ShouldSkip("!OPSTATE.S.C00.Rsp && !OPSTATE.S.C01.Rsp && !OPSTATE.S.C02.Rsp && !OPSTATE.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAcceptedCommandListAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - if (ShouldSkip("(OPSTATE.S.C00.Rsp || OPSTATE.S.C01.Rsp || OPSTATE.S.C02.Rsp || OPSTATE.S.C03.Rsp)")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsTheOptionalCommandStartInAcceptedCommandList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads the optional command(Start) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads the optional command(Start) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsTheOptionalCommandPauseInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads the optional command(Pause) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads the optional command(Pause) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAcceptedCommandListAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PS_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PS_1_1() - : TestCommandBridge("Test_TC_PS_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PS_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PS_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PS_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Test Harness Client reads ClusterRevision attribute.\n"); - err = TestStep2TestHarnessClientReadsClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !PS.S.F00 && !PS.S.F01 && !PS.S.F02 && !PS.S.F03 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PS.S.F00(WIRED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PS.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPssf00wiredEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PS.S.F01(BAT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PS.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenPssf01batEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3c: Given PS.S.F02(RECHG) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PS.S.F02")) { - NextTest(); - return; - } - err = TestStep3cGivenPssf02rechgEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3d: Given PS.S.F03(REPLC) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PS.S.F03")) { - NextTest(); - return; - } - err = TestStep3dGivenPssf03replcEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: Test Harness Client reads AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4TestHarnessClientReadsAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: Test Harness Client reads AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4TestHarnessClientReadsAttributeListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads the Feature dependent(PS.S.F00-WIRED) attribute in AttributeList\n"); - if (ShouldSkip("PS.S.F00")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheFeatureDependentPSSF00WiredAttributeInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads the Feature dependent(PS.S.F01-BAT) attribute in AttributeList\n"); - if (ShouldSkip("PS.S.F01")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentPSSF01BatAttributeInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: TH reads the Feature dependent(PS.S.F02-RECHG) attribute in AttributeList\n"); - if (ShouldSkip("PS.S.F02")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentPSSF02RechgAttributeInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: TH reads the Feature dependent(PS.S.F03-REPLC) attribute in AttributeList\n"); - if (ShouldSkip("PS.S.F03")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheFeatureDependentPSSF03ReplcAttributeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: Test Harness Client reads EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !PS.S.E00 && !PS.S.E01 && !PS.S.E02 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: TH reads PS.S.E00(WiredFaultChange) event in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PS.S.E00")) { - NextTest(); - return; - } - NextTest(); - return; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5c: TH reads PS.S.E01(BatFaultChange) event in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PS.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5d: TH reads PS.S.E02(BatChargeFaultChange) event in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PS.S.E02")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6: Test Harness Client reads AcceptedCommandList attribute.\n"); - err = TestStep6TestHarnessClientReadsAcceptedCommandListAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 7: Test Harness Client reads GeneratedCommandList attribute.\n"); - err = TestStep7TestHarnessClientReadsGeneratedCommandListAttribute_18(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 19; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2TestHarnessClientReadsClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Test Harness Client reads ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: Test Harness Client reads ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPssf00wiredEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PS.S.F00(WIRED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PS.S.F00(WIRED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPssf01batEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PS.S.F01(BAT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PS.S.F01(BAT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPssf02rechgEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PS.S.F02(RECHG) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PS.S.F02(RECHG) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPssf03replcEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PS.S.F03(REPLC) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PS.S.F03(REPLC) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4TestHarnessClientReadsAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Test Harness Client reads AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: Test Harness Client reads AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 31UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4TestHarnessClientReadsAttributeListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Test Harness Client reads AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: Test Harness Client reads AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 31UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheFeatureDependentPSSF00WiredAttributeInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the Feature dependent(PS.S.F00-WIRED) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the Feature dependent(PS.S.F00-WIRED) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentPSSF01BatAttributeInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the Feature dependent(PS.S.F01-BAT) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the Feature dependent(PS.S.F01-BAT) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentPSSF02RechgAttributeInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent(PS.S.F02-RECHG) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent(PS.S.F02-RECHG) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheFeatureDependentPSSF03ReplcAttributeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the Feature dependent(PS.S.F03-REPLC) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the Feature dependent(PS.S.F03-REPLC) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6TestHarnessClientReadsAcceptedCommandListAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Test Harness Client reads AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: Test Harness Client reads AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7TestHarnessClientReadsGeneratedCommandListAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Test Harness Client reads GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: Test Harness Client reads GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PS_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PS_2_1() - : TestCommandBridge("Test_TC_PS_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PS_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PS_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PS_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Test Harness Client reads Status from server DUT\n"); - if (ShouldSkip("PS.S.A0000")) { - NextTest(); - return; - } - err = TestStep2TestHarnessClientReadsStatusFromServerDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Test Harness Client reads Order from server DUT\n"); - if (ShouldSkip("PS.S.A0001")) { - NextTest(); - return; - } - err = TestStep3TestHarnessClientReadsOrderFromServerDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: Test Harness Client reads Order from server DUT\n"); - if (ShouldSkip("PS.S.A0002")) { - NextTest(); - return; - } - err = TestStep4TestHarnessClientReadsOrderFromServerDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: Test Harness Client reads WiredAssessedInputVoltage from server DUT\n"); - if (ShouldSkip("PS.S.A0003")) { - NextTest(); - return; - } - err = TestStep5TestHarnessClientReadsWiredAssessedInputVoltageFromServerDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: Test Harness Client reads WiredAssessedInputFrequencyfrom server DUT\n"); - if (ShouldSkip("PS.S.A0004")) { - NextTest(); - return; - } - err = TestStep6TestHarnessClientReadsWiredAssessedInputFrequencyfromServerDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: Test Harness Client reads WiredCurrentType from server DUT\n"); - if (ShouldSkip("PS.S.A0005")) { - NextTest(); - return; - } - err = TestStep7TestHarnessClientReadsWiredCurrentTypeFromServerDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: Test Harness Client reads WiredAssessedCurrent from server DUT\n"); - if (ShouldSkip("PS.S.A0006")) { - NextTest(); - return; - } - err = TestStep8TestHarnessClientReadsWiredAssessedCurrentFromServerDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: Test Harness Client reads WiredNominalVoltage from server DUT\n"); - if (ShouldSkip("PS.S.A0007")) { - NextTest(); - return; - } - err = TestStep9TestHarnessClientReadsWiredNominalVoltageFromServerDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: Test Harness Client reads WiredMaximumCurrent from Server DUT\n"); - if (ShouldSkip("PS.S.A0008")) { - NextTest(); - return; - } - err = TestStep10TestHarnessClientReadsWiredMaximumCurrentFromServerDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: Test Harness Client reads WiredPresent from Server DUT\n"); - if (ShouldSkip("PS.S.A0009")) { - NextTest(); - return; - } - err = TestStep11TestHarnessClientReadsWiredPresentFromServerDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: Test Harness Client reads ActiveWiredFaults from Server DUT\n"); - if (ShouldSkip("PS.S.A000a")) { - NextTest(); - return; - } - err = TestStep12TestHarnessClientReadsActiveWiredFaultsFromServerDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: Test Harness Client reads BatVoltage from Server DUT\n"); - if (ShouldSkip("PS.S.A000b")) { - NextTest(); - return; - } - err = TestStep13TestHarnessClientReadsBatVoltageFromServerDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: Test Harness Client reads BatPercentRemaining from Server DUT\n"); - if (ShouldSkip("PS.S.A000c")) { - NextTest(); - return; - } - err = TestStep14TestHarnessClientReadsBatPercentRemainingFromServerDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: Test Harness Client reads BatTimeRemaining from Server DUT\n"); - if (ShouldSkip("PS.S.A000d")) { - NextTest(); - return; - } - err = TestStep15TestHarnessClientReadsBatTimeRemainingFromServerDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: Test Harness Client reads BatChargeLevel from Server DUT\n"); - if (ShouldSkip("PS.S.A000e")) { - NextTest(); - return; - } - err = TestStep16TestHarnessClientReadsBatChargeLevelFromServerDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: Test Harness Client reads BatReplacementNeeded from Server DUT\n"); - if (ShouldSkip("PS.S.A000f")) { - NextTest(); - return; - } - err = TestStep17TestHarnessClientReadsBatReplacementNeededFromServerDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: Test Harness Client reads BatReplaceability from Server DUT\n"); - if (ShouldSkip("PS.S.A0010")) { - NextTest(); - return; - } - err = TestStep18TestHarnessClientReadsBatReplaceabilityFromServerDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 19: Test Harness Client reads BatPresent from Server DUT\n"); - if (ShouldSkip("PS.S.A0011")) { - NextTest(); - return; - } - err = TestStep19TestHarnessClientReadsBatPresentFromServerDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 20: Test Harness Client readsActiveBatFaults from Server DUT\n"); - if (ShouldSkip("PS.S.A0012")) { - NextTest(); - return; - } - err = TestStep20TestHarnessClientReadsActiveBatFaultsFromServerDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 21: Test Harness Client reads BatReplacementDescription from Server DUT\n"); - if (ShouldSkip("PS.S.A0013")) { - NextTest(); - return; - } - err = TestStep21TestHarnessClientReadsBatReplacementDescriptionFromServerDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 22: Test Harness Client reads BatCommonDesignation from Server DUT\n"); - if (ShouldSkip("PS.S.A0014")) { - NextTest(); - return; - } - err = TestStep22TestHarnessClientReadsBatCommonDesignationFromServerDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 23: Test Harness Client reads BatANSIDesignation from Server DUT\n"); - if (ShouldSkip("PS.S.A0015")) { - NextTest(); - return; - } - err = TestStep23TestHarnessClientReadsBatANSIDesignationFromServerDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 24: Test Harness Client reads BatIECDesignation from Server DUT\n"); - if (ShouldSkip("PS.S.A0016")) { - NextTest(); - return; - } - err = TestStep24TestHarnessClientReadsBatIECDesignationFromServerDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 25: Test Harness Client reads BatApprovedChemistry from Server DUT\n"); - if (ShouldSkip("PS.S.A0017")) { - NextTest(); - return; - } - err = TestStep25TestHarnessClientReadsBatApprovedChemistryFromServerDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 26: Test Harness Client reads BatCapacity from Server DUT\n"); - if (ShouldSkip("PS.S.A0018")) { - NextTest(); - return; - } - err = TestStep26TestHarnessClientReadsBatCapacityFromServerDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 27: Test Harness Client reads BatQuantity from Server DUT\n"); - if (ShouldSkip("PS.S.A0019")) { - NextTest(); - return; - } - err = TestStep27TestHarnessClientReadsBatQuantityFromServerDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 28: Test Harness Client reads BatChargeState from Server DUT\n"); - if (ShouldSkip("PS.S.A001a")) { - NextTest(); - return; - } - err = TestStep28TestHarnessClientReadsBatChargeStateFromServerDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 29: Test Harness Client reads BatTimeToFullCharge from Server DUT\n"); - if (ShouldSkip("PS.S.A001b")) { - NextTest(); - return; - } - err = TestStep29TestHarnessClientReadsBatTimeToFullChargeFromServerDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 30: Test Harness Client reads BatFunctionalWhileCharging from Server DUT\n"); - if (ShouldSkip("PS.S.A001c")) { - NextTest(); - return; - } - err = TestStep30TestHarnessClientReadsBatFunctionalWhileChargingFromServerDut_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 31: Test Harness Client reads BatChargingCurrent from Server DUT\n"); - if (ShouldSkip("PS.S.A001d")) { - NextTest(); - return; - } - err = TestStep31TestHarnessClientReadsBatChargingCurrentFromServerDut_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 32: Test Harness Client reads ActiveBatChargeFaults from Server DUT\n"); - if (ShouldSkip("PS.S.A001e")) { - NextTest(); - return; - } - err = TestStep32TestHarnessClientReadsActiveBatChargeFaultsFromServerDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 33: Test Harness Client reads EndpointList from Server DUT\n"); - if (ShouldSkip("PS.S.A001f")) { - NextTest(); - return; - } - err = TestStep33TestHarnessClientReadsEndpointListFromServerDut_32(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 33; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2TestHarnessClientReadsStatusFromServerDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Test Harness Client reads Status from server DUT: Error: %@", err); - } else { - NSLog(@"Step 2: Test Harness Client reads Status from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("status", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("status", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("status", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3TestHarnessClientReadsOrderFromServerDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOrderWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Test Harness Client reads Order from server DUT: Error: %@", err); - } else { - NSLog(@"Step 3: Test Harness Client reads Order from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("order", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("order", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("order", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4TestHarnessClientReadsOrderFromServerDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDescriptionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Test Harness Client reads Order from server DUT: Error: %@", err); - } else { - NSLog(@"Step 4: Test Harness Client reads Order from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("description", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("description", value, 60)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5TestHarnessClientReadsWiredAssessedInputVoltageFromServerDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredAssessedInputVoltageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: Test Harness Client reads WiredAssessedInputVoltage from server DUT: Error: %@", err); - } else { - NSLog(@"Step 5: Test Harness Client reads WiredAssessedInputVoltage from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("wiredAssessedInputVoltage", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("wiredAssessedInputVoltage", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("wiredAssessedInputVoltage", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6TestHarnessClientReadsWiredAssessedInputFrequencyfromServerDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredAssessedInputFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Test Harness Client reads WiredAssessedInputFrequencyfrom server DUT: Error: %@", err); - } else { - NSLog(@"Step 6: Test Harness Client reads WiredAssessedInputFrequencyfrom server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("wiredAssessedInputFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("wiredAssessedInputFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("wiredAssessedInputFrequency", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7TestHarnessClientReadsWiredCurrentTypeFromServerDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredCurrentTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Test Harness Client reads WiredCurrentType from server DUT: Error: %@", err); - } else { - NSLog(@"Step 7: Test Harness Client reads WiredCurrentType from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("wiredCurrentType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("wiredCurrentType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("wiredCurrentType", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8TestHarnessClientReadsWiredAssessedCurrentFromServerDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredAssessedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: Test Harness Client reads WiredAssessedCurrent from server DUT: Error: %@", err); - } else { - NSLog(@"Step 8: Test Harness Client reads WiredAssessedCurrent from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("wiredAssessedCurrent", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("wiredAssessedCurrent", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("wiredAssessedCurrent", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9TestHarnessClientReadsWiredNominalVoltageFromServerDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredNominalVoltageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: Test Harness Client reads WiredNominalVoltage from server DUT: Error: %@", err); - } else { - NSLog(@"Step 9: Test Harness Client reads WiredNominalVoltage from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("wiredNominalVoltage", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("wiredNominalVoltage", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("wiredNominalVoltage", [value unsignedIntValue], 4294967295UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10TestHarnessClientReadsWiredMaximumCurrentFromServerDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredMaximumCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: Test Harness Client reads WiredMaximumCurrent from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 10: Test Harness Client reads WiredMaximumCurrent from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("wiredMaximumCurrent", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("wiredMaximumCurrent", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("wiredMaximumCurrent", [value unsignedIntValue], 4294967295UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11TestHarnessClientReadsWiredPresentFromServerDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredPresentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: Test Harness Client reads WiredPresent from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 11: Test Harness Client reads WiredPresent from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("wiredPresent", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12TestHarnessClientReadsActiveWiredFaultsFromServerDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeActiveWiredFaultsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: Test Harness Client reads ActiveWiredFaults from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 12: Test Harness Client reads ActiveWiredFaults from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("activeWiredFaults", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("activeWiredFaults", value, 8)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13TestHarnessClientReadsBatVoltageFromServerDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatVoltageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: Test Harness Client reads BatVoltage from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 13: Test Harness Client reads BatVoltage from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batVoltage", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batVoltage", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batVoltage", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14TestHarnessClientReadsBatPercentRemainingFromServerDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatPercentRemainingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: Test Harness Client reads BatPercentRemaining from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 14: Test Harness Client reads BatPercentRemaining from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batPercentRemaining", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("batPercentRemaining", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batPercentRemaining", [value unsignedCharValue], 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15TestHarnessClientReadsBatTimeRemainingFromServerDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatTimeRemainingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: Test Harness Client reads BatTimeRemaining from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 15: Test Harness Client reads BatTimeRemaining from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batTimeRemaining", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batTimeRemaining", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batTimeRemaining", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16TestHarnessClientReadsBatChargeLevelFromServerDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatChargeLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: Test Harness Client reads BatChargeLevel from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 16: Test Harness Client reads BatChargeLevel from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batChargeLevel", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("batChargeLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batChargeLevel", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17TestHarnessClientReadsBatReplacementNeededFromServerDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatReplacementNeededWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: Test Harness Client reads BatReplacementNeeded from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 17: Test Harness Client reads BatReplacementNeeded from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batReplacementNeeded", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18TestHarnessClientReadsBatReplaceabilityFromServerDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatReplaceabilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: Test Harness Client reads BatReplaceability from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 18: Test Harness Client reads BatReplaceability from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batReplaceability", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("batReplaceability", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batReplaceability", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19TestHarnessClientReadsBatPresentFromServerDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatPresentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: Test Harness Client reads BatPresent from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 19: Test Harness Client reads BatPresent from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batPresent", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20TestHarnessClientReadsActiveBatFaultsFromServerDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeActiveBatFaultsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: Test Harness Client readsActiveBatFaults from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 20: Test Harness Client readsActiveBatFaults from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("activeBatFaults", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("activeBatFaults", value, 8)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21TestHarnessClientReadsBatReplacementDescriptionFromServerDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatReplacementDescriptionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21: Test Harness Client reads BatReplacementDescription from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 21: Test Harness Client reads BatReplacementDescription from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batReplacementDescription", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("batReplacementDescription", value, 60)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep22TestHarnessClientReadsBatCommonDesignationFromServerDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatCommonDesignationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: Test Harness Client reads BatCommonDesignation from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 22: Test Harness Client reads BatCommonDesignation from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batCommonDesignation", "enum16", "enum16")); - VerifyOrReturn(CheckConstraintMinValue("batCommonDesignation", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batCommonDesignation", [value unsignedShortValue], 80U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23TestHarnessClientReadsBatANSIDesignationFromServerDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatANSIDesignationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 23: Test Harness Client reads BatANSIDesignation from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 23: Test Harness Client reads BatANSIDesignation from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batANSIDesignation", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("batANSIDesignation", value, 20)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24TestHarnessClientReadsBatIECDesignationFromServerDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatIECDesignationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24: Test Harness Client reads BatIECDesignation from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 24: Test Harness Client reads BatIECDesignation from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batIECDesignation", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("batIECDesignation", value, 20)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25TestHarnessClientReadsBatApprovedChemistryFromServerDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatApprovedChemistryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 25: Test Harness Client reads BatApprovedChemistry from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 25: Test Harness Client reads BatApprovedChemistry from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batApprovedChemistry", "enum16", "enum16")); - VerifyOrReturn(CheckConstraintMinValue("batApprovedChemistry", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batApprovedChemistry", [value unsignedShortValue], 32U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep26TestHarnessClientReadsBatCapacityFromServerDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatCapacityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 26: Test Harness Client reads BatCapacity from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 26: Test Harness Client reads BatCapacity from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batCapacity", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batCapacity", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batCapacity", [value unsignedIntValue], 4294967295UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep27TestHarnessClientReadsBatQuantityFromServerDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatQuantityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 27: Test Harness Client reads BatQuantity from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 27: Test Harness Client reads BatQuantity from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batQuantity", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("batQuantity", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batQuantity", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep28TestHarnessClientReadsBatChargeStateFromServerDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatChargeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 28: Test Harness Client reads BatChargeState from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 28: Test Harness Client reads BatChargeState from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batChargeState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("batChargeState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batChargeState", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep29TestHarnessClientReadsBatTimeToFullChargeFromServerDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatTimeToFullChargeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 29: Test Harness Client reads BatTimeToFullCharge from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 29: Test Harness Client reads BatTimeToFullCharge from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batTimeToFullCharge", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batTimeToFullCharge", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batTimeToFullCharge", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep30TestHarnessClientReadsBatFunctionalWhileChargingFromServerDut_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatFunctionalWhileChargingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 30: Test Harness Client reads BatFunctionalWhileCharging from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 30: Test Harness Client reads BatFunctionalWhileCharging from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batFunctionalWhileCharging", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep31TestHarnessClientReadsBatChargingCurrentFromServerDut_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatChargingCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 31: Test Harness Client reads BatChargingCurrent from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 31: Test Harness Client reads BatChargingCurrent from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batChargingCurrent", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batChargingCurrent", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batChargingCurrent", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep32TestHarnessClientReadsActiveBatChargeFaultsFromServerDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeActiveBatChargeFaultsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 32: Test Harness Client reads ActiveBatChargeFaults from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 32: Test Harness Client reads ActiveBatChargeFaults from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("activeBatChargeFaults", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("activeBatChargeFaults", value, 16)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep33TestHarnessClientReadsEndpointListFromServerDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEndpointListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 33: Test Harness Client reads EndpointList from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 33: Test Harness Client reads EndpointList from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("endpointList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PRS_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PRS_1_1() - : TestCommandBridge("Test_TC_PRS_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PRS_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PRS_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PRS_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !PRS.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Given PRS.S.F00(EXT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PRS.S.F00")) { - NextTest(); - return; - } - err = TestStep3GivenPrssf00extEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(ScaledValue) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0010")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeScaledValueInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the optional attribute(MinScaledValue) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0011")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeMinScaledValueInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4d: TH reads the optional attribute(MaxScaledValue) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0012")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeMaxScaledValueInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4e: TH reads the optional attribute(Scale) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0014")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeScaleInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4f: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0003")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalAttributeToleranceInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4g: TH reads the optional attribute(ScaledTolerance) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0013")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalAttributeScaledToleranceInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3GivenPrssf00extEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Given PRS.S.F00(EXT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3: Given PRS.S.F00(EXT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeScaledValueInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(ScaledValue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(ScaledValue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeMinScaledValueInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional attribute(MinScaledValue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional attribute(MinScaledValue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeMaxScaledValueInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional attribute(MaxScaledValue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional attribute(MaxScaledValue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeScaleInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional attribute(Scale) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional attribute(Scale) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalAttributeToleranceInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalAttributeScaledToleranceInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional attribute(ScaledTolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional attribute(ScaledTolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PRS_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PRS_2_1() - : TestCommandBridge("Test_TC_PRS_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PRS_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PRS_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PRS_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("PRS.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("PRS.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("PRS.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the Tolerance attribute.\n"); - if (ShouldSkip("PRS.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheToleranceAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the MinScaledValue attribute.\n"); - if (ShouldSkip("PRS.S.A0011")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheMinScaledValueAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the MaxScaledValue attribute.\n"); - if (ShouldSkip("PRS.S.A0012")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheMaxScaledValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the ScaledValue attribute.\n"); - if (ShouldSkip("PRS.S.A0010")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheScaledValueAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the ScaledTolerance attribute.\n"); - if (ShouldSkip("PRS.S.A0013")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheScaledToleranceAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the Scale attribute.\n"); - if (ShouldSkip("PRS.S.A0014")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheScaleAttribute_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value shortValue], -32767)); - VerifyOrReturn(CheckConstraintMaxValue("minMeasuredValue", [value shortValue], 32766)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value shortValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("maxMeasuredValue", [value shortValue], 32767)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value shortValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value shortValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheToleranceAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the Tolerance attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the Tolerance attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("tolerance", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("tolerance", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("tolerance", [value unsignedShortValue], 2048U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MinScaledValueValue; - - CHIP_ERROR TestStep6ThReadsFromTheDutTheMinScaledValueAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinScaledValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the MinScaledValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the MinScaledValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minScaledValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minScaledValue", [value shortValue], -32767)); - VerifyOrReturn(CheckConstraintMaxValue("minScaledValue", [value shortValue], 32766)); - } - { - MinScaledValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxScaledValueValue; - - CHIP_ERROR TestStep7ThReadsFromTheDutTheMaxScaledValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxScaledValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the MaxScaledValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the MaxScaledValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxScaledValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxScaledValue", [value shortValue], MinScaledValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("maxScaledValue", [value shortValue], 32767)); - } - { - MaxScaledValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheScaledValueAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScaledValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the ScaledValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the ScaledValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("scaledValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("scaledValue", [value shortValue], MinScaledValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("scaledValue", [value shortValue], MaxScaledValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheScaledToleranceAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScaledToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the ScaledTolerance attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the ScaledTolerance attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("scaledTolerance", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("scaledTolerance", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("scaledTolerance", [value unsignedShortValue], 2048U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheScaleAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScaleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the Scale attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the Scale attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("scale", "int8s", "int8s")); - VerifyOrReturn(CheckConstraintMinValue("scale", [value charValue], -127)); - VerifyOrReturn(CheckConstraintMaxValue("scale", [value charValue], 127)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PRS_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PRS_2_2() - : TestCommandBridge("Test_TC_PRS_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PRS_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PRS_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PRS_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MeasuredValue attribute\n"); - if (ShouldSkip("PRS.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Operate on device to change the pressure significantly\n"); - if (ShouldSkip("PICS_USER_PROMPT && PRS.M.PressureChange")) { - NextTest(); - return; - } - err = TestStep3OperateOnDeviceToChangeThePressureSignificantly_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Wait 2s\n"); - err = TestWait2s_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: After a few seconds, TH reads from the DUT the MeasuredValue attribute\n"); - if (ShouldSkip("PRS.S.A0000 && PRS.M.PressureChange")) { - NextTest(); - return; - } - err = TestStep4AfterAFewSecondsThReadsFromTheDutTheMeasuredValueAttribute_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable ValueBeforeChange; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MeasuredValue attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MeasuredValue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ValueBeforeChange = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3OperateOnDeviceToChangeThePressureSignificantly_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait2s_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4AfterAFewSecondsThReadsFromTheDutTheMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: After a few seconds, TH reads from the DUT the MeasuredValue attribute: Error: %@", err); - } else { - NSLog(@"Step 4: After a few seconds, TH reads from the DUT the MeasuredValue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("measuredValue", value, ValueBeforeChange)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_1_1() - : TestCommandBridge("Test_TC_PCC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !PCC.S.F00 && !PCC.S.F01 && !PCC.S.F02 && !PCC.S.F03 && !PCC.S.F04 && !PCC.S.F05 && !PCC.S.F06 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PCC.S.F00(PRSCONST) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPccsf00prsconstEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PCC.S.F01(PRSCOMP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenPccsf01prscompEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PCC.S.F02(FLW) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenPccsf02flwEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PCC.S.F03(SPD) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenPccsf03spdEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PCC.S.F04(TEMP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenPccsf04tempEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PCC.S.F05(AUTO) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F05")) { - NextTest(); - return; - } - err = TestStep3gGivenPccsf05autoEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PCC.S.F06(LOCAL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F06")) { - NextTest(); - return; - } - err = TestStep3hGivenPccsf06localEnsureFeaturemapHasTheCorrectBitSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: TH reads optional attribute(MinConstPressure) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeMinConstPressureAttributeInAttributeListFromTheDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c TH reads optional attribute(MaxConstPressure) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0004")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributeMaxConstPressureAttributeInAttributeListFromTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4d: TH reads optional attribute(MinCompPressure) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0005")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeMinCompPressureAttributeInAttributeListFromTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4e: TH reads optional attribute(MaxCompPressure) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0006")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeMaxCompPressureAttributeInAttributeListFromTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4f: TH reads optional attribute(MinConstSpeed) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0007")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributeMinConstSpeedAttributeInAttributeListFromTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4g: TH reads optional attribute(MaxConstSpeed) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributeMaxConstSpeedAttributeInAttributeListFromTheDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4h: TH reads optional attribute(MinConstFlow) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0009")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributeMinConstFlowAttributeInAttributeListFromTheDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4i: TH reads optional attribute(MaxConstFlow) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A000a")) { - NextTest(); - return; - } - err = TestStep4iThReadsOptionalAttributeMaxConstFlowAttributeInAttributeListFromTheDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4j: TH reads optional attribute(MinConstTemp) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A000b")) { - NextTest(); - return; - } - err = TestStep4jThReadsOptionalAttributeMinConstTempAttributeInAttributeListFromTheDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4k: TH reads optional attribute(MaxConstTemp) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A000c")) { - NextTest(); - return; - } - err = TestStep4kThReadsOptionalAttributeMaxConstTempAttributeInAttributeListFromTheDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4l: TH reads optional attribute(PumpStatus) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0010")) { - NextTest(); - return; - } - err = TestStep4lThReadsOptionalAttributePumpStatusAttributeInAttributeListFromTheDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4m: TH reads optional attribute(Speed) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0014")) { - NextTest(); - return; - } - err = TestStep4mThReadsOptionalAttributeSpeedAttributeInAttributeListFromTheDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4n: TH reads optional attribute(LifetimeRunningHours) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep4nThReadsOptionalAttributeLifetimeRunningHoursAttributeInAttributeListFromTheDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4o: TH reads optional attribute(Power) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0016")) { - NextTest(); - return; - } - err = TestStep4oThReadsOptionalAttributePowerAttributeInAttributeListFromTheDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4p: TH reads optional attribute(LifetimeEnergyConsumed) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep4pThReadsOptionalAttributeLifetimeEnergyConsumedAttributeInAttributeListFromTheDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4q: TH reads optional attribute(ControlMode) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep4qThReadsOptionalAttributeControlModeAttributeInAttributeListFromTheDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !PCC.S.E00 && !PCC.S.E01 && !PCC.S.E02 && !PCC.S.E03 && !PCC.S.E04 && !PCC.S.E05 && !PCC.S.E06 && !PCC.S.E07 && !PCC.S.E08 && !PCC.S.E09 && !PCC.S.E0a && !PCC.S.E0b && !PCC.S.E0c && !PCC.S.E0d && !PCC.S.E0e && !PCC.S.E0f && !PCC.S.E10 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 5b: TH reads from the DUT the EventList optional (SupplyVoltageLow)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E00")) { - NextTest(); - return; - } - NextTest(); - return; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 5c: TH reads from the DUT the EventList optional (SupplyVoltageHigh)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 5d: TH reads from the DUT the EventList optional (PowerMissingPhase)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E02")) { - NextTest(); - return; - } - NextTest(); - return; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 5e: TH reads from the DUT the EventList optional (SystemPressureLow)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E03")) { - NextTest(); - return; - } - NextTest(); - return; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 5f: TH reads from the DUT the EventList optional (SystemPressureHigh)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E04")) { - NextTest(); - return; - } - NextTest(); - return; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 5g: TH reads from the DUT the EventList optional (DryRunning)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E05")) { - NextTest(); - return; - } - NextTest(); - return; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 5h: TH reads from the DUT the EventList optional (MotorTemperatureHigh)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E06")) { - NextTest(); - return; - } - NextTest(); - return; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 5i: TH reads from the DUT the EventList optional (PumpMotorFatalFailure)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E07")) { - NextTest(); - return; - } - NextTest(); - return; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 5j: TH reads from the DUT the EventList optional (ElectronicTemperatureHigh)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E08")) { - NextTest(); - return; - } - NextTest(); - return; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 5k: TH reads from the DUT the EventList optional (PumpBlocked)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E09")) { - NextTest(); - return; - } - NextTest(); - return; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 5l: TH reads from the DUT the EventList optional (SensorFailure)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0a")) { - NextTest(); - return; - } - NextTest(); - return; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 5m: TH reads from the DUT the EventList optional (ElectronicNonFatalFailure)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0b")) { - NextTest(); - return; - } - NextTest(); - return; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 5n: TH reads from the DUT the EventList optional (ElectronicFatalFailure)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0c")) { - NextTest(); - return; - } - NextTest(); - return; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 5o: TH reads from the DUT the EventList optional (GeneralFault)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0d")) { - NextTest(); - return; - } - NextTest(); - return; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 5p: TH reads from the DUT the EventList optional (Leakage)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0e")) { - NextTest(); - return; - } - NextTest(); - return; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 5q: TH reads from the DUT the EventList optional (AirDetection)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0f")) { - NextTest(); - return; - } - NextTest(); - return; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 5r: TH reads from the DUT the EventList optional (TurbineOperation)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E10")) { - NextTest(); - return; - } - NextTest(); - return; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_47(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 48; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPccsf00prsconstEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PCC.S.F00(PRSCONST) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PCC.S.F00(PRSCONST) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPccsf01prscompEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PCC.S.F01(PRSCOMP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PCC.S.F01(PRSCOMP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPccsf02flwEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PCC.S.F02(FLW) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PCC.S.F02(FLW) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenPccsf03spdEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given PCC.S.F03(SPD) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given PCC.S.F03(SPD) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenPccsf04tempEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given PCC.S.F04(TEMP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given PCC.S.F04(TEMP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenPccsf05autoEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given PCC.S.F05(AUTO) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given PCC.S.F05(AUTO) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenPccsf06localEnsureFeaturemapHasTheCorrectBitSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given PCC.S.F06(LOCAL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given PCC.S.F06(LOCAL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeMinConstPressureAttributeInAttributeListFromTheDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(MinConstPressure) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(MinConstPressure) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributeMaxConstPressureAttributeInAttributeListFromTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c TH reads optional attribute(MaxConstPressure) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c TH reads optional attribute(MaxConstPressure) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeMinCompPressureAttributeInAttributeListFromTheDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(MinCompPressure) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(MinCompPressure) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeMaxCompPressureAttributeInAttributeListFromTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(MaxCompPressure) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(MaxCompPressure) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributeMinConstSpeedAttributeInAttributeListFromTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(MinConstSpeed) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(MinConstSpeed) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributeMaxConstSpeedAttributeInAttributeListFromTheDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(MaxConstSpeed) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(MaxConstSpeed) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributeMinConstFlowAttributeInAttributeListFromTheDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(MinConstFlow) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(MinConstFlow) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsOptionalAttributeMaxConstFlowAttributeInAttributeListFromTheDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads optional attribute(MaxConstFlow) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads optional attribute(MaxConstFlow) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsOptionalAttributeMinConstTempAttributeInAttributeListFromTheDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads optional attribute(MinConstTemp) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads optional attribute(MinConstTemp) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsOptionalAttributeMaxConstTempAttributeInAttributeListFromTheDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH reads optional attribute(MaxConstTemp) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4k: TH reads optional attribute(MaxConstTemp) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsOptionalAttributePumpStatusAttributeInAttributeListFromTheDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: TH reads optional attribute(PumpStatus) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4l: TH reads optional attribute(PumpStatus) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsOptionalAttributeSpeedAttributeInAttributeListFromTheDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: TH reads optional attribute(Speed) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4m: TH reads optional attribute(Speed) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsOptionalAttributeLifetimeRunningHoursAttributeInAttributeListFromTheDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: TH reads optional attribute(LifetimeRunningHours) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4n: TH reads optional attribute(LifetimeRunningHours) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsOptionalAttributePowerAttributeInAttributeListFromTheDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: TH reads optional attribute(Power) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4o: TH reads optional attribute(Power) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsOptionalAttributeLifetimeEnergyConsumedAttributeInAttributeListFromTheDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4p: TH reads optional attribute(LifetimeEnergyConsumed) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4p: TH reads optional attribute(LifetimeEnergyConsumed) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qThReadsOptionalAttributeControlModeAttributeInAttributeListFromTheDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4q: TH reads optional attribute(ControlMode) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4q: TH reads optional attribute(ControlMode) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_2_1() - : TestCommandBridge("Test_TC_PCC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MaxPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMaxPressureAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxSpeed attribute.\n"); - if (ShouldSkip("PCC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxSpeedAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MaxFlow attribute.\n"); - if (ShouldSkip("PCC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMaxFlowAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the MinConstPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheMinConstPressureAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the MaxConstPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheMaxConstPressureAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the MinCompPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheMinCompPressureAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the MaxCompPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheMaxCompPressureAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MinConstSpeed attribute.\n"); - if (ShouldSkip("PCC.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMinConstSpeedAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MaxConstSpeed attribute.\n"); - if (ShouldSkip("PCC.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMaxConstSpeedAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the MinConstFlow attribute.\n"); - if (ShouldSkip("PCC.S.A0009")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheMinConstFlowAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the MaxConstFlow attribute.\n"); - if (ShouldSkip("PCC.S.A000a")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheMaxConstFlowAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the MinConstTemp attribute.\n"); - if (ShouldSkip("PCC.S.A000b")) { - NextTest(); - return; - } - err = TestStep13ThReadsFromTheDutTheMinConstTempAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads from the DUT the MaxConstTemp attribute.\n"); - if (ShouldSkip("PCC.S.A000c")) { - NextTest(); - return; - } - err = TestStep14ThReadsFromTheDutTheMaxConstTempAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: TH reads from the DUT the PumpStatus attribute.\n"); - if (ShouldSkip("PCC.S.A0010")) { - NextTest(); - return; - } - err = TestStep15ThReadsFromTheDutThePumpStatusAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: TH reads from the DUT the EffectiveOperationMode attribute.\n"); - if (ShouldSkip("PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep16ThReadsFromTheDutTheEffectiveOperationModeAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep17ThReadsFromTheDutTheEffectiveControlModeAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: TH reads from the DUT the Capacity attribute.\n"); - if (ShouldSkip("PCC.S.A0013")) { - NextTest(); - return; - } - err = TestStep18ThReadsFromTheDutTheCapacityAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 19: TH reads from the DUT the Speed attribute.\n"); - if (ShouldSkip("PCC.S.A0014")) { - NextTest(); - return; - } - err = TestStep19ThReadsFromTheDutTheSpeedAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 20: TH reads from the DUT the LifetimeRunningHours attribute.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep20ThReadsFromTheDutTheLifetimeRunningHoursAttribute_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 21: TH reads from the DUT the Power attribute.\n"); - if (ShouldSkip("PCC.S.A0016")) { - NextTest(); - return; - } - err = TestStep21ThReadsFromTheDutThePowerAttribute_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 22: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep22ThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 23: TH reads from the DUT the OperationMode attribute.\n"); - if (ShouldSkip("PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep23ThReadsFromTheDutTheOperationModeAttribute_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 24: TH reads from the DUT the ControlMode attribute.\n"); - if (ShouldSkip("PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep24ThReadsFromTheDutTheControlModeAttribute_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMaxPressureAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MaxPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MaxPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("maxPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxSpeedAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxSpeed attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxSpeed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxSpeed", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxSpeed", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxSpeed", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMaxFlowAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxFlowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MaxFlow attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MaxFlow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxFlow", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxFlow", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxFlow", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheMinConstPressureAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinConstPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the MinConstPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the MinConstPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minConstPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minConstPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("minConstPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheMaxConstPressureAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxConstPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the MaxConstPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the MaxConstPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxConstPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxConstPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("maxConstPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheMinCompPressureAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinCompPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the MinCompPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the MinCompPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minCompPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minCompPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("minCompPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheMaxCompPressureAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxCompPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the MaxCompPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the MaxCompPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxCompPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxCompPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("maxCompPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMinConstSpeedAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinConstSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MinConstSpeed attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MinConstSpeed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minConstSpeed", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minConstSpeed", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minConstSpeed", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMaxConstSpeedAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxConstSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MaxConstSpeed attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MaxConstSpeed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxConstSpeed", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxConstSpeed", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxConstSpeed", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheMinConstFlowAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinConstFlowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the MinConstFlow attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the MinConstFlow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minConstFlow", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minConstFlow", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minConstFlow", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheMaxConstFlowAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxConstFlowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the MaxConstFlow attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the MaxConstFlow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxConstFlow", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxConstFlow", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxConstFlow", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsFromTheDutTheMinConstTempAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinConstTempWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads from the DUT the MinConstTemp attribute.: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads from the DUT the MinConstTemp attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minConstTemp", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minConstTemp", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("minConstTemp", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsFromTheDutTheMaxConstTempAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxConstTempWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads from the DUT the MaxConstTemp attribute.: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads from the DUT the MaxConstTemp attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxConstTemp", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxConstTemp", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("maxConstTemp", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15ThReadsFromTheDutThePumpStatusAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePumpStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: TH reads from the DUT the PumpStatus attribute.: Error: %@", err); - } else { - NSLog(@"Step 15: TH reads from the DUT the PumpStatus attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("pumpStatus", "bitmap16", "bitmap16")); - VerifyOrReturn(CheckConstraintMinValue("pumpStatus", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("pumpStatus", [value unsignedShortValue], 8U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16ThReadsFromTheDutTheEffectiveOperationModeAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH reads from the DUT the EffectiveOperationMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 16: TH reads from the DUT the EffectiveOperationMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("effectiveOperationMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("effectiveOperationMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("effectiveOperationMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17ThReadsFromTheDutTheEffectiveControlModeAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 17: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("effectiveControlMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("effectiveControlMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("effectiveControlMode", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18ThReadsFromTheDutTheCapacityAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCapacityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: TH reads from the DUT the Capacity attribute.: Error: %@", err); - } else { - NSLog(@"Step 18: TH reads from the DUT the Capacity attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("capacity", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("capacity", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("capacity", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19ThReadsFromTheDutTheSpeedAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH reads from the DUT the Speed attribute.: Error: %@", err); - } else { - NSLog(@"Step 19: TH reads from the DUT the Speed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("speed", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("speed", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("speed", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20ThReadsFromTheDutTheLifetimeRunningHoursAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); - } else { - NSLog(@"Step 20: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lifetimeRunningHours", "int24u", "int24u")); - VerifyOrReturn(CheckConstraintMinValue("lifetimeRunningHours", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("lifetimeRunningHours", [value unsignedIntValue], 16777215UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21ThReadsFromTheDutThePowerAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePowerWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21: TH reads from the DUT the Power attribute.: Error: %@", err); - } else { - NSLog(@"Step 21: TH reads from the DUT the Power attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("power", "int24u", "int24u")); - VerifyOrReturn(CheckConstraintMinValue("power", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("power", [value unsignedIntValue], 16777215UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep22ThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); - } else { - NSLog(@"Step 22: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lifetimeEnergyConsumed", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("lifetimeEnergyConsumed", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("lifetimeEnergyConsumed", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23ThReadsFromTheDutTheOperationModeAttribute_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 23: TH reads from the DUT the OperationMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 23: TH reads from the DUT the OperationMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("operationMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("operationMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24ThReadsFromTheDutTheControlModeAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24: TH reads from the DUT the ControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 24: TH reads from the DUT the ControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("controlMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("controlMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("controlMode", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_2_2() - : TestCommandBridge("Test_TC_PCC_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT\n"); - if (ShouldSkip("PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH write 1 (Minimum) to the OperationMode attribute to DUT\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep3aThWrite1MinimumToTheOperationModeAttributeToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheEffectiveOperationModeAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH write 2 (Maximum) to the OperationMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep4aThWrite2MaximumToTheOperationModeAttributeToDutOneAtATime_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheEffectiveOperationModeAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5a: TH write 3 (Local) to the OperationMode attribute to DUT\n"); - if (ShouldSkip("PCC.S.F06 && PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep5aThWrite3LocalToTheOperationModeAttributeToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.F06 && PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep5bThReadsFromTheDutTheEffectiveOperationModeAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWrite1MinimumToTheOperationModeAttributeToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH write 1 (Minimum) to the OperationMode attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH write 1 (Minimum) to the OperationMode attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheEffectiveOperationModeAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWrite2MaximumToTheOperationModeAttributeToDutOneAtATime_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH write 2 (Maximum) to the OperationMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH write 2 (Maximum) to the OperationMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheEffectiveOperationModeAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrite3LocalToTheOperationModeAttributeToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH write 3 (Local) to the OperationMode attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH write 3 (Local) to the OperationMode attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsFromTheDutTheEffectiveOperationModeAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_2_3() - : TestCommandBridge("Test_TC_PCC_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT.\n"); - if (ShouldSkip("PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH write 0 (ConstantSpeed) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep3aThWrite0ConstantSpeedToTheControlModeAttributeToDutOneAtATime_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheEffectiveControlModeAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH write 1 (ConstantPressure) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F00 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep4aThWrite1ConstantPressureToTheControlModeAttributeToDutOneAtATime_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F00 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheEffectiveControlModeAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5a: TH write 2 (ProportionalPressure) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F01 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep5aThWrite2ProportionalPressureToTheControlModeAttributeToDutOneAtATime_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F01 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep5bThReadsFromTheDutTheEffectiveControlModeAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH write 3 (ConstantFlow) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F02 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep6aThWrite3ConstantFlowToTheControlModeAttributeToDutOneAtATime_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6b: TH reads from the DUT the _EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F02 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep6bThReadsFromTheDutTheEffectiveControlModeAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7a: TH write 5 (ConstantTemperature) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F04 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep7aThWrite5ConstantTemperatureToTheControlModeAttributeToDutOneAtATime_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F04 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep7bThReadsFromTheDutTheEffectiveControlModeAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 8a: TH write 7 (Automatic) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F05 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep8aThWrite7AutomaticToTheControlModeAttributeToDutOneAtATime_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 8b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F05 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep8bThReadsFromTheDutTheEffectiveControlModeAttribute_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT.: Error: %@", err); - } else { - NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWrite0ConstantSpeedToTheControlModeAttributeToDutOneAtATime_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH write 0 (ConstantSpeed) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH write 0 (ConstantSpeed) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheEffectiveControlModeAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWrite1ConstantPressureToTheControlModeAttributeToDutOneAtATime_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH write 1 (ConstantPressure) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH write 1 (ConstantPressure) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheEffectiveControlModeAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrite2ProportionalPressureToTheControlModeAttributeToDutOneAtATime_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH write 2 (ProportionalPressure) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 5a: TH write 2 (ProportionalPressure) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsFromTheDutTheEffectiveControlModeAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThWrite3ConstantFlowToTheControlModeAttributeToDutOneAtATime_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH write 3 (ConstantFlow) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH write 3 (ConstantFlow) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFromTheDutTheEffectiveControlModeAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads from the DUT the _EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads from the DUT the _EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThWrite5ConstantTemperatureToTheControlModeAttributeToDutOneAtATime_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH write 5 (ConstantTemperature) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 7a: TH write 5 (ConstantTemperature) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bThReadsFromTheDutTheEffectiveControlModeAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 7b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8aThWrite7AutomaticToTheControlModeAttributeToDutOneAtATime_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:7U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8a: TH write 7 (Automatic) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 8a: TH write 7 (Automatic) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8bThReadsFromTheDutTheEffectiveControlModeAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 8b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_2_4() - : TestCommandBridge("Test_TC_PCC_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH Write 1 to the LifetimeRunningHours attribute to DUT\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep2aThWrite1ToTheLifetimeRunningHoursAttributeToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads from the DUT the LifetimeRunningHours attribute.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep2bThReadsFromTheDutTheLifetimeRunningHoursAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH write 2 to the LifetimeRunningHours attribute of DUT.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep3aThWrite2ToTheLifetimeRunningHoursAttributeOfDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads from the DUT the LifetimeRunningHours attribute.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheLifetimeRunningHoursAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH Write 3 to the LifetimeRunningHours attribute to DUT\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep4aThWrite3ToTheLifetimeRunningHoursAttributeToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the LifetimeRunningHours attribute.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheLifetimeRunningHoursAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5a: TH write 1 to the LifetimeEnergyConsumed attribute of DUT.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep5aThWrite1ToTheLifetimeEnergyConsumedAttributeOfDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5b: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep5bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH write 2 to the LifetimeEnergyConsumed attribute of DUT.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep6aThWrite2ToTheLifetimeEnergyConsumedAttributeOfDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6b: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep6bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7a: TH write 3 to the LifetimeEnergyConsumed attribute of DUT.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep7aThWrite3ToTheLifetimeEnergyConsumedAttributeOfDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7b: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep7bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_12(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThWrite1ToTheLifetimeRunningHoursAttributeToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeRunningHoursArgument; - lifetimeRunningHoursArgument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeLifetimeRunningHoursWithValue:lifetimeRunningHoursArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH Write 1 to the LifetimeRunningHours attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH Write 1 to the LifetimeRunningHours attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsFromTheDutTheLifetimeRunningHoursAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeRunningHours", actualValue)); - VerifyOrReturn(CheckValue("LifetimeRunningHours", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWrite2ToTheLifetimeRunningHoursAttributeOfDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeRunningHoursArgument; - lifetimeRunningHoursArgument = - [NSNumber numberWithUnsignedInt:2UL]; - [cluster writeAttributeLifetimeRunningHoursWithValue:lifetimeRunningHoursArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH write 2 to the LifetimeRunningHours attribute of DUT.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH write 2 to the LifetimeRunningHours attribute of DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheLifetimeRunningHoursAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeRunningHours", actualValue)); - VerifyOrReturn(CheckValue("LifetimeRunningHours", actualValue, 2UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWrite3ToTheLifetimeRunningHoursAttributeToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeRunningHoursArgument; - lifetimeRunningHoursArgument = - [NSNumber numberWithUnsignedInt:3UL]; - [cluster writeAttributeLifetimeRunningHoursWithValue:lifetimeRunningHoursArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH Write 3 to the LifetimeRunningHours attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH Write 3 to the LifetimeRunningHours attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheLifetimeRunningHoursAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeRunningHours", actualValue)); - VerifyOrReturn(CheckValue("LifetimeRunningHours", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrite1ToTheLifetimeEnergyConsumedAttributeOfDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeEnergyConsumedArgument; - lifetimeEnergyConsumedArgument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeLifetimeEnergyConsumedWithValue:lifetimeEnergyConsumedArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH write 1 to the LifetimeEnergyConsumed attribute of DUT.: Error: %@", err); - } else { - NSLog(@"Step 5a: TH write 1 to the LifetimeEnergyConsumed attribute of DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeEnergyConsumed", actualValue)); - VerifyOrReturn(CheckValue("LifetimeEnergyConsumed", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThWrite2ToTheLifetimeEnergyConsumedAttributeOfDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeEnergyConsumedArgument; - lifetimeEnergyConsumedArgument = - [NSNumber numberWithUnsignedInt:2UL]; - [cluster writeAttributeLifetimeEnergyConsumedWithValue:lifetimeEnergyConsumedArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH write 2 to the LifetimeEnergyConsumed attribute of DUT.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH write 2 to the LifetimeEnergyConsumed attribute of DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeEnergyConsumed", actualValue)); - VerifyOrReturn(CheckValue("LifetimeEnergyConsumed", actualValue, 2UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThWrite3ToTheLifetimeEnergyConsumedAttributeOfDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeEnergyConsumedArgument; - lifetimeEnergyConsumedArgument = - [NSNumber numberWithUnsignedInt:3UL]; - [cluster writeAttributeLifetimeEnergyConsumedWithValue:lifetimeEnergyConsumedArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH write 3 to the LifetimeEnergyConsumed attribute of DUT.: Error: %@", err); - } else { - NSLog(@"Step 7a: TH write 3 to the LifetimeEnergyConsumed attribute of DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); - } else { - NSLog(@"Step 7b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeEnergyConsumed", actualValue)); - VerifyOrReturn(CheckValue("LifetimeEnergyConsumed", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_REFALM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_REFALM_1_1() - : TestCommandBridge("Test_TC_REFALM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_REFALM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_REFALM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_REFALM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_REFALM_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_REFALM_2_1() - : TestCommandBridge("Test_TC_REFALM_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_REFALM_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_REFALM_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_REFALM_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Ensure that the door alarm is not locally suppressed and the door is closed\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep2EnsureThatTheDoorAlarmIsNotLocallySuppressedAndTheDoorIsClosed_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3:TH reads from the DUT the Mask attribute\n"); - if (ShouldSkip("REFALM.S.A0000")) { - NextTest(); - return; - } - err = TestStep3thReadsFromTheDutTheMaskAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4:TH reads from the DUT the State attribute\n"); - if (ShouldSkip("REFALM.S.A0002")) { - NextTest(); - return; - } - err = TestStep4thReadsFromTheDutTheStateAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5:TH reads from the DUT the Supportedask attribute\n"); - if (ShouldSkip("REFALM.S.A0003")) { - NextTest(); - return; - } - err = TestStep5thReadsFromTheDutTheSupportedaskAttribute_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2EnsureThatTheDoorAlarmIsNotLocallySuppressedAndTheDoorIsClosed_1() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3thReadsFromTheDutTheMaskAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3:TH reads from the DUT the Mask attribute: Error: %@", err); - } else { - NSLog(@"Step 3:TH reads from the DUT the Mask attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("mask", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4thReadsFromTheDutTheStateAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4:TH reads from the DUT the State attribute: Error: %@", err); - } else { - NSLog(@"Step 4:TH reads from the DUT the State attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("state", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5thReadsFromTheDutTheSupportedaskAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5:TH reads from the DUT the Supportedask attribute: Error: %@", err); - } else { - NSLog(@"Step 5:TH reads from the DUT the Supportedask attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supported", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RH_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RH_1_1() - : TestCommandBridge("Test_TC_RH_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RH_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RH_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RH_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT.\n"); - err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap attribute from the DUT.\n"); - err = TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("RH.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the AcceptedCommandList attribute from the DUT.\n"); - err = TestStep5ThReadsTheAcceptedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the GeneratedCommandList attribute from the DUT.\n"); - err = TestStep6ThReadsTheGeneratedCommandListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads the EventList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheAcceptedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the AcceptedCommandList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the AcceptedCommandList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheGeneratedCommandListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the GeneratedCommandList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the GeneratedCommandList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RVCCLEANM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RVCCLEANM_1_1() - : TestCommandBridge("Test_TC_RVCCLEANM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RVCCLEANM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RVCCLEANM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RVCCLEANM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode)\n"); - if (ShouldSkip("RVCCLEANM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse)\n"); - if (ShouldSkip("RVCCLEANM.S.C01.Tx")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 1UL)); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RVCRUNM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RVCRUNM_1_1() - : TestCommandBridge("Test_TC_RVCRUNM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RVCRUNM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RVCRUNM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RVCRUNM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode)\n"); - if (ShouldSkip("RVCRUNM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse)\n"); - if (ShouldSkip("RVCRUNM.S.C01.Tx")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 1UL)); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RVCOPSTATE_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RVCOPSTATE_1_1() - : TestCommandBridge("Test_TC_RVCOPSTATE_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RVCOPSTATE_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RVCOPSTATE_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RVCOPSTATE_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT\n"); - if (ShouldSkip("RVCOPSTATE.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5a: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5b: TH reads from the DUT the optional event(OperationCompletion) in EventList.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && RVCOPSTATE.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6a: TH reads the optional command(Pause) in AcceptedCommandList\n"); - if (ShouldSkip("RVCOPSTATE.S.C00.Rsp || RVCOPSTATE.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsTheOptionalCommandPauseInAcceptedCommandList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6b: TH reads the optional command(Stop) in AcceptedCommandList\n"); - if (ShouldSkip("RVCOPSTATE.S.C01.Rsp || RVCOPSTATE.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6c: TH reads the optional command(Start) in AcceptedCommandList\n"); - if (ShouldSkip("RVCOPSTATE.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThReadsTheOptionalCommandStartInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6d: TH reads the optional command(Resume) in AcceptedCommandList\n"); - if (ShouldSkip("RVCOPSTATE.S.C03.Rsp || RVCOPSTATE.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - if (ShouldSkip(" !RVCOPSTATE.S.C00.Rsp && !RVCOPSTATE.S.C01.Rsp && !RVCOPSTATE.S.C02.Rsp && !RVCOPSTATE.S.C03.Rsp ")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - if (ShouldSkip(" RVCOPSTATE.S.C00.Rsp || RVCOPSTATE.S.C01.Rsp || RVCOPSTATE.S.C02.Rsp || RVCOPSTATE.S.C03.Rsp ")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsTheOptionalCommandPauseInAcceptedCommandList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads the optional command(Pause) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads the optional command(Pause) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsTheOptionalCommandStartInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads the optional command(Start) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads the optional command(Start) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_SMOKECO_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_SMOKECO_1_1() - : TestCommandBridge("Test_TC_SMOKECO_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_SMOKECO_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_SMOKECO_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_SMOKECO_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute\n"); - if (ShouldSkip("!SMOKECO.S.F00 && !SMOKECO.S.F01")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: TH reads from the DUT the FeatureMap attribute(Smoke Alarm)\n"); - if (ShouldSkip("SMOKECO.S.F00 && !SMOKECO.S.F01")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheFeatureMapAttributeSmokeAlarm_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: TH reads from the DUT the FeatureMap attribute(CO Alarm)\n"); - if (ShouldSkip("SMOKECO.S.F01 && !SMOKECO.S.F00")) { - NextTest(); - return; - } - err = TestStep3cThReadsFromTheDutTheFeatureMapAttributeCOAlarm_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: TH reads from the DUT the FeatureMap attribute(Smoke Alarm & CO Alarm)\n"); - if (ShouldSkip("SMOKECO.S.F00 && SMOKECO.S.F01")) { - NextTest(); - return; - } - err = TestStep3dThReadsFromTheDutTheFeatureMapAttributeSmokeAlarmCoAlarm_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads from the DUT the AttributeList attribute(SmokeState)\n"); - if (ShouldSkip("SMOKECO.S.A0001 && SMOKECO.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttributeSmokeState_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads from the DUT the AttributeList attribute(COState)\n"); - if (ShouldSkip("SMOKECO.S.A0002 && SMOKECO.S.F01")) { - NextTest(); - return; - } - err = TestStep4cThReadsFromTheDutTheAttributeListAttributeCOState_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4d: TH reads from the DUT the AttributeList attribute(DeviceMuted)\n"); - if (ShouldSkip("SMOKECO.S.A0004")) { - NextTest(); - return; - } - err = TestStep4dThReadsFromTheDutTheAttributeListAttributeDeviceMuted_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4e: TH reads from the DUT the AttributeList attribute(InterconnectSmokeAlarm)\n"); - if (ShouldSkip("SMOKECO.S.A0008")) { - NextTest(); - return; - } - err = TestStep4eThReadsFromTheDutTheAttributeListAttributeInterconnectSmokeAlarm_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4f: TH reads from the DUT the AttributeList attribute(InterconnectCOAlarm)\n"); - if (ShouldSkip("SMOKECO.S.A0009")) { - NextTest(); - return; - } - err = TestStep4fThReadsFromTheDutTheAttributeListAttributeInterconnectCOAlarm_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4g: TH reads from the DUT the AttributeList attribute(ContaminationState)\n"); - if (ShouldSkip("SMOKECO.S.A000a")) { - NextTest(); - return; - } - err = TestStep4gThReadsFromTheDutTheAttributeListAttributeContaminationState_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4h: TH reads from the DUT the AttributeList attribute(SmokeSensitivityLevel)\n"); - if (ShouldSkip("SMOKECO.S.A000b")) { - NextTest(); - return; - } - err = TestStep4hThReadsFromTheDutTheAttributeListAttributeSmokeSensitivityLevel_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4i: TH reads from the DUT the AttributeList attribute(ExpiryDate)\n"); - if (ShouldSkip("SMOKECO.S.A000c")) { - NextTest(); - return; - } - err = TestStep4iThReadsFromTheDutTheAttributeListAttributeExpiryDate_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5a: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH reads from the DUT the EventList attribute(SmokeAlarm)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E00")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5c: TH reads from the DUT the EventList attribute(COAlarm)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5d: TH reads from the DUT the EventList attribute(AlarmMuted)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E06")) { - NextTest(); - return; - } - NextTest(); - return; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 5e: TH reads from the DUT the EventList attribute(MuteEnded)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E07")) { - NextTest(); - return; - } - NextTest(); - return; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5f: TH reads from the DUT the EventList attribute(InterconnectSmokeAlarm)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E08")) { - NextTest(); - return; - } - NextTest(); - return; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5g: TH reads from the DUT the EventList attribute(InterconnectCOAlarm)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E09")) { - NextTest(); - return; - } - NextTest(); - return; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute\n"); - if (ShouldSkip("!SMOKECO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 6b: TH reads from the DUT the AcceptedCommandList attribute\n"); - if (ShouldSkip("SMOKECO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsFromTheDutTheAcceptedCommandListAttribute_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_24(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 25; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheFeatureMapAttributeSmokeAlarm_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute(Smoke Alarm): Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute(Smoke Alarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsFromTheDutTheFeatureMapAttributeCOAlarm_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute(CO Alarm): Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute(CO Alarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 2UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsFromTheDutTheFeatureMapAttributeSmokeAlarmCoAlarm_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute(Smoke Alarm & CO Alarm): Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute(Smoke Alarm & CO Alarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 3UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttributeSmokeState_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute(SmokeState): Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute(SmokeState): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFromTheDutTheAttributeListAttributeCOState_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute(COState): Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute(COState): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsFromTheDutTheAttributeListAttributeDeviceMuted_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute(DeviceMuted): Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute(DeviceMuted): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsFromTheDutTheAttributeListAttributeInterconnectSmokeAlarm_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads from the DUT the AttributeList attribute(InterconnectSmokeAlarm): Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads from the DUT the AttributeList attribute(InterconnectSmokeAlarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsFromTheDutTheAttributeListAttributeInterconnectCOAlarm_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads from the DUT the AttributeList attribute(InterconnectCOAlarm): Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads from the DUT the AttributeList attribute(InterconnectCOAlarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsFromTheDutTheAttributeListAttributeContaminationState_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads from the DUT the AttributeList attribute(ContaminationState): Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads from the DUT the AttributeList attribute(ContaminationState): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsFromTheDutTheAttributeListAttributeSmokeSensitivityLevel_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads from the DUT the AttributeList attribute(SmokeSensitivityLevel): Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads from the DUT the AttributeList attribute(SmokeSensitivityLevel): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsFromTheDutTheAttributeListAttributeExpiryDate_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads from the DUT the AttributeList attribute(ExpiryDate): Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads from the DUT the AttributeList attribute(ExpiryDate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFromTheDutTheAcceptedCommandListAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_SMOKECO_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_SMOKECO_2_1() - : TestCommandBridge("Test_TC_SMOKECO_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_SMOKECO_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_SMOKECO_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_SMOKECO_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ExpressedState attribute\n"); - if (ShouldSkip("SMOKECO.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheExpressedStateAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the SmokeState attribute\n"); - if (ShouldSkip("SMOKECO.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheSmokeStateAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the COState attribute\n"); - if (ShouldSkip("SMOKECO.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheCOStateAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the BatteryAlert attribute\n"); - if (ShouldSkip("SMOKECO.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheBatteryAlertAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the DeviceMuted attribute\n"); - if (ShouldSkip("SMOKECO.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheDeviceMutedAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the TestInProgress attribute\n"); - if (ShouldSkip("SMOKECO.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheTestInProgressAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the HardwareFaultAlert attribute\n"); - if (ShouldSkip("SMOKECO.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheHardwareFaultAlertAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the EndOfServiceAlert attribute\n"); - if (ShouldSkip("SMOKECO.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheEndOfServiceAlertAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the InterconnectSmokeAlarm attribute\n"); - if (ShouldSkip("SMOKECO.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheInterconnectSmokeAlarmAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the InterconnectCOAlarm attribute\n"); - if (ShouldSkip("SMOKECO.S.A0009")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheInterconnectCOAlarmAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the ContaminationState attribute\n"); - if (ShouldSkip("SMOKECO.S.A000a")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheContaminationStateAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the SmokeSensitivityLevel attribute\n"); - if (ShouldSkip("SMOKECO.S.A000b")) { - NextTest(); - return; - } - err = TestStep13ThReadsFromTheDutTheSmokeSensitivityLevelAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads from the DUT the ExpiryDate attribute\n"); - if (ShouldSkip("SMOKECO.S.A000c")) { - NextTest(); - return; - } - err = TestStep14ThReadsFromTheDutTheExpiryDateAttribute_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheExpressedStateAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeExpressedStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ExpressedState attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ExpressedState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("expressedState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("expressedState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("expressedState", [value unsignedCharValue], 8U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheSmokeStateAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSmokeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the SmokeState attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the SmokeState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("smokeState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("smokeState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("smokeState", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheCOStateAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCOStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the COState attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the COState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("COState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("COState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("COState", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheBatteryAlertAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatteryAlertWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the BatteryAlert attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the BatteryAlert attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batteryAlert", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("batteryAlert", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batteryAlert", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheDeviceMutedAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDeviceMutedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the DeviceMuted attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the DeviceMuted attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("deviceMuted", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("deviceMuted", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("deviceMuted", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheTestInProgressAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTestInProgressWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the TestInProgress attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the TestInProgress attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("testInProgress", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheHardwareFaultAlertAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeHardwareFaultAlertWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the HardwareFaultAlert attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the HardwareFaultAlert attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("hardwareFaultAlert", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheEndOfServiceAlertAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEndOfServiceAlertWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the EndOfServiceAlert attribute: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the EndOfServiceAlert attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("endOfServiceAlert", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("endOfServiceAlert", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("endOfServiceAlert", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheInterconnectSmokeAlarmAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInterconnectSmokeAlarmWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the InterconnectSmokeAlarm attribute: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the InterconnectSmokeAlarm attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("interconnectSmokeAlarm", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("interconnectSmokeAlarm", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("interconnectSmokeAlarm", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheInterconnectCOAlarmAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInterconnectCOAlarmWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the InterconnectCOAlarm attribute: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the InterconnectCOAlarm attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("interconnectCOAlarm", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("interconnectCOAlarm", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("interconnectCOAlarm", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheContaminationStateAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeContaminationStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the ContaminationState attribute: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the ContaminationState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("contaminationState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("contaminationState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("contaminationState", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsFromTheDutTheSmokeSensitivityLevelAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSmokeSensitivityLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads from the DUT the SmokeSensitivityLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads from the DUT the SmokeSensitivityLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("smokeSensitivityLevel", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("smokeSensitivityLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("smokeSensitivityLevel", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsFromTheDutTheExpiryDateAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeExpiryDateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads from the DUT the ExpiryDate attribute: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads from the DUT the ExpiryDate attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("expiryDate", "epoch_s", "epoch_s")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_SWTCH_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_SWTCH_1_1() - : TestCommandBridge("Test_TC_SWTCH_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_SWTCH_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_SWTCH_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_SWTCH_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 3: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep3ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads from the DUT the FeatureMap attribute and Check values of flags in this FeatureMap\n"); - if (ShouldSkip("!SWTCH.S.F00 && !SWTCH.S.F01 && !SWTCH.S.F02 && !SWTCH.S.F03 && !SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep2aThReadsFromTheDutTheFeatureMapAttributeAndCheckValuesOfFlagsInThisFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given SWTCH.S.F00(LS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenSwtchsf00lsEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given SWTCH.S.F01(MS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenSwtchsf01msEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2d: Given SWTCH.S.F02(MSR) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F02")) { - NextTest(); - return; - } - err = TestStep2dGivenSwtchsf02msrEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2e: Given SWTCH.S.F03(MSL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F03")) { - NextTest(); - return; - } - err = TestStep2eGivenSwtchsf03mslEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2f: Given SWTCH.S.F04(MSM) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep2fGivenSwtchsf04msmEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4b: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED && !SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5a: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("!SWTCH.S.F00 && !SWTCH.S.F01 && !SWTCH.S.F02 && !SWTCH.S.F03 && !SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5b: TH reads EventList if SWTCH.S.F00(LS)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SWTCH.S.F00")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5c: TH reads EventList if SWTCH.S.F01(MS) & !SWTCH.S.F02(MSR)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && !SWTCH.S.F02")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5d: TH reads EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & !SWTCH.S.F03(MSL) & !SWTCH.S.F04(MSM)\n"); - if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && !SWTCH.S.F03 && !SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5e: TH reads EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & SWTCH.S.F03(MSL) & !SWTCH.S.F04(MSM)\n"); - if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && SWTCH.S.F03 && !SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5f: TH reads EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & !SWTCH.S.F03(MSL) & SWTCH.S.F04(MSM) \n"); - if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && !SWTCH.S.F03 && SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5g: TH reads EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & SWTCH.S.F03(MSL) & SWTCH.S.F04(MSM) \n"); - if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && SWTCH.S.F03 && SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsFromTheDutTheFeatureMapAttributeAndCheckValuesOfFlagsInThisFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads from the DUT the FeatureMap attribute and Check values of flags in this FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads from the DUT the FeatureMap attribute and Check values of flags in this FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenSwtchsf00lsEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given SWTCH.S.F00(LS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2b: Given SWTCH.S.F00(LS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenSwtchsf01msEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given SWTCH.S.F01(MS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2c: Given SWTCH.S.F01(MS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dGivenSwtchsf02msrEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: Given SWTCH.S.F02(MSR) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2d: Given SWTCH.S.F02(MSR) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eGivenSwtchsf03mslEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: Given SWTCH.S.F03(MSL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2e: Given SWTCH.S.F03(MSL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fGivenSwtchsf04msmEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: Given SWTCH.S.F04(MSM) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2f: Given SWTCH.S.F04(MSM) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCCM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCCM_1_1() - : TestCommandBridge("Test_TC_TCCM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCCM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCCM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCCM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!TCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if TCCM.S.F00(DEPONOFF)\n"); - if (ShouldSkip("TCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTccmsf00deponoff_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the AttributeList attribute. 0x0002: SHALL be included if and only if TCCM.S.A0002(StartUpMode)\n"); - if (ShouldSkip("TCCM.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0002ShallBeIncludedIfAndOnlyIfTCCMSA0002StartUpMode_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003 SHALL be included if and only if TCCM.S.F00(DEPONOFF)\n"); - if (ShouldSkip("TCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTccmsf00deponoff_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTccmsf00deponoff_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if TCCM.S.F00(DEPONOFF): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if TCCM.S.F00(DEPONOFF): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0002ShallBeIncludedIfAndOnlyIfTCCMSA0002StartUpMode_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0002: SHALL be included if and only if TCCM.S.A0002(StartUpMode): Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0002: SHALL be included if and only if TCCM.S.A0002(StartUpMode): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTccmsf00deponoff_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003 SHALL be included if and only if TCCM.S.F00(DEPONOFF): Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003 SHALL be included if and only if TCCM.S.F00(DEPONOFF): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCTL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_1_1() - : TestCommandBridge("Test_TC_TCTL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute\n"); - if (ShouldSkip("!TCTL.S.F00 && !TCTL.S.F01 && !TCTL.S.F02")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: TH reads from the DUT the FeatureMap attribute. bit 0: SHALL be 1 if and only if TCTL.S.F00(TN) & !TCTL.S.F01(TL)\n"); - if (ShouldSkip("TCTL.S.F00 && !TCTL.S.F01")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTctlsf00tntctlsf01tl_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: TH reads from the DUT the FeatureMap attribute. bit 1: SHALL be 1 if and only if TCTL.S.F01(TL) & !TCTL.S.F00(TN)\n"); - if (ShouldSkip("TCTL.S.F01 && !TCTL.S.F00")) { - NextTest(); - return; - } - err = TestStep3cThReadsFromTheDutTheFeatureMapAttributeBit1ShallBe1IfAndOnlyIfTctlsf01tltctlsf00tn_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: TH reads from the DUT the FeatureMap attribute. bit 2: SHALL be 1 if and only if TCTL.S.F02(A_STEP) & TCTL.S.F00(TN)\n"); - if (ShouldSkip("TCTL.S.F02 && TCTL.S.F00")) { - NextTest(); - return; - } - err = TestStep3dThReadsFromTheDutTheFeatureMapAttributeBit2ShallBe1IfAndOnlyIfTctlsf02aStepTctlsf00tn_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: TH reads from the DUT the AttributeList attribute. 0x0000, 0x0001, 0x0002: SHALL be included if and only if TCTL.S.F00(TN)\n"); - if (ShouldSkip("TCTL.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute0x00000x00010x0002ShallBeIncludedIfAndOnlyIfTctlsf00tn_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003: SHALL be included if and only if TCTL.S.F02(A_STEP)\n"); - if (ShouldSkip("TCTL.S.F02")) { - NextTest(); - return; - } - err = TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTctlsf02aStep_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: TH reads from the DUT the AttributeList attribute. 0x0004 & 0x0005: SHALL be included if and only if TCTL.S.F01(TL)\n"); - if (ShouldSkip("TCTL.S.F01")) { - NextTest(); - return; - } - err = TestStep4dThReadsFromTheDutTheAttributeListAttribute0x00040x0005ShallBeIncludedIfAndOnlyIfTctlsf01tl_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep5ThReadsFromTheDutTheAcceptedCommandListAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheGeneratedCommandListAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTctlsf00tntctlsf01tl_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute. bit 0: SHALL be 1 if and only if TCTL.S.F00(TN) & !TCTL.S.F01(TL): Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute. bit 0: SHALL be 1 if and only if TCTL.S.F00(TN) & !TCTL.S.F01(TL): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsFromTheDutTheFeatureMapAttributeBit1ShallBe1IfAndOnlyIfTctlsf01tltctlsf00tn_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute. bit 1: SHALL be 1 if and only if TCTL.S.F01(TL) & !TCTL.S.F00(TN): Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute. bit 1: SHALL be 1 if and only if TCTL.S.F01(TL) & !TCTL.S.F00(TN): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsFromTheDutTheFeatureMapAttributeBit2ShallBe1IfAndOnlyIfTctlsf02aStepTctlsf00tn_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute. bit 2: SHALL be 1 if and only if TCTL.S.F02(A_STEP) & TCTL.S.F00(TN): Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute. bit 2: SHALL be 1 if and only if TCTL.S.F02(A_STEP) & TCTL.S.F00(TN): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute0x00000x00010x0002ShallBeIncludedIfAndOnlyIfTctlsf00tn_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0000, 0x0001, 0x0002: SHALL be included if and only if TCTL.S.F00(TN): Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0000, 0x0001, 0x0002: SHALL be included if and only if TCTL.S.F00(TN): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTctlsf02aStep_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003: SHALL be included if and only if TCTL.S.F02(A_STEP): Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003: SHALL be included if and only if TCTL.S.F02(A_STEP): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsFromTheDutTheAttributeListAttribute0x00040x0005ShallBeIncludedIfAndOnlyIfTctlsf01tl_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute. 0x0004 & 0x0005: SHALL be included if and only if TCTL.S.F01(TL): Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute. 0x0004 & 0x0005: SHALL be included if and only if TCTL.S.F01(TL): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheAcceptedCommandListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheGeneratedCommandListAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCTL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_2_2() - : TestCommandBridge("Test_TC_TCTL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinTemperature attribute\n"); - if (ShouldSkip("TCTL.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinTemperatureAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxTemperature attribute\n"); - if (ShouldSkip("TCTL.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxTemperatureAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the TemperatureSetpoint attribute\n"); - if (ShouldSkip("TCTL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheTemperatureSetpointAttribute_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull MinTemperatureValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinTemperatureAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinTemperature attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinTemperature attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minTemperature", "temperature", "temperature")); - { - MinTemperatureValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxTemperatureValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxTemperatureAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxTemperature attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxTemperature attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxTemperature", "temperature", "temperature")); - VerifyOrReturn(CheckConstraintMinValue("maxTemperature", [value shortValue], MinTemperatureValue)); - { - MaxTemperatureValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull temperatureValue; - - CHIP_ERROR TestStep4ThReadsFromTheDutTheTemperatureSetpointAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the TemperatureSetpoint attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("temperatureSetpoint", [value shortValue], MinTemperatureValue)); - VerifyOrReturn(CheckConstraintMaxValue("temperatureSetpoint", [value shortValue], MaxTemperatureValue)); - { - temperatureValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCTL_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_2_3() - : TestCommandBridge("Test_TC_TCTL_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the SelectedTemperatureLevel attribute\n"); - if (ShouldSkip("TCTL.S.A0004")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute\n"); - if (ShouldSkip("TCTL.S.A0005")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Verify that the DUT response contains a list of strings with each string length not exceeding 16 characters.\n"); - if (ShouldSkip("PICS_USER_PROMPT && TCTL.S.A0005")) { - NextTest(); - return; - } - err = TestVerifyThatTheDutResponseContainsAListOfStringsWithEachStringLengthNotExceeding16Characters_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the SelectedTemperatureLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the SelectedTemperatureLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("selectedTemperatureLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("selectedTemperatureLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("selectedTemperatureLevel", [value unsignedCharValue], 31U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedTemperatureLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedTemperatureLevels", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("supportedTemperatureLevels", value, 32)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheDutResponseContainsAListOfStringsWithEachStringLengthNotExceeding16Characters_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_TCTL_3_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_3_2() - : TestCommandBridge("Test_TC_TCTL_3_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Step_5_setTemp", INT16_MIN, INT16_MAX, &mStep5SetTemp); - AddArgument("InvalidTemp", INT16_MIN, INT16_MAX, &mInvalidTemp); - AddArgument("Step_10_setTemp", INT16_MIN, INT16_MAX, &mStep10SetTemp); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_3_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_3_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_3_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Operate device such that a temperature number can be accepted\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep2OperateDeviceSuchThatATemperatureNumberCanBeAccepted_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MinTemperature attribute\n"); - if (ShouldSkip("TCTL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMinTemperatureAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MaxTemperature attribute\n"); - if (ShouldSkip("TCTL.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMaxTemperatureAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp\n"); - if (ShouldSkip("TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for 5s\n"); - err = TestWaitFor5s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the TemperatureSetpoint attribute\n"); - if (ShouldSkip("TCTL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheTemperatureSetpointAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends command SetTemperatureCommand with an invalid value\n"); - if (ShouldSkip("TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait for 5s\n"); - err = TestWaitFor5s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 8: TH reads from the DUT the TemperatureSetpoint attribute\n"); - if (ShouldSkip("TCTL.S.A0000")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheTemperatureSetpointAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 9: Operate device such that a temperature number cannot be accepted\n"); - if (ShouldSkip("PICS_USER_PROMPT && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep9OperateDeviceSuchThatATemperatureNumberCannotBeAccepted_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 10: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp\n"); - if (ShouldSkip("TCTL.S.C00.Rsp && PICS_USER_PROMPT && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep10ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for 5s\n"); - err = TestWaitFor5s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 11: TH reads from the DUT the TemperatureSetpoint attribute\n"); - if (ShouldSkip("TCTL.S.A0000 && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheTemperatureSetpointAttribute_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_IN_STATE)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mStep5SetTemp; - chip::Optional mInvalidTemp; - chip::Optional mStep10SetTemp; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2OperateDeviceSuchThatATemperatureNumberCanBeAccepted_1() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nonnull minTemp; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMinTemperatureAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MinTemperature attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MinTemperature attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minTemperature", "temperature", "temperature")); - { - minTemp = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull maxTemp; - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMaxTemperatureAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MaxTemperature attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MaxTemperature attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxTemperature", "temperature", "temperature")); - { - maxTemp = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperature = mStep5SetTemp.HasValue() ? [NSNumber numberWithShort:mStep5SetTemp.Value()] : [NSNumber numberWithShort:5]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheTemperatureSetpointAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the TemperatureSetpoint attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureSetpoint", actualValue, mStep5SetTemp.HasValue() ? mStep5SetTemp.Value() : 5)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperature = mInvalidTemp.HasValue() ? [NSNumber numberWithShort:mInvalidTemp.Value()] : [NSNumber numberWithShort:100]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheTemperatureSetpointAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the TemperatureSetpoint attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureSetpoint", actualValue, mStep5SetTemp.HasValue() ? mStep5SetTemp.Value() : 5)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9OperateDeviceSuchThatATemperatureNumberCannotBeAccepted_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperature = mStep10SetTemp.HasValue() ? [NSNumber numberWithShort:mStep10SetTemp.Value()] : [NSNumber numberWithShort:50]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_IN_STATE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheTemperatureSetpointAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the TemperatureSetpoint attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureSetpoint", actualValue, mStep5SetTemp.HasValue() ? mStep5SetTemp.Value() : 5)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCTL_3_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_3_3() - : TestCommandBridge("Test_TC_TCTL_3_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Step_4_setLevel", 0, UINT8_MAX, &mStep4SetLevel); - AddArgument("Step_7_setLevel", 0, UINT8_MAX, &mStep7SetLevel); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_3_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_3_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_3_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Operate device such that a temperature level can be accepted\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep2OperateDeviceSuchThatATemperatureLevelCanBeAccepted_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute\n"); - if (ShouldSkip("TCTL.S.A0005")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH sends command SetTemperatureCommand with a value from supportedLevels saved as setLevel\n"); - if (ShouldSkip("TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsCommandSetTemperatureCommandWithAValueFromSupportedLevelsSavedAsSetLevel_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for 5s\n"); - if (ShouldSkip("TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestWaitFor5s_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the SelectedTemperatureLevel attribute\n"); - if (ShouldSkip("TCTL.S.A0004 && TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6:Operate device such that a temperature level cannot be accepted\n"); - if (ShouldSkip("PICS_USER_PROMPT && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep6OperateDeviceSuchThatATemperatureLevelCannotBeAccepted_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends command SetTemperatureCommand with an invalid value\n"); - if (ShouldSkip("TCTL.S.C00.Rsp && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait for 5s\n"); - if (ShouldSkip("TCTL.S.C00.Rsp && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestWaitFor5s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 8: TH reads from the DUT the SelectedTemperatureLevel attribute\n"); - if (ShouldSkip("TCTL.S.A0004 && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mStep4SetLevel; - chip::Optional mStep7SetLevel; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2OperateDeviceSuchThatATemperatureLevelCanBeAccepted_1() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSArray * _Nonnull supportedLevels; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedTemperatureLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedTemperatureLevels", "list", "list")); - { - supportedLevels = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsCommandSetTemperatureCommandWithAValueFromSupportedLevelsSavedAsSetLevel_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperatureLevel = mStep4SetLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mStep4SetLevel.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends command SetTemperatureCommand with a value from supportedLevels saved as setLevel: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends command SetTemperatureCommand with a value from supportedLevels saved as setLevel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the SelectedTemperatureLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the SelectedTemperatureLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, mStep4SetLevel.HasValue() ? mStep4SetLevel.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6OperateDeviceSuchThatATemperatureLevelCannotBeAccepted_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperatureLevel = mStep7SetLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mStep7SetLevel.Value()] : [NSNumber numberWithUnsignedChar:3U]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the SelectedTemperatureLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the SelectedTemperatureLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, mStep4SetLevel.HasValue() ? mStep4SetLevel.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TMP_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TMP_1_1() - : TestCommandBridge("Test_TC_TMP_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TMP_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TMP_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TMP_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads ClusterRevision attribute from the DUT\n"); - err = TestStep2ThReadsClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FeatureMap attribute from the DUT\n"); - err = TestStep3ThReadsFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheGlobalAttributeAttributeList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheGlobalAttributeAttributeList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("TMP.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads AcceptedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsAcceptedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads GeneratedCommandList attribute from the DUT\n"); - err = TestStep6ThReadsGeneratedCommandListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads EventList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheGlobalAttributeAttributeList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheGlobalAttributeAttributeList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsAcceptedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsGeneratedCommandListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TMP_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TMP_2_1() - : TestCommandBridge("Test_TC_TMP_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TMP_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TMP_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TMP_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the MinMeasuredValue attribute from the DUT\n"); - if (ShouldSkip("TMP.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheMinMeasuredValueAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the MaxMeasuredValue attribute from the DUT\n"); - if (ShouldSkip("TMP.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheMaxMeasuredValueAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads the MeasuredValue attribute from the DUT\n"); - if (ShouldSkip("TMP.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheMeasuredValueAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads the Tolerance attribute from the DUT\n"); - if (ShouldSkip("TMP.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheToleranceAttributeFromTheDut_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable CurrentMinMeasured; - - CHIP_ERROR TestStep2ThReadsTheMinMeasuredValueAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the MinMeasuredValue attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the MinMeasuredValue attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "temperature", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value shortValue], -27315)); - VerifyOrReturn(CheckConstraintMaxValue("minMeasuredValue", [value shortValue], 32766)); - } - { - CurrentMinMeasured = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable CurrentMaxMeasured; - - CHIP_ERROR TestStep3ThReadsTheMaxMeasuredValueAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the MaxMeasuredValue attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the MaxMeasuredValue attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "temperature", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value shortValue], CurrentMinMeasured)); - VerifyOrReturn(CheckConstraintMaxValue("maxMeasuredValue", [value shortValue], 32767)); - } - { - CurrentMaxMeasured = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheMeasuredValueAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the MeasuredValue attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the MeasuredValue attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "temperature", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value shortValue], CurrentMinMeasured)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value shortValue], CurrentMaxMeasured)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheToleranceAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("tolerance", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("tolerance", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("tolerance", [value unsignedShortValue], 2048U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TSTAT_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TSTAT_1_1() - : TestCommandBridge("Test_TC_TSTAT_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TSTAT_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSTAT_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSTAT_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!TSTAT.S.F00 && !TSTAT.S.F01 && !TSTAT.S.F02 && !TSTAT.S.F03 && !TSTAT.S.F04 && !TSTAT.S.F05")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given TSTAT.S.F00(HEAT ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenTstatsf00heatEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given TSTAT.S.F01(COOL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenTstatsf01coolEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given TSTAT.S.F02(OCC) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenTstatsf02occEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given TSTAT.S.F03(SCH) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenTstatsf03schEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given TSTAT.S.F04(SB) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenTstatsf04sbEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given TSTAT.S.F05(AUTO) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F05")) { - NextTest(); - return; - } - err = TestStep3gGivenTstatsf05autoEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given TSTAT.S.F06(LTNE) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F06")) { - NextTest(); - return; - } - err = TestStep3hGivenTstatsf06ltneEnsureFeaturemapHasTheCorrectBitSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentTSTATSF00HEATAttributeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c: TH reads the Feature dependent(TSTAT.S.F01(COOL)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentTSTATSF01COOLAttributeInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4d: TH reads the Feature dependent(TSTAT.S.F02(OCC)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheFeatureDependentTSTATSF02OCCAttributeInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4e: TH reads the Feature dependent(TSTAT.S.F00(HEAT) & TSTAT.S.F02(OCC)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheFeatureDependentTSTATSF00HEATTstatsf02occAttributeInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4f: TH reads the Feature dependent(TSTAT.S.F01(COOL) & TSTAT.S.F02(OCC)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheFeatureDependentTSTATSF01COOLTstatsf02occAttributeInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4g: TH reads the Feature dependent(TSTAT.S.F05(AUTO)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F05")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheFeatureDependentTSTATSF05AUTOAttributeInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4h: TH reads the Feature dependent(TSTAT.S.F03(SCH)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F03")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheFeatureDependentTSTATSF03SCHAttributeInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4i: TH reads the Feature dependent(TSTAT.S.F04(SB)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F04")) { - NextTest(); - return; - } - err = TestStep4iThReadsTheFeatureDependentTSTATSF04SBAttributeInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4j: TH reads the Feature dependent(TSTAT.S.F04(SB) & TSTAT.S.F02(OCC)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F04 && TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheFeatureDependentTSTATSF04SBTstatsf02occAttributeInAttributeList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4k: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0001")) { - NextTest(); - return; - } - err = TestStep4kThReadsTheOptionalAttributeInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4l: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0009")) { - NextTest(); - return; - } - err = TestStep4lThReadsTheOptionalAttributeInAttributeList_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4m: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0010")) { - NextTest(); - return; - } - err = TestStep4mThReadsTheOptionalAttributeInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4n: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A001a")) { - NextTest(); - return; - } - err = TestStep4nThReadsTheOptionalAttributeInAttributeList_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4o: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A001d")) { - NextTest(); - return; - } - err = TestStep4oThReadsTheOptionalAttributeInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4p: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0023")) { - NextTest(); - return; - } - err = TestStep4pThReadsTheOptionalAttributeInAttributeList_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4q: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0024")) { - NextTest(); - return; - } - err = TestStep4qThReadsTheOptionalAttributeInAttributeList_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4r: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0025")) { - NextTest(); - return; - } - err = TestStep4rThReadsTheOptionalAttributeInAttributeList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4s: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0029")) { - NextTest(); - return; - } - err = TestStep4sThReadsTheOptionalAttributeInAttributeList_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 4t: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0030")) { - NextTest(); - return; - } - err = TestStep4tThReadsTheOptionalAttributeInAttributeList_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4u: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0031")) { - NextTest(); - return; - } - err = TestStep4uThReadsTheOptionalAttributeInAttributeList_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4x: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0032")) { - NextTest(); - return; - } - err = TestStep4xThReadsTheOptionalAttributeInAttributeList_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 4y: TH reads the optional attribute: AttributeList\n"); - if (ShouldSkip("TSTAT.S.A003a")) { - NextTest(); - return; - } - err = TestStep4yThReadsTheOptionalAttributeAttributeList_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4z: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0040")) { - NextTest(); - return; - } - err = TestStep4zThReadsTheOptionalAttributeInAttributeList_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4A: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0041")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheOptionalAttributeInAttributeList_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4B: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0042")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeInAttributeList_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 4C: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0043")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeInAttributeList_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 4D: TH reads the optional attribute: AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0044")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeAttributeList_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 4E: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0045")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeInAttributeList_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 4F: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0046")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalAttributeInAttributeList_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 4g: TH reads the optional attribute: AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0047")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalAttributeAttributeList_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 4H: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0003")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 4I: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0004")) { - NextTest(); - return; - } - err = TestStep4iThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 4J: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0008")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 4K: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0015")) { - NextTest(); - return; - } - err = TestStep4kThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 4L: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0016")) { - NextTest(); - return; - } - err = TestStep4lThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 4M: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0005")) { - NextTest(); - return; - } - err = TestStep4mThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 4N: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0007")) { - NextTest(); - return; - } - err = TestStep4nThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Step 4O: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0007")) { - NextTest(); - return; - } - err = TestStep4oThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Step 4P: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0017")) { - NextTest(); - return; - } - err = TestStep4pThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Step 4Q: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0018")) { - NextTest(); - return; - } - err = TestStep4qThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Step 4R: TH reads the Feature dependent(TSTAT.S.F05(AUTO)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F05 && TSTAT.S.A001e")) { - NextTest(); - return; - } - err = TestStep4rThReadsTheFeatureDependentTSTATSF05AUTOOptionalAttributeInAttributeList_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Step 5: TH reads EventList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Step 6b: TH reads Feature dependent(TSTAT.S.F03(SCH)) commands in AcceptedCommandList\n"); - if (ShouldSkip("TSTAT.S.F03")) { - NextTest(); - return; - } - err = TestStep6bThReadsFeatureDependentTSTATSF03SCHCommandsInAcceptedCommandList_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Step 6c: TH reads the optional (GetRelayStatusLog) command in AcceptedCommandList\n"); - if (ShouldSkip("TSTAT.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThReadsTheOptionalGetRelayStatusLogCommandInAcceptedCommandList_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Step 7a: TH reads from the DUT the GeneratedCommandList attribute.\n"); - if (ShouldSkip(" !TSTAT.S.C04.Rsp && !TSTAT.S.C02.Rsp ")) { - NextTest(); - return; - } - err = TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Step 7b: TH reads Feature dependent(TSTAT.S.F03(SCH)) commands in GeneratedCommandList\n"); - if (ShouldSkip("TSTAT.S.F03")) { - NextTest(); - return; - } - err = TestStep7bThReadsFeatureDependentTSTATSF03SCHCommandsInGeneratedCommandList_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Step 7c: TH reads optional command (GetRelayStatusLogResponse) in GeneratedCommandList\n"); - if (ShouldSkip("TSTAT.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep7cThReadsOptionalCommandGetRelayStatusLogResponseInGeneratedCommandList_59(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 60; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 6U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenTstatsf00heatEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given TSTAT.S.F00(HEAT ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given TSTAT.S.F00(HEAT ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenTstatsf01coolEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given TSTAT.S.F01(COOL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given TSTAT.S.F01(COOL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenTstatsf02occEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given TSTAT.S.F02(OCC) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given TSTAT.S.F02(OCC) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenTstatsf03schEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given TSTAT.S.F03(SCH) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given TSTAT.S.F03(SCH) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenTstatsf04sbEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given TSTAT.S.F04(SB) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given TSTAT.S.F04(SB) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenTstatsf05autoEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given TSTAT.S.F05(AUTO) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given TSTAT.S.F05(AUTO) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenTstatsf06ltneEnsureFeaturemapHasTheCorrectBitSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given TSTAT.S.F06(LTNE) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given TSTAT.S.F06(LTNE) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentTSTATSF00HEATAttributeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentTSTATSF01COOLAttributeInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent(TSTAT.S.F01(COOL)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent(TSTAT.S.F01(COOL)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheFeatureDependentTSTATSF02OCCAttributeInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the Feature dependent(TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the Feature dependent(TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheFeatureDependentTSTATSF00HEATTstatsf02occAttributeInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the Feature dependent(TSTAT.S.F00(HEAT) & TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the Feature dependent(TSTAT.S.F00(HEAT) & TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheFeatureDependentTSTATSF01COOLTstatsf02occAttributeInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the Feature dependent(TSTAT.S.F01(COOL) & TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the Feature dependent(TSTAT.S.F01(COOL) & TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheFeatureDependentTSTATSF05AUTOAttributeInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the Feature dependent(TSTAT.S.F05(AUTO)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the Feature dependent(TSTAT.S.F05(AUTO)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheFeatureDependentTSTATSF03SCHAttributeInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the Feature dependent(TSTAT.S.F03(SCH)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the Feature dependent(TSTAT.S.F03(SCH)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsTheFeatureDependentTSTATSF04SBAttributeInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads the Feature dependent(TSTAT.S.F04(SB)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads the Feature dependent(TSTAT.S.F04(SB)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 52UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 53UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 54UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheFeatureDependentTSTATSF04SBTstatsf02occAttributeInAttributeList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the Feature dependent(TSTAT.S.F04(SB) & TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the Feature dependent(TSTAT.S.F04(SB) & TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 55UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 56UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 57UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsTheOptionalAttributeInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsTheOptionalAttributeInAttributeList_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsTheOptionalAttributeInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4m: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsTheOptionalAttributeInAttributeList_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4n: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsTheOptionalAttributeInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4o: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 29UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsTheOptionalAttributeInAttributeList_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4p: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4p: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 35UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qThReadsTheOptionalAttributeInAttributeList_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4q: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4q: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4rThReadsTheOptionalAttributeInAttributeList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4r: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4r: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4sThReadsTheOptionalAttributeInAttributeList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4s: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4s: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4tThReadsTheOptionalAttributeInAttributeList_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4t: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4t: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4uThReadsTheOptionalAttributeInAttributeList_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4u: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4u: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4xThReadsTheOptionalAttributeInAttributeList_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4x: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4x: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4yThReadsTheOptionalAttributeAttributeList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4y: TH reads the optional attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4y: TH reads the optional attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 58UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4zThReadsTheOptionalAttributeInAttributeList_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4z: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4z: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheOptionalAttributeInAttributeList_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4A: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4A: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeInAttributeList_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4B: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4B: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 66UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeInAttributeList_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4C: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4C: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 67UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeAttributeList_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4D: TH reads the optional attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4D: TH reads the optional attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 68UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeInAttributeList_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4E: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4E: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 69UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalAttributeInAttributeList_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4F: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4F: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 70UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalAttributeAttributeList_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 71UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4H: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4H: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4I: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4I: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4J: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4J: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4K: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4K: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4L: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4L: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4M: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4M: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4N: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4N: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4O: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4O: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4P: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4P: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4Q: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4Q: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 24UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4rThReadsTheFeatureDependentTSTATSF05AUTOOptionalAttributeInAttributeList_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4R: TH reads the Feature dependent(TSTAT.S.F05(AUTO)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4R: TH reads the Feature dependent(TSTAT.S.F05(AUTO)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 30UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFeatureDependentTSTATSF03SCHCommandsInAcceptedCommandList_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads Feature dependent(TSTAT.S.F03(SCH)) commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads Feature dependent(TSTAT.S.F03(SCH)) commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsTheOptionalGetRelayStatusLogCommandInAcceptedCommandList_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads the optional (GetRelayStatusLog) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads the optional (GetRelayStatusLog) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bThReadsFeatureDependentTSTATSF03SCHCommandsInGeneratedCommandList_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH reads Feature dependent(TSTAT.S.F03(SCH)) commands in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7b: TH reads Feature dependent(TSTAT.S.F03(SCH)) commands in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7cThReadsOptionalCommandGetRelayStatusLogResponseInGeneratedCommandList_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7c: TH reads optional command (GetRelayStatusLogResponse) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7c: TH reads optional command (GetRelayStatusLogResponse) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TSUIC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TSUIC_1_1() - : TestCommandBridge("Test_TC_TSUIC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TSUIC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSUIC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSUIC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(ScheduleProgrammingVisibility) in AttributeList\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeScheduleProgrammingVisibilityInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeScheduleProgrammingVisibilityInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(ScheduleProgrammingVisibility) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(ScheduleProgrammingVisibility) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TSUIC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TSUIC_2_1() - : TestCommandBridge("Test_TC_TSUIC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TSUIC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSUIC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSUIC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the TemperatureDisplayMode attribute from the DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheTemperatureDisplayModeAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the KeypadLockout attribute from the DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheKeypadLockoutAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads the ScheduleProgrammingVisibility attribute from the DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheScheduleProgrammingVisibilityAttributeFromTheDut_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheTemperatureDisplayModeAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the TemperatureDisplayMode attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the TemperatureDisplayMode attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("temperatureDisplayMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("temperatureDisplayMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("temperatureDisplayMode", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheKeypadLockoutAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the KeypadLockout attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the KeypadLockout attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("keypadLockout", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("keypadLockout", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("keypadLockout", [value unsignedCharValue], 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheScheduleProgrammingVisibilityAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the ScheduleProgrammingVisibility attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the ScheduleProgrammingVisibility attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("scheduleProgrammingVisibility", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("scheduleProgrammingVisibility", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("scheduleProgrammingVisibility", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TSUIC_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TSUIC_2_2() - : TestCommandBridge("Test_TC_TSUIC_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TSUIC_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSUIC_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSUIC_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH writes a value of 0 to TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2aThWritesAValueOf0ToTemperatureDisplayModeAttributeOfDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify device temperature displayed in °C\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestVerifyDeviceTemperatureDisplayedInc_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH reads the TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2bThReadsTheTemperatureDisplayModeAttributeOfDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: TH writes a value of 1 to TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2cThWritesAValueOf1ToTemperatureDisplayModeAttributeOfDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Verify device temperature displayed in °F\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestVerifyDeviceTemperatureDisplayedInf_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2d: TH reads the TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2dThReadsTheTemperatureDisplayModeAttributeOfDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2e: TH writes a value of greater than 1 to TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2eThWritesAValueOfGreaterThan1ToTemperatureDisplayModeAttributeOfDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2f: TH reads the TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2fThReadsTheTemperatureDisplayModeAttributeOfDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3a: TH writes a value of 0 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3aThWritesAValueOf0ToKeypadLockoutAttributeOfDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Verify all device functionality available to the user\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyAllDeviceFunctionalityAvailableToTheUser_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheKeypadLockoutAttributeOfDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH writes a value of 1 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThWritesAValueOf1ToKeypadLockoutAttributeOfDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Verify device operates at Level 1 reduced functionality\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLevel1ReducedFunctionality_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3d: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheKeypadLockoutAttributeOfDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3e: TH writes a value of 2 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3eThWritesAValueOf2ToKeypadLockoutAttributeOfDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Verify device operates at Level 2 reduced functionality\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLevel2ReducedFunctionality_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3f: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3fThReadsTheKeypadLockoutAttributeOfDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3g: TH writes a value of 3 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3gThWritesAValueOf3ToKeypadLockoutAttributeOfDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Verify device operates at Level 3 reduced functionality\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLevel3ReducedFunctionality_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3h: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3hThReadsTheKeypadLockoutAttributeOfDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3i: TH writes a value of 4 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3iThWritesAValueOf4ToKeypadLockoutAttributeOfDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Verify device operates at Level 4 reduced functionality\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLevel4ReducedFunctionality_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3j: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3jThReadsTheKeypadLockoutAttributeOfDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3k: TH writes a value of 5 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3kThWritesAValueOf5ToKeypadLockoutAttributeOfDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Verify device operates at least functionality level\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLeastFunctionalityLevel_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 3l: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3lThReadsTheKeypadLockoutAttributeOfDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 3m: Writes a value of greater than 5 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3mWritesAValueOfGreaterThan5ToKeypadLockoutAttributeOfDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 3n: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3nThReadsTheKeypadLockoutAttributeOfDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4a: TH writes a value of 0 to ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4aThWritesAValueOf0ToScheduleProgrammingVisibilityAttributeOfDut_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Verify local schedule programming functionality is enabled at the thermostat\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestVerifyLocalScheduleProgrammingFunctionalityIsEnabledAtTheThermostat_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4b: TH reads the ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheScheduleProgrammingVisibilityAttributeOfDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4c: TH writes a value of 1 to ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cThWritesAValueOf1ToScheduleProgrammingVisibilityAttributeOfDut_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Verify local schedule programming functionality is disabled at the thermostat\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestVerifyLocalScheduleProgrammingFunctionalityIsDisabledAtTheThermostat_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4d: TH reads the ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheScheduleProgrammingVisibilityAttributeOfDut_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4e: TH writes a value of greater than 1 to ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4eThWritesAValueOfGreaterThan1ToScheduleProgrammingVisibilityAttributeOfDut_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4f: TH reads the ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheScheduleProgrammingVisibilityAttributeOfDut_36(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 37; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThWritesAValueOf0ToTemperatureDisplayModeAttributeOfDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureDisplayModeArgument; - temperatureDisplayModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeTemperatureDisplayModeWithValue:temperatureDisplayModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH writes a value of 0 to TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH writes a value of 0 to TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceTemperatureDisplayedInc_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsTheTemperatureDisplayModeAttributeOfDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads the TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads the TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureDisplayMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThWritesAValueOf1ToTemperatureDisplayModeAttributeOfDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureDisplayModeArgument; - temperatureDisplayModeArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeTemperatureDisplayModeWithValue:temperatureDisplayModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH writes a value of 1 to TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH writes a value of 1 to TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceTemperatureDisplayedInf_5() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsTheTemperatureDisplayModeAttributeOfDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads the TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads the TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureDisplayMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThWritesAValueOfGreaterThan1ToTemperatureDisplayModeAttributeOfDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureDisplayModeArgument; - temperatureDisplayModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeTemperatureDisplayModeWithValue:temperatureDisplayModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH writes a value of greater than 1 to TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH writes a value of greater than 1 to TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThReadsTheTemperatureDisplayModeAttributeOfDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads the TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads the TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureDisplayMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWritesAValueOf0ToKeypadLockoutAttributeOfDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH writes a value of 0 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH writes a value of 0 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyAllDeviceFunctionalityAvailableToTheUser_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsTheKeypadLockoutAttributeOfDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThWritesAValueOf1ToKeypadLockoutAttributeOfDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH writes a value of 1 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH writes a value of 1 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLevel1ReducedFunctionality_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsTheKeypadLockoutAttributeOfDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThWritesAValueOf2ToKeypadLockoutAttributeOfDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH writes a value of 2 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH writes a value of 2 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLevel2ReducedFunctionality_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3fThReadsTheKeypadLockoutAttributeOfDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gThWritesAValueOf3ToKeypadLockoutAttributeOfDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH writes a value of 3 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3g: TH writes a value of 3 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLevel3ReducedFunctionality_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3hThReadsTheKeypadLockoutAttributeOfDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3h: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iThWritesAValueOf4ToKeypadLockoutAttributeOfDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:4U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: TH writes a value of 4 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3i: TH writes a value of 4 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLevel4ReducedFunctionality_22() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3jThReadsTheKeypadLockoutAttributeOfDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3j: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kThWritesAValueOf5ToKeypadLockoutAttributeOfDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: TH writes a value of 5 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3k: TH writes a value of 5 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLeastFunctionalityLevel_25() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3lThReadsTheKeypadLockoutAttributeOfDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3l: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mWritesAValueOfGreaterThan5ToKeypadLockoutAttributeOfDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:6U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Writes a value of greater than 5 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3m: Writes a value of greater than 5 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3nThReadsTheKeypadLockoutAttributeOfDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3n: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3n: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWritesAValueOf0ToScheduleProgrammingVisibilityAttributeOfDut_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id scheduleProgrammingVisibilityArgument; - scheduleProgrammingVisibilityArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeScheduleProgrammingVisibilityWithValue:scheduleProgrammingVisibilityArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH writes a value of 0 to ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH writes a value of 0 to ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyLocalScheduleProgrammingFunctionalityIsEnabledAtTheThermostat_30() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4bThReadsTheScheduleProgrammingVisibilityAttributeOfDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ScheduleProgrammingVisibility", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThWritesAValueOf1ToScheduleProgrammingVisibilityAttributeOfDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id scheduleProgrammingVisibilityArgument; - scheduleProgrammingVisibilityArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeScheduleProgrammingVisibilityWithValue:scheduleProgrammingVisibilityArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH writes a value of 1 to ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH writes a value of 1 to ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyLocalScheduleProgrammingFunctionalityIsDisabledAtTheThermostat_33() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4dThReadsTheScheduleProgrammingVisibilityAttributeOfDut_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ScheduleProgrammingVisibility", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThWritesAValueOfGreaterThan1ToScheduleProgrammingVisibilityAttributeOfDut_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id scheduleProgrammingVisibilityArgument; - scheduleProgrammingVisibilityArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeScheduleProgrammingVisibilityWithValue:scheduleProgrammingVisibilityArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH writes a value of greater than 1 to ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH writes a value of greater than 1 to ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheScheduleProgrammingVisibilityAttributeOfDut_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ScheduleProgrammingVisibility", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGTHREAD_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGTHREAD_1_1() - : TestCommandBridge("Test_TC_DGTHREAD_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGTHREAD_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGTHREAD_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGTHREAD_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip(" !DGTHREAD.S.F00 && !DGTHREAD.S.F01 && !DGTHREAD.S.F02 && !DGTHREAD.S.F03 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGTHREAD.S.F00(PKTCNT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGTHREAD.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDgthreadsf00pktcntEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DGTHREAD.S.F01(ERRCNT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGTHREAD.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenDgthreadsf01errcntEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given DGTHREAD.S.F02(MLECNT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGTHREAD.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenDgthreadsf02mlecntEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given DGTHREAD.S.F03(MACCNT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGTHREAD.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenDgthreadsf03maccntEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH reads mandatory attributes in AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads mandatory attributes in AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4b: TH reads Feature dependent attribute(DGTHREAD.S.F01(ERRCNT)) in attributeList\n"); - if (ShouldSkip("DGTHREAD.S.A0006 && DGTHREAD.S.F01")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentAttributeDGTHREADSF01ERRCNTInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4c: TH reads Feature dependent attribute (DGTHREAD.S.F02(MLECNT)) in attributeList\n"); - if (ShouldSkip("DGTHREAD.S.F02")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentAttributeDgthreadsf02mlecntInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4d: TH reads Feature dependent attribute (DGTHREAD.S.F03(MACCNT)) in attributeList\n"); - if (ShouldSkip("DGTHREAD.S.F03")) { - NextTest(); - return; - } - err = TestStep4dThReadsFeatureDependentAttributeDgthreadsf03maccntInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4e: TH reads the optional attribute (ActiveTimestamp) in AttributeList\n"); - if (ShouldSkip("DGTHREAD.S.A0038")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeActiveTimestampInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4f: TH reads the optional attribute (PendingTimestamp) in AttributeList\n"); - if (ShouldSkip("DGTHREAD.S.A0039")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalAttributePendingTimestampInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4g: TH reads the optional attribute (Delay) in AttributeList\n"); - if (ShouldSkip("DGTHREAD.S.A003a")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalAttributeDelayInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip(" !DGTHREAD.S.E00 && !DGTHREAD.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH reads DGTHREAD.S.E00(ConnectionStatus) event in EventList\n"); - if (ShouldSkip("DGTHREAD.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5c: TH reads DGTHREAD.S.E01(NetworkFaultChange) event in EventList\n"); - if (ShouldSkip("DGTHREAD.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip(" !DGTHREAD.S.F01 ")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip("DGTHREAD.S.F01")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDgthreadsf00pktcntEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DGTHREAD.S.F00(PKTCNT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DGTHREAD.S.F00(PKTCNT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenDgthreadsf01errcntEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given DGTHREAD.S.F01(ERRCNT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given DGTHREAD.S.F01(ERRCNT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenDgthreadsf02mlecntEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given DGTHREAD.S.F02(MLECNT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given DGTHREAD.S.F02(MLECNT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenDgthreadsf03maccntEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given DGTHREAD.S.F03(MACCNT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given DGTHREAD.S.F03(MACCNT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 59UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 60UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 61UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 62UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 59UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 60UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 61UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 62UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentAttributeDGTHREADSF01ERRCNTInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent attribute(DGTHREAD.S.F01(ERRCNT)) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent attribute(DGTHREAD.S.F01(ERRCNT)) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentAttributeDgthreadsf02mlecntInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads Feature dependent attribute (DGTHREAD.S.F02(MLECNT)) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads Feature dependent attribute (DGTHREAD.S.F02(MLECNT)) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsFeatureDependentAttributeDgthreadsf03maccntInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads Feature dependent attribute (DGTHREAD.S.F03(MACCNT)) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads Feature dependent attribute (DGTHREAD.S.F03(MACCNT)) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 24UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 29UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 30UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 31UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 35UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 39UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 40UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 42UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 43UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 44UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 45UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 46UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 47UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 51UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 52UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 53UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 54UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 55UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeActiveTimestampInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional attribute (ActiveTimestamp) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional attribute (ActiveTimestamp) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 56UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalAttributePendingTimestampInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional attribute (PendingTimestamp) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional attribute (PendingTimestamp) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 57UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalAttributeDelayInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional attribute (Delay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional attribute (Delay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 58UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TIMESYNC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TIMESYNC_1_1() - : TestCommandBridge("Test_TC_TIMESYNC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TIMESYNC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TIMESYNC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TIMESYNC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given !TIMESYNC.S.F00(TZ) ensure featuremap has the correct bit clear\n"); - if (ShouldSkip("!TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGiventimesyncsf00tzEnsureFeaturemapHasTheCorrectBitClear_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenTimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given !TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit clear\n"); - if (ShouldSkip("!TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGiventimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitClear_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TIMESYNC.S.F02")) { - NextTest(); - return; - } - err = TestStep3eGivenTimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given !TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit clear\n"); - if (ShouldSkip("!TIMESYNC.S.F02")) { - NextTest(); - return; - } - err = TestStep3fGiventimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitClear_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep3gGivenTimesyncsf03tscEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given !TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit clear\n"); - if (ShouldSkip("!TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep3hGiventimesyncsf03tscEnsureFeaturemapHasTheCorrectBitClear_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4b: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4c: Check for optional attribute TimeSource in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cCheckForOptionalAttributeTimeSourceInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4d: Check for optional attribute TimeSource not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dCheckForOptionalAttributeTimeSourceNotInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4e: Check for TZ feature-based attributes in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep4eCheckForTzFeatureBasedAttributesInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4f: Check for TZ feature-based attributes not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep4fCheckForTzFeatureBasedAttributesNotInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4g: Check for NTPC feature-based attributes in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep4gCheckForNtpcFeatureBasedAttributesInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4h: Check for NTPC feature-based attributes not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep4hCheckForNtpcFeatureBasedAttributesNotInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4i: Check for NTPS feature-based attributes in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.F02")) { - NextTest(); - return; - } - err = TestStep4iCheckForNtpsFeatureBasedAttributesInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4j: Check for NTPS feature-based attributes not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.F02")) { - NextTest(); - return; - } - err = TestStep4jCheckForNtpsFeatureBasedAttributesNotInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4k: Check for TSC feature-based attributes in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep4kCheckForTscFeatureBasedAttributesInAttributeList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4l: Check for TSC feature-based attributes not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep4lCheckForTscFeatureBasedAttributesNotInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5a: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 5b: Check for TZ feature-based events in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && TIMESYNC.S.F00")) { - NextTest(); - return; - } - NextTest(); - return; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 5c: Check for TZ feature-based events not in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !TIMESYNC.S.F00")) { - NextTest(); - return; - } - NextTest(); - return; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 5d: Check for TSC feature-based events in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && TIMESYNC.S.F03")) { - NextTest(); - return; - } - NextTest(); - return; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 5e: Check for TSC feature-based events not in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !TIMESYNC.S.F03")) { - NextTest(); - return; - } - NextTest(); - return; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6b: Check for TZ feature-based commands in AcceptedCommandList\n"); - if (ShouldSkip("TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep6bCheckForTzFeatureBasedCommandsInAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 6c: Check for TZ feature-based commands in not AcceptedCommandList\n"); - if (ShouldSkip("!TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep6cCheckForTzFeatureBasedCommandsInNotAcceptedCommandList_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 6d: Check for NTPC feature-based commands in AcceptedCommandList\n"); - if (ShouldSkip("TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep6dCheckForNtpcFeatureBasedCommandsInAcceptedCommandList_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 6e: Check for NTPC feature-based commands in not AcceptedCommandList\n"); - if (ShouldSkip("!TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep6eCheckForNtpcFeatureBasedCommandsInNotAcceptedCommandList_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 6f: Check for TSC feature-based commands in AcceptedCommandList\n"); - if (ShouldSkip("TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep6fCheckForTscFeatureBasedCommandsInAcceptedCommandList_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 6g: Check for TSC feature-based commands in not AcceptedCommandList\n"); - if (ShouldSkip("!TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep6gCheckForTscFeatureBasedCommandsInNotAcceptedCommandList_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 7a: TH reads from the DUT the GeneratedCommandList attribute\n"); - if (ShouldSkip("TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 7b: Check for TZ feature-based commands in not GeneratedCommandList\n"); - if (ShouldSkip("!TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep7bCheckForTzFeatureBasedCommandsInNotGeneratedCommandList_35(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 36; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGiventimesyncsf00tzEnsureFeaturemapHasTheCorrectBitClear_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given !TIMESYNC.S.F00(TZ) ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3b: Given !TIMESYNC.S.F00(TZ) ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenTimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGiventimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitClear_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given !TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3d: Given !TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenTimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGiventimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitClear_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given !TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3f: Given !TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenTimesyncsf03tscEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGiventimesyncsf03tscEnsureFeaturemapHasTheCorrectBitClear_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given !TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3h: Given !TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckForOptionalAttributeTimeSourceInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check for optional attribute TimeSource in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: Check for optional attribute TimeSource in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dCheckForOptionalAttributeTimeSourceNotInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Check for optional attribute TimeSource not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Check for optional attribute TimeSource not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckForTzFeatureBasedAttributesInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check for TZ feature-based attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: Check for TZ feature-based attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fCheckForTzFeatureBasedAttributesNotInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Check for TZ feature-based attributes not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Check for TZ feature-based attributes not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckForNtpcFeatureBasedAttributesInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check for NTPC feature-based attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: Check for NTPC feature-based attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hCheckForNtpcFeatureBasedAttributesNotInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Check for NTPC feature-based attributes not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Check for NTPC feature-based attributes not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckForNtpsFeatureBasedAttributesInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check for NTPS feature-based attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: Check for NTPS feature-based attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jCheckForNtpsFeatureBasedAttributesNotInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Check for NTPS feature-based attributes not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Check for NTPS feature-based attributes not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckForTscFeatureBasedAttributesInAttributeList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check for TSC feature-based attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: Check for TSC feature-based attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lCheckForTscFeatureBasedAttributesNotInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: Check for TSC feature-based attributes not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: Check for TSC feature-based attributes not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bCheckForTzFeatureBasedCommandsInAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: Check for TZ feature-based commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: Check for TZ feature-based commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cCheckForTzFeatureBasedCommandsInNotAcceptedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: Check for TZ feature-based commands in not AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: Check for TZ feature-based commands in not AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dCheckForNtpcFeatureBasedCommandsInAcceptedCommandList_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: Check for NTPC feature-based commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: Check for NTPC feature-based commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eCheckForNtpcFeatureBasedCommandsInNotAcceptedCommandList_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: Check for NTPC feature-based commands in not AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6e: Check for NTPC feature-based commands in not AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fCheckForTscFeatureBasedCommandsInAcceptedCommandList_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: Check for TSC feature-based commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6f: Check for TSC feature-based commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gCheckForTscFeatureBasedCommandsInNotAcceptedCommandList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6g: Check for TSC feature-based commands in not AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6g: Check for TSC feature-based commands in not AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bCheckForTzFeatureBasedCommandsInNotGeneratedCommandList_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: Check for TZ feature-based commands in not GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7b: Check for TZ feature-based commands in not GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("generatedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TIMESYNC_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TIMESYNC_2_3() - : TestCommandBridge("Test_TC_TIMESYNC_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TIMESYNC_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TIMESYNC_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TIMESYNC_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read commissioner nodeID and saves as th_node_id\n"); - err = TestReadCommissionerNodeIDAndSavesAsThNodeId_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource fields set as follows: NodeID: th_node_id, Endpoint: 0\n"); - err = TestStep1ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceFieldsSetAsFollowsNodeIDThNodeIdEndpoint0_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH reads from the DUT the CurrentFabricIndex attribute from the Node Operational Credentials Cluster and saves as th_fabric_idx\n"); - err = TestStep2ThReadsFromTheDutTheCurrentFabricIndexAttributeFromTheNodeOperationalCredentialsClusterAndSavesAsThFabricIdx_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads from the DUT the TrustedTimeSource attribute.\n"); - err = TestStep3ThReadsFromTheDutTheTrustedTimeSourceAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource set to null.\n"); - err = TestStep4ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceSetToNull_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the TrustedTimeSource attribute.\n"); - err = TestStep5ThReadsFromTheDutTheTrustedTimeSourceAttribute_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull th_node_id; - - CHIP_ERROR TestReadCommissionerNodeIDAndSavesAsThNodeId_1() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - th_node_id = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestStep1ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceFieldsSetAsFollowsNodeIDThNodeIdEndpoint0_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTrustedTimeSourceParams alloc] init]; - params.trustedTimeSource = [[MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct alloc] init]; - ((MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct *) params.trustedTimeSource).nodeID = - [th_node_id copy]; - ((MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct *) params.trustedTimeSource).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster setTrustedTimeSourceWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource fields set as follows: NodeID: th_node_id, Endpoint: 0: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource fields set as follows: NodeID: th_node_id, Endpoint: 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull th_fabric_idx; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheCurrentFabricIndexAttributeFromTheNodeOperationalCredentialsClusterAndSavesAsThFabricIdx_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the CurrentFabricIndex attribute from the Node Operational Credentials Cluster and saves as th_fabric_idx: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the CurrentFabricIndex attribute from the Node Operational Credentials Cluster and saves as th_fabric_idx: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th_fabric_idx = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTrustedTimeSourceAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTrustedTimeSourceWithCompletion:^(MTRTimeSynchronizationClusterTrustedTimeSourceStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the TrustedTimeSource attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the TrustedTimeSource attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TrustedTimeSource", actualValue)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRTimeSynchronizationClusterTrustedTimeSourceStruct *) actualValue).fabricIndex, th_fabric_idx)); - VerifyOrReturn(CheckValue("NodeID", ((MTRTimeSynchronizationClusterTrustedTimeSourceStruct *) actualValue).nodeID, th_node_id)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRTimeSynchronizationClusterTrustedTimeSourceStruct *) actualValue).endpoint, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceSetToNull_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTrustedTimeSourceParams alloc] init]; - params.trustedTimeSource = nil; - [cluster setTrustedTimeSourceWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource set to null.: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource set to null.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheTrustedTimeSourceAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTrustedTimeSourceWithCompletion:^(MTRTimeSynchronizationClusterTrustedTimeSourceStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the TrustedTimeSource attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the TrustedTimeSource attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("TrustedTimeSource", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_1_1() - : TestCommandBridge("Test_TC_ULABEL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_2_1() - : TestCommandBridge("Test_TC_ULABEL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads LabelList from the DUT\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsLabelListFromTheDut_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsLabelListFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads LabelList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads LabelList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("labelList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_2_2() - : TestCommandBridge("Test_TC_ULABEL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH writes LabelList attribute on the DUT with following entry: 'roomName':'master bedroom 1','orientation':'east', 'floor':'2', 'roomType':'bedroom'\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThWritesLabelListAttributeOnTheDutWithFollowingEntryroomNamemasterBedroom1orientationeastfloor2roomTypebedroom_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads LabelList attribute of the DUT\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsLabelListAttributeOfTheDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThWritesLabelListAttributeOnTheDutWithFollowingEntryroomNamemasterBedroom1orientationeastfloor2roomTypebedroom_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"roomName"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"master bedroom 1"; - - temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"Orientation"; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"east"; - - temp_0[2] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).label = @"floor"; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).value = @"2"; - - temp_0[3] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).label = @"roomType"; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).value = @"bedroom"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes LabelList attribute on the DUT with following entry: 'roomName':'master bedroom 1','orientation':'east', 'floor':'2', 'roomType':'bedroom': Error: %@", err); - } else { - NSLog(@"Step 1: TH writes LabelList attribute on the DUT with following entry: 'roomName':'master bedroom 1','orientation':'east', 'floor':'2', 'roomType':'bedroom': Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsLabelListAttributeOfTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"roomName")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"master bedroom 1")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"Orientation")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"east")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).label, @"floor")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).value, @"2")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).label, @"roomType")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).value, @"bedroom")); - } - - VerifyOrReturn(CheckConstraintType("labelList", "list", "list")); - VerifyOrReturn(CheckConstraintMinLength("labelList", value, 4)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_2_3() - : TestCommandBridge("Test_TC_ULABEL_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH writes LabelList attribute of the DUT by setting 'room':'17_bytesIsTooLong'\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThWritesLabelListAttributeOfTheDutBySettingroom17BytesIsTooLong_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH writes LabelList attribute of the DUT by setting '17_bytesIsTooLong':'foobar'\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThWritesLabelListAttributeOfTheDutBySetting17BytesIsTooLongfoobar_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThWritesLabelListAttributeOfTheDutBySettingroom17BytesIsTooLong_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"17_bytesIsTooLongforuserlabelnotexpected"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes LabelList attribute of the DUT by setting 'room':'17_bytesIsTooLong': Error: %@", err); - } else { - NSLog(@"Step 1: TH writes LabelList attribute of the DUT by setting 'room':'17_bytesIsTooLong': Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThWritesLabelListAttributeOfTheDutBySetting17BytesIsTooLongfoobar_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"17_bytesIsTooLongforuserlabelnotexpected"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"foobar"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH writes LabelList attribute of the DUT by setting '17_bytesIsTooLong':'foobar': Error: %@", err); - } else { - NSLog(@"Step 2: TH writes LabelList attribute of the DUT by setting '17_bytesIsTooLong':'foobar': Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_2_4() - : TestCommandBridge("Test_TC_ULABEL_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH writes LabelList attribute of the DUT with entry as following: 'room':'bedroom 1','orientation':'east' \n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThWritesLabelListAttributeOfTheDutWithEntryAsFollowingroombedroom1orientationeast_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads LabelList attribute of the DUT\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsLabelListAttributeOfTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH writes LabelList attribute of the DUT with an entry as empty values in the list\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep3ThWritesLabelListAttributeOfTheDutWithAnEntryAsEmptyValuesInTheList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads LabelList attribute of the DUT\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsLabelListAttributeOfTheDut_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThWritesLabelListAttributeOfTheDutWithEntryAsFollowingroombedroom1orientationeast_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 1"; - - temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"Orientation"; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"east"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes LabelList attribute of the DUT with entry as following: 'room':'bedroom 1','orientation':'east' : Error: %@", err); - } else { - NSLog(@"Step 1: TH writes LabelList attribute of the DUT with entry as following: 'room':'bedroom 1','orientation':'east' : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsLabelListAttributeOfTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"room")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"bedroom 1")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"Orientation")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"east")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThWritesLabelListAttributeOfTheDutWithAnEntryAsEmptyValuesInTheList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @""; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @""; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH writes LabelList attribute of the DUT with an entry as empty values in the list: Error: %@", err); - } else { - NSLog(@"Step 3: TH writes LabelList attribute of the DUT with an entry as empty values in the list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsLabelListAttributeOfTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads LabelList attribute of the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads LabelList attribute of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGWIFI_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGWIFI_1_1() - : TestCommandBridge("Test_TC_DGWIFI_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGWIFI_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGWIFI_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGWIFI_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip("( !DGWIFI.S.F00 && !DGWIFI.S.F01 )")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGWIFI.S.F00(PacketCounts) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGWIFI.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDGWIFISF00PacketCountsEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DGWIFI.S.F01(ErrorCounts) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGWIFI.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenDGWIFISF01ErrorCountsEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads Feature dependent(DGWIFI.S.F00) attributes in attributeList from DUT\n"); - if (ShouldSkip("DGWIFI.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentDGWIFISF00AttributesInAttributeListFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads Feature dependent(DGWIFI.S.F01) attributes in attributeList from DUT\n"); - if (ShouldSkip("DGWIFI.S.F01")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentDGWIFISF01AttributesInAttributeListFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4d: TH reads optional attribute (CurrentMaxRate) in AttributeList from DUT\n"); - if (ShouldSkip("DGWIFI.S.A000b")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeCurrentMaxRateInAttributeListFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip(" !DGWIFI.S.E00 && !DGWIFI.S.E01 && !DGWIFI.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5b: TH reads optional attribute (Disconnection) in EventList from DUT\n"); - if (ShouldSkip("DGWIFI.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5c: TH reads optional attribute (AssociationFailure) in EventList from DUT\n"); - if (ShouldSkip("DGWIFI.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5d: TH reads optional attribute (ConnectionStatus) in EventList from DUT\n"); - if (ShouldSkip("DGWIFI.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6a: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip(" !DGWIFI.S.F01 ")) { - NextTest(); - return; - } - err = TestStep6aThReadsAcceptedCommandListFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6b: TH reads Feature dependent(DGWIFI.S.F01) command in AcceptedCommandList from DUT\n"); - if (ShouldSkip("DGWIFI.S.F01")) { - NextTest(); - return; - } - err = TestStep6bThReadsFeatureDependentDGWIFISF01CommandInAcceptedCommandListFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDGWIFISF00PacketCountsEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DGWIFI.S.F00(PacketCounts) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DGWIFI.S.F00(PacketCounts) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenDGWIFISF01ErrorCountsEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given DGWIFI.S.F01(ErrorCounts) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given DGWIFI.S.F01(ErrorCounts) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentDGWIFISF00AttributesInAttributeListFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent(DGWIFI.S.F00) attributes in attributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent(DGWIFI.S.F00) attributes in attributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentDGWIFISF01AttributesInAttributeListFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads Feature dependent(DGWIFI.S.F01) attributes in attributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads Feature dependent(DGWIFI.S.F01) attributes in attributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeCurrentMaxRateInAttributeListFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute (CurrentMaxRate) in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute (CurrentMaxRate) in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsAcceptedCommandListFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFeatureDependentDGWIFISF01CommandInAcceptedCommandListFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads Feature dependent(DGWIFI.S.F01) command in AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads Feature dependent(DGWIFI.S.F01) command in AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGWIFI_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGWIFI_2_1() - : TestCommandBridge("Test_TC_DGWIFI_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGWIFI_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGWIFI_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGWIFI_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads BSSID attribute from DUT\n"); - if (ShouldSkip("DGWIFI.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsBssidAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads SecurityType attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsSecurityTypeAttributeConstraints_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads WiFiVersion attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsWiFiVersionAttributeConstraints_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads ChannelNumber attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsChannelNumberAttributeConstraints_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads RSSI attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsRssiAttributeConstraints_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads BeaconLostCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsBeaconLostCountAttributeConstraints_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads BeaconRxCount attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsBeaconRxCountAttributeConstraints_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads PacketMulticastRxCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsPacketMulticastRxCountAttributeConstraints_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads PacketMulticastTxCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsPacketMulticastTxCountAttributeConstraints_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads PacketUnicastRxCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0009")) { - NextTest(); - return; - } - err = TestStep11ThReadsPacketUnicastRxCountAttributeConstraints_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads PacketUnicastTxCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A000a")) { - NextTest(); - return; - } - err = TestStep12ThReadsPacketUnicastTxCountAttributeConstraints_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads CurrentMaxRate attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A000b")) { - NextTest(); - return; - } - err = TestStep13ThReadsCurrentMaxRateAttributeConstraints_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads OverrunCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A000c")) { - NextTest(); - return; - } - err = TestStep14ThReadsOverrunCountAttributeConstraints_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsBssidAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBSSIDWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads BSSID attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads BSSID attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("bssid", "octet_string", "octet_string")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsSecurityTypeAttributeConstraints_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSecurityTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads SecurityType attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads SecurityType attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("securityType", "enum8", "enum8")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsWiFiVersionAttributeConstraints_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiFiVersionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads WiFiVersion attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads WiFiVersion attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("wiFiVersion", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("wiFiVersion", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("wiFiVersion", [value unsignedCharValue], 6U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsChannelNumberAttributeConstraints_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelNumberWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads ChannelNumber attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads ChannelNumber attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("channelNumber", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("channelNumber", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("channelNumber", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsRssiAttributeConstraints_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRSSIWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads RSSI attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads RSSI attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("rssi", "int8s", "int8s")); - VerifyOrReturn(CheckConstraintMinValue("rssi", [value charValue], -120)); - VerifyOrReturn(CheckConstraintMaxValue("rssi", [value charValue], 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsBeaconLostCountAttributeConstraints_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBeaconLostCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads BeaconLostCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads BeaconLostCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("beaconLostCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("beaconLostCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("beaconLostCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsBeaconRxCountAttributeConstraints_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBeaconRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads BeaconRxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads BeaconRxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("beaconRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("beaconRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("beaconRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsPacketMulticastRxCountAttributeConstraints_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketMulticastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads PacketMulticastRxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads PacketMulticastRxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetMulticastRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetMulticastRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetMulticastRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsPacketMulticastTxCountAttributeConstraints_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketMulticastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads PacketMulticastTxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads PacketMulticastTxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetMulticastTxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetMulticastTxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetMulticastTxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsPacketUnicastRxCountAttributeConstraints_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketUnicastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads PacketUnicastRxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads PacketUnicastRxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetUnicastRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetUnicastRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetUnicastRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsPacketUnicastTxCountAttributeConstraints_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketUnicastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads PacketUnicastTxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads PacketUnicastTxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetUnicastTxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetUnicastTxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetUnicastTxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsCurrentMaxRateAttributeConstraints_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentMaxRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads CurrentMaxRate attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads CurrentMaxRate attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentMaxRate", "int64u", "int64u")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsOverrunCountAttributeConstraints_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads OverrunCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads OverrunCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("overrunCount", "int64u", "int64u")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGWIFI_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGWIFI_2_3() - : TestCommandBridge("Test_TC_DGWIFI_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGWIFI_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGWIFI_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGWIFI_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TWait for the commissioned device to be retrieved\n"); - err = TestStep1TWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH sends ResetCounts command to DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsResetCountsCommandToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads BeaconLostCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0005")) { - NextTest(); - return; - } - err = TestStep2aThReadsBeaconLostCountAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH reads BeaconRxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0006")) { - NextTest(); - return; - } - err = TestStep2bThReadsBeaconRxCountAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: TH reads PacketMulticastRxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0007")) { - NextTest(); - return; - } - err = TestStep2cThReadsPacketMulticastRxCountAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2d: TH reads PacketMulticastTxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0008")) { - NextTest(); - return; - } - err = TestStep2dThReadsPacketMulticastTxCountAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2e: TH reads PacketUnicastRxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0009")) { - NextTest(); - return; - } - err = TestStep2eThReadsPacketUnicastRxCountAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2f: TH reads PacketUnicastTxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A000a")) { - NextTest(); - return; - } - err = TestStep2fThReadsPacketUnicastTxCountAttributeFromDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1TWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsResetCountsCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster resetCountsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends ResetCounts command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends ResetCounts command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsBeaconLostCountAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBeaconLostCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads BeaconLostCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads BeaconLostCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("beaconLostCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("beaconLostCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("beaconLostCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsBeaconRxCountAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBeaconRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads BeaconRxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads BeaconRxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("beaconRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("beaconRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("beaconRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsPacketMulticastRxCountAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketMulticastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads PacketMulticastRxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads PacketMulticastRxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetMulticastRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetMulticastRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetMulticastRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThReadsPacketMulticastTxCountAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketMulticastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads PacketMulticastTxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads PacketMulticastTxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetMulticastTxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetMulticastTxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetMulticastTxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThReadsPacketUnicastRxCountAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketUnicastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads PacketUnicastRxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads PacketUnicastRxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetUnicastRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetUnicastRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetUnicastRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThReadsPacketUnicastTxCountAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketUnicastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads PacketUnicastTxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads PacketUnicastTxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetUnicastTxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetUnicastTxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetUnicastTxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_1_1() - : TestCommandBridge("Test_TC_WNCV_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute\n"); - if (ShouldSkip("!WNCV.S.F00 && !WNCV.S.F01 && !WNCV.S.F02 && !WNCV.S.F03 && !WNCV.S.F04 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given WNCV.S.F00(LF) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenWncvsf00lfEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given WNCV.S.F01(TL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenWncvsf01tlEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given WNCV.S.F02(PA_LF) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenWncvsf02paLfEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given WNCV.S.F03(ABS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenWncvsf03absEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given WNCV.S.F04(PA_TL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenWncvsf04paTlEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads optional attribute(SafetyStatus) in AttributeList\n"); - if (ShouldSkip("WNCV.S.A001a")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeSafetyStatusInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 & WNCV.S.F03) attribute in AttributeList\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.F03")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentWNCVSF00Wncvsf02Wncvsf03AttributeInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 ) attribute in AttributeList\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheFeatureDependentWNCVSF00Wncvsf02AttributeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4e: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 & WNCV.S.F03) attribute in AttributeList\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.F03")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheFeatureDependentWNCVSF01Wncvsf04Wncvsf03AttributeInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4f: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 ) attribute in AttributeList\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheFeatureDependentWNCVSF01Wncvsf04AttributeInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5: TH reads from the DUT the (0xFFFA) EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6a: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute\n"); - err = TestStep6aThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6b: TH reads Feature dependent(WNCV.S.F00 & WNCV.S.F02) command in AcceptedCommandList\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep6bThReadsFeatureDependentWNCVSF00Wncvsf02CommandInAcceptedCommandList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6c: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F03) command in AcceptedCommandList\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F03")) { - NextTest(); - return; - } - err = TestStep6cThReadsFeatureDependentWNCVSF01Wncvsf03CommandInAcceptedCommandList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6d: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F04) command in AcceptedCommandList\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep6dThReadsFeatureDependentWNCVSF01Wncvsf04CommandInAcceptedCommandList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 5U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("clusterRevision", [value unsignedShortValue], 5U)); - VerifyOrReturn(CheckConstraintMaxValue("clusterRevision", [value unsignedShortValue], 200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenWncvsf00lfEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given WNCV.S.F00(LF) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given WNCV.S.F00(LF) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenWncvsf01tlEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given WNCV.S.F01(TL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given WNCV.S.F01(TL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenWncvsf02paLfEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given WNCV.S.F02(PA_LF) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given WNCV.S.F02(PA_LF) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenWncvsf03absEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given WNCV.S.F03(ABS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given WNCV.S.F03(ABS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenWncvsf04paTlEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given WNCV.S.F04(PA_TL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given WNCV.S.F04(PA_TL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeSafetyStatusInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(SafetyStatus) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(SafetyStatus) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentWNCVSF00Wncvsf02Wncvsf03AttributeInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 & WNCV.S.F03) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 & WNCV.S.F03) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheFeatureDependentWNCVSF00Wncvsf02AttributeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 ) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 ) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheFeatureDependentWNCVSF01Wncvsf04Wncvsf03AttributeInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 & WNCV.S.F03) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 & WNCV.S.F03) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheFeatureDependentWNCVSF01Wncvsf04AttributeInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 ) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 ) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFeatureDependentWNCVSF00Wncvsf02CommandInAcceptedCommandList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads Feature dependent(WNCV.S.F00 & WNCV.S.F02) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads Feature dependent(WNCV.S.F00 & WNCV.S.F02) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsFeatureDependentWNCVSF01Wncvsf03CommandInAcceptedCommandList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F03) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F03) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsFeatureDependentWNCVSF01Wncvsf04CommandInAcceptedCommandList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F04) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F04) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_2_1() - : TestCommandBridge("Test_TC_WNCV_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads from the DUT the ( 0) Type attribute\n"); - if (ShouldSkip("WNCV.S.A0000")) { - NextTest(); - return; - } - err = TestStep1aThReadsFromTheDutThe0TypeAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads from the DUT the ( 7) ConfigStatus attribute\n"); - if (ShouldSkip("WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep1bThReadsFromTheDutThe7ConfigStatusAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH reads from the DUT the (10) OperationalStatus attribute: OperationalStatus\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep1cThReadsFromTheDutThe10OperationalStatusAttributeOperationalStatus_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH reads from the DUT the (13) EndProductType attribute\n"); - if (ShouldSkip("WNCV.S.A000d")) { - NextTest(); - return; - } - err = TestStep1dThReadsFromTheDutThe13EndProductTypeAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH reads from the DUT the (23) Mode attribute\n"); - if (ShouldSkip("WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep1eThReadsFromTheDutThe23ModeAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: TH writes to (23) Mode attribute the value 0\n"); - if (ShouldSkip("WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep1fThWritesTo23ModeAttributeTheValue0_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH reads from the DUT the (11) TargetPositionLiftPercent100ths attribute\n"); - if (ShouldSkip("WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep2aThReadsFromTheDutThe11TargetPositionLiftPercent100thsAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH reads from the DUT the (12) TargetPositionTiltPercent100ths attribute\n"); - if (ShouldSkip("WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep2bThReadsFromTheDutThe12TargetPositionTiltPercent100thsAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2c: TH reads from the DUT the (14) CurrentPositionLiftPercent100ths attribute\n"); - if (ShouldSkip("WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep2cThReadsFromTheDutThe14CurrentPositionLiftPercent100thsAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2d: TH reads from the DUT the (15) CurrentPositionTiltPercent100ths attribute\n"); - if (ShouldSkip("WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep2dThReadsFromTheDutThe15CurrentPositionTiltPercent100thsAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads from the DUT the (16) InstalledOpenLimitLift attribute\n"); - if (ShouldSkip("WNCV.S.A0010")) { - NextTest(); - return; - } - err = TestStep2eThReadsFromTheDutThe16InstalledOpenLimitLiftAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2f: TH reads from the DUT the (17) InstalledClosedLimitLift attribute\n"); - if (ShouldSkip("WNCV.S.A0011")) { - NextTest(); - return; - } - err = TestStep2fThReadsFromTheDutThe17InstalledClosedLimitLiftAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2g: TH reads from the DUT the (18) InstalledOpenLimitTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0012")) { - NextTest(); - return; - } - err = TestStep2gThReadsFromTheDutThe18InstalledOpenLimitTiltAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2h: TH reads from the DUT the (19) InstalledClosedLimitTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0013")) { - NextTest(); - return; - } - err = TestStep2hThReadsFromTheDutThe19InstalledClosedLimitTiltAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH reads from the DUT the (26) SafetyStatus attribute\n"); - if (ShouldSkip("WNCV.S.A001a")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutThe26SafetyStatusAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3b: TH reads from the DUT the ( 1) PhysicalClosedLimitLift attribute\n"); - if (ShouldSkip("WNCV.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutThe1PhysicalClosedLimitLiftAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3c: TH reads from the DUT the ( 2) PhysicalClosedLimitTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0002")) { - NextTest(); - return; - } - err = TestStep3cThReadsFromTheDutThe2PhysicalClosedLimitTiltAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3d: TH reads from the DUT the ( 3) CurrentPositionLift attribute\n"); - if (ShouldSkip("WNCV.S.A0003 && !WNCV.S.A0010 && !WNCV.S.A0011")) { - NextTest(); - return; - } - err = TestStep3dThReadsFromTheDutThe3CurrentPositionLiftAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3d: TH reads the RO optional attribute default: CurrentPositionLift\n"); - if (ShouldSkip("WNCV.S.A0003 && WNCV.S.A0010 && WNCV.S.A0011")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheRoOptionalAttributeDefaultCurrentPositionLift_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3e: TH reads from the DUT the ( 4) CurrentPositionTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0004 && !WNCV.S.A0012 && !WNCV.S.A0013")) { - NextTest(); - return; - } - err = TestStep3eThReadsFromTheDutThe4CurrentPositionTiltAttribute_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3e: TH reads the RO optional attribute default: CurrentPositionTilt\n"); - if (ShouldSkip("WNCV.S.A0004 && WNCV.S.A0012 && WNCV.S.A0013")) { - NextTest(); - return; - } - err = TestStep3eThReadsTheRoOptionalAttributeDefaultCurrentPositionTilt_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 3f: TH reads from the DUT the ( 5) NumberOfActuationsLift attribute\n"); - if (ShouldSkip("WNCV.S.A0005")) { - NextTest(); - return; - } - err = TestStep3fThReadsFromTheDutThe5NumberOfActuationsLiftAttribute_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3g: TH reads from the DUT the ( 6) NumberOfActuationsTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0006")) { - NextTest(); - return; - } - err = TestStep3gThReadsFromTheDutThe6NumberOfActuationsTiltAttribute_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3h: TH reads from the DUT the ( 8) CurrentPositionLiftPercentage attribute\n"); - if (ShouldSkip("WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3hThReadsFromTheDutThe8CurrentPositionLiftPercentageAttribute_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 3i: TH reads from the DUT the ( 9) CurrentPositionTiltPercentage attribute\n"); - if (ShouldSkip("WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3iThReadsFromTheDutThe9CurrentPositionTiltPercentageAttribute_25(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 26; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThReadsFromTheDutThe0TypeAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads from the DUT the ( 0) Type attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads from the DUT the ( 0) Type attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("type", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("type", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("type", [value unsignedCharValue], 9U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsFromTheDutThe7ConfigStatusAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads from the DUT the ( 7) ConfigStatus attribute: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads from the DUT the ( 7) ConfigStatus attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsFromTheDutThe10OperationalStatusAttributeOperationalStatus_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads from the DUT the (10) OperationalStatus attribute: OperationalStatus: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads from the DUT the (10) OperationalStatus attribute: OperationalStatus: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("operationalStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("operationalStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThReadsFromTheDutThe13EndProductTypeAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEndProductTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads from the DUT the (13) EndProductType attribute: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads from the DUT the (13) EndProductType attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("endProductType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("endProductType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("endProductType", [value unsignedCharValue], 23U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eThReadsFromTheDutThe23ModeAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH reads from the DUT the (23) Mode attribute: Error: %@", err); - } else { - NSLog(@"Step 1e: TH reads from the DUT the (23) Mode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("mode", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("mode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("mode", [value unsignedCharValue], 15U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fThWritesTo23ModeAttributeTheValue0_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1f: TH writes to (23) Mode attribute the value 0: Error: %@", err); - } else { - NSLog(@"Step 1f: TH writes to (23) Mode attribute the value 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsFromTheDutThe11TargetPositionLiftPercent100thsAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads from the DUT the (11) TargetPositionLiftPercent100ths attribute: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads from the DUT the (11) TargetPositionLiftPercent100ths attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsFromTheDutThe12TargetPositionTiltPercent100thsAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads from the DUT the (12) TargetPositionTiltPercent100ths attribute: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads from the DUT the (12) TargetPositionTiltPercent100ths attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsFromTheDutThe14CurrentPositionLiftPercent100thsAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads from the DUT the (14) CurrentPositionLiftPercent100ths attribute: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads from the DUT the (14) CurrentPositionLiftPercent100ths attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThReadsFromTheDutThe15CurrentPositionTiltPercent100thsAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads from the DUT the (15) CurrentPositionTiltPercent100ths attribute: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads from the DUT the (15) CurrentPositionTiltPercent100ths attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull InstalledOpenLimitLiftValue; - - CHIP_ERROR TestStep2eThReadsFromTheDutThe16InstalledOpenLimitLiftAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInstalledOpenLimitLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads from the DUT the (16) InstalledOpenLimitLift attribute: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads from the DUT the (16) InstalledOpenLimitLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("installedOpenLimitLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("installedOpenLimitLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("installedOpenLimitLift", [value unsignedShortValue], 65535U)); - { - InstalledOpenLimitLiftValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull InstalledClosedLimitLiftValue; - - CHIP_ERROR TestStep2fThReadsFromTheDutThe17InstalledClosedLimitLiftAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInstalledClosedLimitLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads from the DUT the (17) InstalledClosedLimitLift attribute: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads from the DUT the (17) InstalledClosedLimitLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("installedClosedLimitLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("installedClosedLimitLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("installedClosedLimitLift", [value unsignedShortValue], 65535U)); - { - InstalledClosedLimitLiftValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull InstalledOpenLimitTiltValue; - - CHIP_ERROR TestStep2gThReadsFromTheDutThe18InstalledOpenLimitTiltAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInstalledOpenLimitTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH reads from the DUT the (18) InstalledOpenLimitTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 2g: TH reads from the DUT the (18) InstalledOpenLimitTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("installedOpenLimitTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("installedOpenLimitTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("installedOpenLimitTilt", [value unsignedShortValue], 65535U)); - { - InstalledOpenLimitTiltValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull InstalledClosedLimitTiltValue; - - CHIP_ERROR TestStep2hThReadsFromTheDutThe19InstalledClosedLimitTiltAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInstalledClosedLimitTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2h: TH reads from the DUT the (19) InstalledClosedLimitTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 2h: TH reads from the DUT the (19) InstalledClosedLimitTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("installedClosedLimitTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("installedClosedLimitTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("installedClosedLimitTilt", [value unsignedShortValue], 65535U)); - { - InstalledClosedLimitTiltValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutThe26SafetyStatusAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSafetyStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the (26) SafetyStatus attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the (26) SafetyStatus attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("safetyStatus", "bitmap16", "bitmap16")); - VerifyOrReturn(CheckConstraintMinValue("safetyStatus", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("safetyStatus", [value unsignedShortValue], 2047U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutThe1PhysicalClosedLimitLiftAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalClosedLimitLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the ( 1) PhysicalClosedLimitLift attribute: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the ( 1) PhysicalClosedLimitLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalClosedLimitLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("physicalClosedLimitLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalClosedLimitLift", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsFromTheDutThe2PhysicalClosedLimitTiltAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalClosedLimitTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads from the DUT the ( 2) PhysicalClosedLimitTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads from the DUT the ( 2) PhysicalClosedLimitTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalClosedLimitTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("physicalClosedLimitTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalClosedLimitTilt", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsFromTheDutThe3CurrentPositionLiftAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads from the DUT the ( 3) CurrentPositionLift attribute: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads from the DUT the ( 3) CurrentPositionLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLift", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsTheRoOptionalAttributeDefaultCurrentPositionLift_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the RO optional attribute default: CurrentPositionLift: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the RO optional attribute default: CurrentPositionLift: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLift", [value unsignedShortValue], InstalledOpenLimitLiftValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLift", [value unsignedShortValue], InstalledClosedLimitLiftValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThReadsFromTheDutThe4CurrentPositionTiltAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads from the DUT the ( 4) CurrentPositionTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads from the DUT the ( 4) CurrentPositionTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTilt", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThReadsTheRoOptionalAttributeDefaultCurrentPositionTilt_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads the RO optional attribute default: CurrentPositionTilt: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads the RO optional attribute default: CurrentPositionTilt: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTilt", [value unsignedShortValue], InstalledOpenLimitTiltValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTilt", [value unsignedShortValue], InstalledClosedLimitTiltValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsFromTheDutThe5NumberOfActuationsLiftAttribute_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfActuationsLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads from the DUT the ( 5) NumberOfActuationsLift attribute: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads from the DUT the ( 5) NumberOfActuationsLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("numberOfActuationsLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("numberOfActuationsLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfActuationsLift", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gThReadsFromTheDutThe6NumberOfActuationsTiltAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfActuationsTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH reads from the DUT the ( 6) NumberOfActuationsTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 3g: TH reads from the DUT the ( 6) NumberOfActuationsTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("numberOfActuationsTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("numberOfActuationsTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfActuationsTilt", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hThReadsFromTheDutThe8CurrentPositionLiftPercentageAttribute_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: TH reads from the DUT the ( 8) CurrentPositionLiftPercentage attribute: Error: %@", err); - } else { - NSLog(@"Step 3h: TH reads from the DUT the ( 8) CurrentPositionLiftPercentage attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iThReadsFromTheDutThe9CurrentPositionTiltPercentageAttribute_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: TH reads from the DUT the ( 9) CurrentPositionTiltPercentage attribute: Error: %@", err); - } else { - NSLog(@"Step 3i: TH reads from the DUT the ( 9) CurrentPositionTiltPercentage attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_2_2() - : TestCommandBridge("Test_TC_WNCV_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b\n"); - if (ShouldSkip("WNCV.S.A0007 && WNCV.S.F00 && WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep1aThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b\n"); - if (ShouldSkip("WNCV.S.A0007 && !WNCV.S.F00 && !WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep1bThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,\n"); - if (ShouldSkip("WNCV.S.A0007 && WNCV.S.F01 && WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep1cThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,\n"); - if (ShouldSkip("WNCV.S.A0007 && !WNCV.S.F01 && !WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep1dThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH reads ConfigStatus attribute from DUT, value of bit 0 must be 1b (operational)\n"); - if (ShouldSkip("WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep1eThReadsConfigStatusAttributeFromDutValueOfBit0MustBe1bOperational_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eThReadsConfigStatusAttributeFromDutValueOfBit0MustBe1bOperational_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH reads ConfigStatus attribute from DUT, value of bit 0 must be 1b (operational): Error: %@", err); - } else { - NSLog(@"Step 1e: TH reads ConfigStatus attribute from DUT, value of bit 0 must be 1b (operational): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_2_3() - : TestCommandBridge("Test_TC_WNCV_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step Wait for the commissioned device to be retrieved\n"); - err = TestStepWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH set the Mode Attribute bit0 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep1aThSetTheModeAttributeBit0OfTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep1bThReadsConfigStatusAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH clear the Mode Attribute bit0 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep1cThClearTheModeAttributeBit0OfTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep1dThReadsConfigStatusAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a: TH set the Mode Attribute bit1 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep2aThSetTheModeAttributeBit1OfTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep2bThReadsConfigStatusAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: If (ConfigStatus bit0 == 0) TH send DownOrClose command to the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2cIfConfigStatusBit00ThSendDownOrCloseCommandToTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2d: TH clear the Mode Attribute bit1 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep2dThClearTheModeAttributeBit1OfTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2e: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep2eThReadsConfigStatusAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2f: TH reads the Mode Attribute from the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep2fThReadsTheModeAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2g: TH send DownOrClose command to the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2gThSendDownOrCloseCommandToTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH set the Mode Attribute bit2 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep3aThSetTheModeAttributeBit2OfTheDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3b: TH send DownOrClose command to the DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendDownOrCloseCommandToTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3c: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep3cThReadsConfigStatusAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH clear the Mode Attribute bit2 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep3dThClearTheModeAttributeBit2OfTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3e: TH send DownOrClose command to the DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3eThSendDownOrCloseCommandToTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3f: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep3fThReadsConfigStatusAttributeFromDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_BUSY)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStepWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSetTheModeAttributeBit0OfTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH set the Mode Attribute bit0 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH set the Mode Attribute bit0 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsConfigStatusAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 4U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThClearTheModeAttributeBit0OfTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH clear the Mode Attribute bit0 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: TH clear the Mode Attribute bit0 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThReadsConfigStatusAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSetTheModeAttributeBit1OfTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH set the Mode Attribute bit1 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH set the Mode Attribute bit1 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull configStatusValA; - - CHIP_ERROR TestStep2bThReadsConfigStatusAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - { - configStatusValA = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cIfConfigStatusBit00ThSendDownOrCloseCommandToTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (ConfigStatus bit0 == 0) TH send DownOrClose command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (ConfigStatus bit0 == 0) TH send DownOrClose command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThClearTheModeAttributeBit1OfTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH clear the Mode Attribute bit1 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH clear the Mode Attribute bit1 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThReadsConfigStatusAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThReadsTheModeAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads the Mode Attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads the Mode Attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("mode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("mode", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2gThSendDownOrCloseCommandToTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH send DownOrClose command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2g: TH send DownOrClose command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSetTheModeAttributeBit2OfTheDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:4U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH set the Mode Attribute bit2 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH set the Mode Attribute bit2 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendDownOrCloseCommandToTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH send DownOrClose command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH send DownOrClose command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_BUSY)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull configStatusValB; - - CHIP_ERROR TestStep3cThReadsConfigStatusAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - { - configStatusValB = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThClearTheModeAttributeBit2OfTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH clear the Mode Attribute bit2 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH clear the Mode Attribute bit2 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThSendDownOrCloseCommandToTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH send DownOrClose command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH send DownOrClose command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsConfigStatusAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_2_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_2_5() - : TestCommandBridge("Test_TC_WNCV_2_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_2_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads EndProductType attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000d")) { - NextTest(); - return; - } - err = TestStep1ThReadsEndProductTypeAttributeFromDut_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsEndProductTypeAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEndProductTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads EndProductType attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads EndProductType attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("endProductType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("endProductType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("endProductType", [value unsignedCharValue], 23U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_1() - : TestCommandBridge("Test_TC_WNCV_3_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Step1bWaitTime", 0, UINT16_MAX, &mStep1bWaitTime); - AddArgument("Step2bWaitTime", 0, UINT16_MAX, &mStep2bWaitTime); - AddArgument("Step2eWaitTime", 0, UINT16_MAX, &mStep2eWaitTime); - AddArgument("Step4bWaitTime", 0, UINT16_MAX, &mStep4bWaitTime); - AddArgument("Step5aWaitTime", 0, UINT16_MAX, &mStep5aWaitTime); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH Waits for 5 - 15 seconds movement(s) on the device\n"); - err = TestStep1bThWaitsFor515SecondsMovementsOnTheDevice_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH sends UpOrOpen command to DUT\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsUpOrOpenCommandToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH waits for 100-1000 ms\n"); - err = TestStep2bThWaitsFor1001000Ms_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH waits for 1-5 seconds movement(s) on the DUT\n"); - err = TestStep2eThWaitsFor15SecondsMovementsOnTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep3aThReadsOperationalStatusAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3a: DUT updates its attributes\n"); - err = TestStep3aDutUpdatesItsAttributes_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4a: TH sends a StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAStopMotionCommandToDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4b: TH waits for 1-5 seconds end of motion(s) on the DUT\n"); - err = TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4c: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep4cThReadsOperationalStatusAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5a: TH waits for 100-1000 ms\n"); - err = TestStep5aThWaitsFor1001000Ms_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mStep1bWaitTime; - chip::Optional mStep2bWaitTime; - chip::Optional mStep2eWaitTime; - chip::Optional mStep4bWaitTime; - chip::Optional mStep5aWaitTime; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor515SecondsMovementsOnTheDevice_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep1bWaitTime.HasValue() ? mStep1bWaitTime.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsUpOrOpenCommandToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor1001000Ms_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep2bWaitTime.HasValue() ? mStep2bWaitTime.Value() : 200UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThWaitsFor15SecondsMovementsOnTheDut_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep2eWaitTime.HasValue() ? mStep2eWaitTime.Value() : 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3aThReadsOperationalStatusAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aDutUpdatesItsAttributes_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 3000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 99U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 99U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAStopMotionCommandToDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep4bWaitTime.HasValue() ? mStep4bWaitTime.Value() : 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cThReadsOperationalStatusAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWaitsFor1001000Ms_21() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep5aWaitTime.HasValue() ? mStep5aWaitTime.Value() : 500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_2() - : TestCommandBridge("Test_TC_WNCV_3_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Step1bWaitTime", 0, UINT16_MAX, &mStep1bWaitTime); - AddArgument("Step2bWaitTime", 0, UINT16_MAX, &mStep2bWaitTime); - AddArgument("Step2eWaitTime", 0, UINT16_MAX, &mStep2eWaitTime); - AddArgument("Step4bWaitTime", 0, UINT16_MAX, &mStep4bWaitTime); - AddArgument("Step5aWaitTime", 0, UINT16_MAX, &mStep5aWaitTime); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH Waits for 10 seconds movement(s) on the device\n"); - err = TestStep1bThWaitsFor10SecondsMovementsOnTheDevice_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH sends DownOrClose command to DUT\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsDownOrCloseCommandToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH waits for 100-1000 ms\n"); - err = TestStep2bThWaitsFor1001000Ms_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH leave the device moving for 2 seconds\n"); - err = TestStep2eThLeaveTheDeviceMovingFor2Seconds_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep3aThReadsOperationalStatusAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3a: DUT updates its attributes\n"); - err = TestStep3aDutUpdatesItsAttributes_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4a: TH sends a StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAStopMotionCommandToDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4b: TH waits for 1-5 seconds end of motion(s) on the DUT\n"); - err = TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4c: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep4cThReadsOperationalStatusAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5a: TH waits for 100-1000 ms\n"); - err = TestStep5aThWaitsFor1001000Ms_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mStep1bWaitTime; - chip::Optional mStep2bWaitTime; - chip::Optional mStep2eWaitTime; - chip::Optional mStep4bWaitTime; - chip::Optional mStep5aWaitTime; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor10SecondsMovementsOnTheDevice_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep1bWaitTime.HasValue() ? mStep1bWaitTime.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 99U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 99U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsDownOrCloseCommandToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor1001000Ms_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep2bWaitTime.HasValue() ? mStep2bWaitTime.Value() : 200UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThLeaveTheDeviceMovingFor2Seconds_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep2eWaitTime.HasValue() ? mStep2eWaitTime.Value() : 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3aThReadsOperationalStatusAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aDutUpdatesItsAttributes_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 3000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAStopMotionCommandToDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep4bWaitTime.HasValue() ? mStep4bWaitTime.Value() : 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cThReadsOperationalStatusAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWaitsFor1001000Ms_21() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep5aWaitTime.HasValue() ? mStep5aWaitTime.Value() : 200UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_3() - : TestCommandBridge("Test_TC_WNCV_3_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for 6-8 seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsFor68SecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1cThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH waits for 1-5 seconds revert motion(s) on the DUT\n"); - err = TestStep1dThWaitsFor15SecondsRevertMotionsOnTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep1eThReadsOperationalStatusAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: TH waits for 2 seconds\n"); - err = TestStep1fThWaitsFor2Seconds_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Report: Step 2: Subscribe to DUT reports on OperationalStatus attribute\n"); - err = TestReportStep2SubscribeToDutReportsOnOperationalStatusAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2: Subscribe to DUT reports on OperationalStatus attribute\n"); - err = TestStep2SubscribeToDutReportsOnOperationalStatusAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a: TH sends a StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsAStopMotionCommandToDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2b: TH waits for 1-5 seconds end of motion(s) on the DUT\n"); - err = TestStep2bThWaitsFor15SecondsEndOfMotionsOnTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2c: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep2cThReadsOperationalStatusAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2d: TH waits for 100ms - 3s attributes update on the device\n"); - err = TestStep2dThWaitsFor100ms3sAttributesUpdateOnTheDevice_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2e: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep2eThReadsOperationalStatusAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsTargetPositionLiftPercent100thsAttribute3cItMustBeEqualWithCurrentPositionLiftPercent100thsFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep4aIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000c && WNCV.S.A000f && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4bIfPaTlThReadsTargetPositionTiltPercent100thsAttribute4cItMustBeEqualWithCurrentPositionTiltPercent100thsFromDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor68SecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThWaitsFor15SecondsRevertMotionsOnTheDut_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1eThReadsOperationalStatusAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1e: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("operationalStatus", value, 0U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fThWaitsFor2Seconds_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - bool testSendClusterTest_TC_WNCV_3_3_7_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_Test_TC_WNCV_3_3_OperationalStatus_Reported - = nil; - - CHIP_ERROR TestReportStep2SubscribeToDutReportsOnOperationalStatusAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_Test_TC_WNCV_3_3_OperationalStatus_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Step 2: Subscribe to DUT reports on OperationalStatus attribute: Error: %@", err); - } else { - NSLog(@"Report: Step 2: Subscribe to DUT reports on OperationalStatus attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); - testSendClusterTest_TC_WNCV_3_3_7_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2SubscribeToDutReportsOnOperationalStatusAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 4U; - uint16_t maxIntervalArgument = 5U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeOperationalStatusWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTest_TC_WNCV_3_3_7_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Subscribe to DUT reports on OperationalStatus attribute: Error: %@", err); - } else { - NSLog(@"Step 2: Subscribe to DUT reports on OperationalStatus attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_Test_TC_WNCV_3_3_OperationalStatus_Reported - != nil) { - ResponseHandler callback = test_Test_TC_WNCV_3_3_OperationalStatus_Reported; - test_Test_TC_WNCV_3_3_OperationalStatus_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsAStopMotionCommandToDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends a StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends a StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor15SecondsEndOfMotionsOnTheDut_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 3000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsOperationalStatusAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThWaitsFor100ms3sAttributesUpdateOnTheDevice_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsOperationalStatusAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable attrCurrentPositionLift; - - CHIP_ERROR TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - { - attrCurrentPositionLift = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bIfPaLfThReadsTargetPositionLiftPercent100thsAttribute3cItMustBeEqualWithCurrentPositionLiftPercent100thsFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (attrCurrentPositionLift == nil) { - VerifyOrReturn(CheckValueNull("TargetPositionLiftPercent100ths", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, attrCurrentPositionLift)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable attrCurrentPositionTilt; - - CHIP_ERROR TestStep4aIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - { - attrCurrentPositionTilt = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bIfPaTlThReadsTargetPositionTiltPercent100thsAttribute4cItMustBeEqualWithCurrentPositionTiltPercent100thsFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (attrCurrentPositionTilt == nil) { - VerifyOrReturn(CheckValueNull("TargetPositionTiltPercent100ths", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, attrCurrentPositionTilt)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_4() - : TestCommandBridge("Test_TC_WNCV_3_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("fastMotionDuration", 0, UINT16_MAX, &mFastMotionDuration); - AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for 5-15 seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends UpOrOpen command to DUT\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsUpOrOpenCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2b: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2c: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep2cThChecksOperationalStatusAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mFastMotionDuration; - chip::Optional mFullMotionDuration; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFastMotionDuration.HasValue() ? mFastMotionDuration.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsUpOrOpenCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThChecksOperationalStatusAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_5() - : TestCommandBridge("Test_TC_WNCV_3_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("fastMotionDuration", 0, UINT16_MAX, &mFastMotionDuration); - AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends UpOrOpen command to DUT\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsUpOrOpenCommandToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for 5-15 seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends DownOrClose command to DUT\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsDownOrCloseCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2b: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2c: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep2cThChecksOperationalStatusAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mFastMotionDuration; - chip::Optional mFullMotionDuration; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsUpOrOpenCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends UpOrOpen command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends UpOrOpen command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFastMotionDuration.HasValue() ? mFastMotionDuration.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsDownOrCloseCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThChecksOperationalStatusAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_1() - : TestCommandBridge("Test_TC_WNCV_4_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for x seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsForXSecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends GoToLiftPercentage command with 25 percent to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsGoToLiftPercentageCommandWith25PercentToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH waits for 100-1000 ms\n"); - err = TestStep2bThWaitsFor1001000Ms_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep3bThChecksOperationalStatusAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH sends GoToLiftPercentage command with 75.20 percent to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsGoToLiftPercentageCommandWith7520PercentToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: TH waits for 100-1000 ms\n"); - err = TestStep4bThWaitsFor1001000Ms_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep4cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5b: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep5bThChecksOperationalStatusAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep5cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep5dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mFullMotionDuration; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsForXSecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("currentPositionLiftPercent100ths", value, 0U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsGoToLiftPercentageCommandWith25PercentToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:2500U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends GoToLiftPercentage command with 25 percent to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends GoToLiftPercentage command with 25 percent to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor1001000Ms_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 2500U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThChecksOperationalStatusAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 2500U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 25U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsGoToLiftPercentageCommandWith7520PercentToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:7520U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 75.20 percent to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 75.20 percent to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWaitsFor1001000Ms_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 7520U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bThChecksOperationalStatusAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 7520U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 75U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_2() - : TestCommandBridge("Test_TC_WNCV_4_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for x seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsForXSecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep1cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends GoToTiltPercentage command with 30 percent to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsGoToTiltPercentageCommandWith30PercentToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH waits for 100-1000 ms\n"); - err = TestStep2bThWaitsFor1001000Ms_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep2cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep3bThChecksOperationalStatusAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH sends GoToTiltPercentage command with 60.05 percent to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsGoToTiltPercentageCommandWith6005PercentToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: TH waits for 100-1000 ms\n"); - err = TestStep4bThWaitsFor1001000Ms_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep4cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5b: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep5bThReadsOperationalStatusAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep5cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep5dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mFullMotionDuration; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsForXSecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("currentPositionTiltPercent100ths", value, 0U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsGoToTiltPercentageCommandWith30PercentToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:3000U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends GoToTiltPercentage command with 30 percent to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends GoToTiltPercentage command with 30 percent to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor1001000Ms_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 3000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThChecksOperationalStatusAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 3000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 30U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsGoToTiltPercentageCommandWith6005PercentToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:6005U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 60.05 percent to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 60.05 percent to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWaitsFor1001000Ms_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 6005U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bThReadsOperationalStatusAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 6005U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 60U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_3() - : TestCommandBridge("Test_TC_WNCV_4_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: If (PA_LF & LF) TH reads CurrentPositionLiftPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1aIfPaLfLfThReadsCurrentPositionLiftPercent100thsFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT + assert CurrentPositionLiftPercent100ths/100 equals CurrentPositionLiftPercentage\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1b1cIfPaLfLfThReadsCurrentPositionLiftPercentageFromDutAssertCurrentPositionLiftPercent100ths100EqualsCurrentPositionLiftPercentage_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH sends GoToLiftPercentage command with BadParam to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 || WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsGoToLiftPercentageCommandWithBadParamToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH sends GoToLiftPercentage command with 10001 to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 || WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsGoToLiftPercentageCommandWith10001ToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 || WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsGoToLiftPercentageCommandWith0xFFFFToDut_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable attrCurrentPositionLiftPercent100ths; - - CHIP_ERROR TestStep1aIfPaLfLfThReadsCurrentPositionLiftPercent100thsFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: If (PA_LF & LF) TH reads CurrentPositionLiftPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: If (PA_LF & LF) TH reads CurrentPositionLiftPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - { - attrCurrentPositionLiftPercent100ths = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1b1cIfPaLfLfThReadsCurrentPositionLiftPercentageFromDutAssertCurrentPositionLiftPercent100ths100EqualsCurrentPositionLiftPercentage_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT + assert CurrentPositionLiftPercent100ths/100 equals CurrentPositionLiftPercentage: Error: %@", err); - } else { - NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT + assert CurrentPositionLiftPercent100ths/100 equals CurrentPositionLiftPercentage: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, [attrCurrentPositionLiftPercent100ths unsignedShortValue] / 100U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsGoToLiftPercentageCommandWithBadParamToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:12288U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends GoToLiftPercentage command with BadParam to DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends GoToLiftPercentage command with BadParam to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsGoToLiftPercentageCommandWith10001ToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:10001U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends GoToLiftPercentage command with 10001 to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends GoToLiftPercentage command with 10001 to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsGoToLiftPercentageCommandWith0xFFFFToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_4() - : TestCommandBridge("Test_TC_WNCV_4_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: If (PA_TL & TL) TH reads CurrentPositionTiltPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aIfPaTlTlThReadsCurrentPositionTiltPercent100thsFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionTiltPercentage from DUT + assert CurrentPositionTiltPercent100ths/100 equals CurrentPositionTiltPercentage\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep1b1cIfPaLfLfThReadsCurrentPositionTiltPercentageFromDutAssertCurrentPositionTiltPercent100ths100EqualsCurrentPositionTiltPercentage_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH sends GoToTiltPercentage command with BadParam to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 || WNCV.S.F01 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsGoToTiltPercentageCommandWithBadParamToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH sends GoToTiltPercentage command with 10001 to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 || WNCV.S.F01 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsGoToTiltPercentageCommandWith10001ToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH sends GoToTiltPercentage command with 0xFFFF to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 || WNCV.S.F01 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsGoToTiltPercentageCommandWith0xFFFFToDut_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable attrCurrentPositionTiltPercent100ths; - - CHIP_ERROR TestStep1aIfPaTlTlThReadsCurrentPositionTiltPercent100thsFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: If (PA_TL & TL) TH reads CurrentPositionTiltPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: If (PA_TL & TL) TH reads CurrentPositionTiltPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - { - attrCurrentPositionTiltPercent100ths = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1b1cIfPaLfLfThReadsCurrentPositionTiltPercentageFromDutAssertCurrentPositionTiltPercent100ths100EqualsCurrentPositionTiltPercentage_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionTiltPercentage from DUT + assert CurrentPositionTiltPercent100ths/100 equals CurrentPositionTiltPercentage: Error: %@", err); - } else { - NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionTiltPercentage from DUT + assert CurrentPositionTiltPercent100ths/100 equals CurrentPositionTiltPercentage: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, [attrCurrentPositionTiltPercent100ths unsignedShortValue] / 100U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsGoToTiltPercentageCommandWithBadParamToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:12288U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends GoToTiltPercentage command with BadParam to DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends GoToTiltPercentage command with BadParam to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsGoToTiltPercentageCommandWith10001ToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:10001U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends GoToTiltPercentage command with 10001 to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends GoToTiltPercentage command with 10001 to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsGoToTiltPercentageCommandWith0xFFFFToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 0xFFFF to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 0xFFFF to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_5() - : TestCommandBridge("Test_TC_WNCV_4_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0a: Wait for the commissioned device to be retrieved\n"); - err = TestStep0aWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0b: TH sends UpOrOpen command to preposition the DUT\n"); - err = TestStep0bThSendsUpOrOpenCommandToPrepositionTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1a: If (PA_LF & LF) TH sends GoToLiftPercentage command with 90%% to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep1aIfPaLfLfThSendsGoToLiftPercentageCommandWith90ToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1b: TH Waits for 100ms-1s\n"); - err = TestStep1bThWaitsFor100ms1s_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1c: TH sends StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep1cThSendsStopMotionCommandToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1d: TH Waits for 100ms-1s\n"); - err = TestStep1dThWaitsFor100ms1s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: If (PA_TL & TL) TH sends GoToTiltPercentage command with 90%% to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2aIfPaTlTlThSendsGoToTiltPercentageCommandWith90ToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH Waits for 100ms-1s\n"); - err = TestStep2bThWaitsFor100ms1s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2c: TH sends StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThSendsStopMotionCommandToDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH Waits for 100ms-1s\n"); - err = TestStep2dThWaitsFor100ms1s_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3a: TH reads CurrentPositionLiftPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3aThReadsCurrentPositionLiftPercent100thsFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: TH reads CurrentPositionTiltPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentPositionTiltPercent100thsFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: reboot/restart the DUT\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep3cRebootRestartTheDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStepRebootTargetDeviceDUT_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3d: Wait for the commissioned device to be retrieved\n"); - err = TestStep3dWaitForTheCommissionedDeviceToBeRetrieved_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3e: TH reads CurrentPositionLiftPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3eThReadsCurrentPositionLiftPercent100thsFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3f: TH reads CurrentPositionTiltPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3fThReadsCurrentPositionTiltPercent100thsFromDut_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0aWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0bThSendsUpOrOpenCommandToPrepositionTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends UpOrOpen command to preposition the DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends UpOrOpen command to preposition the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aIfPaLfLfThSendsGoToLiftPercentageCommandWith90ToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:9000U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: If (PA_LF & LF) TH sends GoToLiftPercentage command with 90%% to DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: If (PA_LF & LF) TH sends GoToLiftPercentage command with 90%% to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor100ms1s_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cThSendsStopMotionCommandToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH sends StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: TH sends StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThWaitsFor100ms1s_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2aIfPaTlTlThSendsGoToTiltPercentageCommandWith90ToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:9000U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: If (PA_TL & TL) TH sends GoToTiltPercentage command with 90%% to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: If (PA_TL & TL) TH sends GoToTiltPercentage command with 90%% to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor100ms1s_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThSendsStopMotionCommandToDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH sends StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH sends StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThWaitsFor100ms1s_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 500UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nullable attrCurrentPositionLiftPercent100ths; - - CHIP_ERROR TestStep3aThReadsCurrentPositionLiftPercent100thsFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads CurrentPositionLiftPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads CurrentPositionLiftPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("currentPositionLiftPercent100ths", value, 0U)); - { - attrCurrentPositionLiftPercent100ths = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable attrCurrentPositionTiltPercent100ths; - - CHIP_ERROR TestStep3bThReadsCurrentPositionTiltPercent100thsFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentPositionTiltPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentPositionTiltPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("currentPositionTiltPercent100ths", value, 0U)); - { - attrCurrentPositionTiltPercent100ths = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cRebootRestartTheDut_12() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStepRebootTargetDeviceDUT_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3dWaitForTheCommissionedDeviceToBeRetrieved_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep3eThReadsCurrentPositionLiftPercent100thsFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads CurrentPositionLiftPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads CurrentPositionLiftPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (attrCurrentPositionLiftPercent100ths == nil) { - VerifyOrReturn(CheckValueNull("CurrentPositionLiftPercent100ths", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, attrCurrentPositionLiftPercent100ths)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsCurrentPositionTiltPercent100thsFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads CurrentPositionTiltPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads CurrentPositionTiltPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (attrCurrentPositionTiltPercent100ths == nil) { - VerifyOrReturn(CheckValueNull("CurrentPositionTiltPercent100ths", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, attrCurrentPositionTiltPercent100ths)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_TargetNavigatorCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_TargetNavigatorCluster() - : TestCommandBridge("TV_TargetNavigatorCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_TargetNavigatorCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_TargetNavigatorCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_TargetNavigatorCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Target Navigator list\n"); - err = TestReadAttributeTargetNavigatorList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute current navigator target\n"); - err = TestReadAttributeCurrentNavigatorTarget_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Navigate Target Request Command\n"); - err = TestNavigateTargetRequestCommand_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeTargetNavigatorList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Target Navigator list: Error: %@", err); - } else { - NSLog(@"Read attribute Target Navigator list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TargetList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Identifier", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[0]).identifier, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[0]).name, @"exampleName")); - VerifyOrReturn(CheckValue("Identifier", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[1]).identifier, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[1]).name, @"exampleName")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCurrentNavigatorTarget_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentTargetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute current navigator target: Error: %@", err); - } else { - NSLog(@"Read attribute current navigator target: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentTarget", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestNavigateTargetRequestCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTargetNavigatorClusterNavigateTargetParams alloc] init]; - params.target = - [NSNumber numberWithUnsignedChar:1U]; - params.data = @"1"; - [cluster navigateTargetWithParams:params completion: - ^(MTRTargetNavigatorClusterNavigateTargetResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Navigate Target Request Command: Error: %@", err); - } else { - NSLog(@"Navigate Target Request Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_AudioOutputCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_AudioOutputCluster() - : TestCommandBridge("TV_AudioOutputCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_AudioOutputCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_AudioOutputCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_AudioOutputCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Audio Output list\n"); - err = TestReadAttributeAudioOutputList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute current audio output\n"); - err = TestReadAttributeCurrentAudioOutput_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Select Output Command\n"); - err = TestSelectOutputCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Rename Output Command\n"); - err = TestRenameOutputCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute Audio Output list\n"); - err = TestReadAttributeAudioOutputList_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeAudioOutputList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Audio Output list: Error: %@", err); - } else { - NSLog(@"Read attribute Audio Output list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OutputList", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).index, 1U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).name, @"HDMI")); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).index, 2U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).name, @"HDMI")); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).index, 3U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).name, @"HDMI")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCurrentAudioOutput_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentOutputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute current audio output: Error: %@", err); - } else { - NSLog(@"Read attribute current audio output: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentOutput", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSelectOutputCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAudioOutputClusterSelectOutputParams alloc] init]; - params.index = - [NSNumber numberWithUnsignedChar:1U]; - [cluster selectOutputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Select Output Command: Error: %@", err); - } else { - NSLog(@"Select Output Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRenameOutputCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAudioOutputClusterRenameOutputParams alloc] init]; - params.index = - [NSNumber numberWithUnsignedChar:1U]; - params.name = @"HDMI Test"; - [cluster renameOutputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Rename Output Command: Error: %@", err); - } else { - NSLog(@"Rename Output Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeAudioOutputList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Audio Output list: Error: %@", err); - } else { - NSLog(@"Read attribute Audio Output list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OutputList", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).index, 1U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).name, @"HDMI Test")); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).index, 2U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).name, @"HDMI")); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).index, 3U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).name, @"HDMI")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_ApplicationLauncherCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_ApplicationLauncherCluster() - : TestCommandBridge("TV_ApplicationLauncherCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_ApplicationLauncherCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_ApplicationLauncherCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_ApplicationLauncherCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Application Launcher list\n"); - err = TestReadAttributeApplicationLauncherList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute application launcher app\n"); - err = TestReadAttributeApplicationLauncherApp_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Launch App Command\n"); - err = TestLaunchAppCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Stop App Command\n"); - err = TestStopAppCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Hide App Command\n"); - err = TestHideAppCommand_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeApplicationLauncherList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCatalogListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Application Launcher list: Error: %@", err); - } else { - NSLog(@"Read attribute Application Launcher list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CatalogList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 123U)); - VerifyOrReturn(CheckValue("", actualValue[1], 456U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationLauncherApp_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentAppWithCompletion:^(MTRApplicationLauncherClusterApplicationEPStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application launcher app: Error: %@", err); - } else { - NSLog(@"Read attribute application launcher app: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CurrentApp", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLaunchAppCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRApplicationLauncherClusterLaunchAppParams alloc] init]; - params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = - [NSNumber numberWithUnsignedShort:123U]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = @"applicationId"; - - params.data = - [[NSData alloc] initWithBytes:"data" length:4]; - [cluster launchAppWithParams:params completion: - ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Launch App Command: Error: %@", err); - } else { - NSLog(@"Launch App Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, [[NSData alloc] initWithBytes:"data" length:4])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStopAppCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRApplicationLauncherClusterStopAppParams alloc] init]; - params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = - [NSNumber numberWithUnsignedShort:123U]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = @"applicationId"; - - [cluster stopAppWithParams:params completion: - ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Stop App Command: Error: %@", err); - } else { - NSLog(@"Stop App Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, [[NSData alloc] initWithBytes:"data" length:4])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestHideAppCommand_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRApplicationLauncherClusterHideAppParams alloc] init]; - params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = - [NSNumber numberWithUnsignedShort:123U]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = @"applicationId"; - - [cluster hideAppWithParams:params completion: - ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Hide App Command: Error: %@", err); - } else { - NSLog(@"Hide App Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, [[NSData alloc] initWithBytes:"data" length:4])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_KeypadInputCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_KeypadInputCluster() - : TestCommandBridge("TV_KeypadInputCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_KeypadInputCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_KeypadInputCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_KeypadInputCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Key Command\n"); - err = TestSendKeyCommand_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendKeyCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:3U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Key Command: Error: %@", err); - } else { - NSLog(@"Send Key Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_AccountLoginCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_AccountLoginCluster() - : TestCommandBridge("TV_AccountLoginCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_AccountLoginCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_AccountLoginCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_AccountLoginCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Get Setup PIN Command\n"); - err = TestGetSetupPinCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Login Command\n"); - err = TestLoginCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Logout Command\n"); - err = TestLogoutCommand_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestGetSetupPinCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterGetSetupPINParams alloc] init]; - params.tempAccountIdentifier = @"asdf"; - [cluster getSetupPINWithParams:params completion: - ^(MTRAccountLoginClusterGetSetupPINResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Setup PIN Command: Error: %@", err); - } else { - NSLog(@"Get Setup PIN Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.setupPIN; - VerifyOrReturn(CheckValueAsString("SetupPIN", actualValue, @"tempPin123")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLoginCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterLoginParams alloc] init]; - params.tempAccountIdentifier = @"asdf"; - params.setupPIN = @"tempPin123"; - params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; - [cluster loginWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Login Command: Error: %@", err); - } else { - NSLog(@"Login Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLogoutCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterLogoutParams alloc] init]; - params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; - [cluster logoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Logout Command: Error: %@", err); - } else { - NSLog(@"Logout Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_WakeOnLanCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_WakeOnLanCluster() - : TestCommandBridge("TV_WakeOnLanCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_WakeOnLanCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_WakeOnLanCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_WakeOnLanCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read mac address\n"); - err = TestReadMacAddress_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadMacAddress_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMACAddressWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read mac address: Error: %@", err); - } else { - NSLog(@"Read mac address: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("MACAddress", value, 3)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_ApplicationBasicCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_ApplicationBasicCluster() - : TestCommandBridge("TV_ApplicationBasicCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_ApplicationBasicCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_ApplicationBasicCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_ApplicationBasicCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute vendor name\n"); - err = TestReadAttributeVendorName_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute vendor id\n"); - err = TestReadAttributeVendorId_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute application name\n"); - err = TestReadAttributeApplicationName_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute product id\n"); - err = TestReadAttributeProductId_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute application status\n"); - err = TestReadAttributeApplicationStatus_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute application status\n"); - err = TestReadAttributeApplicationStatus_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute application version\n"); - err = TestReadAttributeApplicationVersion_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute application allowed vendor list\n"); - err = TestReadAttributeApplicationAllowedVendorList_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeVendorName_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor name: Error: %@", err); - } else { - NSLog(@"Read attribute vendor name: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("VendorName", actualValue, @"exampleVendorName1")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorId_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor id: Error: %@", err); - } else { - NSLog(@"Read attribute vendor id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("VendorID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationName_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application name: Error: %@", err); - } else { - NSLog(@"Read attribute application name: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("ApplicationName", actualValue, @"exampleName1")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeProductId_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeProductIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute product id: Error: %@", err); - } else { - NSLog(@"Read attribute product id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ProductID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationStatus_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application status: Error: %@", err); - } else { - NSLog(@"Read attribute application status: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationStatus_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationWithCompletion:^(MTRApplicationBasicClusterApplicationStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application status: Error: %@", err); - } else { - NSLog(@"Read attribute application status: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CatalogVendorID", ((MTRApplicationBasicClusterApplicationStruct *) actualValue).catalogVendorID, 123U)); - VerifyOrReturn(CheckValueAsString("ApplicationID", ((MTRApplicationBasicClusterApplicationStruct *) actualValue).applicationID, @"applicationId")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationVersion_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationVersionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application version: Error: %@", err); - } else { - NSLog(@"Read attribute application version: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("ApplicationVersion", actualValue, @"exampleVersion")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationAllowedVendorList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAllowedVendorListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application allowed vendor list: Error: %@", err); - } else { - NSLog(@"Read attribute application allowed vendor list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AllowedVendorList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 456U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_MediaPlaybackCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_MediaPlaybackCluster() - : TestCommandBridge("TV_MediaPlaybackCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_MediaPlaybackCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_MediaPlaybackCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_MediaPlaybackCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute playback state\n"); - err = TestReadAttributePlaybackState_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute start time\n"); - err = TestReadAttributeStartTime_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute duration\n"); - err = TestReadAttributeDuration_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute position\n"); - err = TestReadAttributePosition_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute playback speed\n"); - err = TestReadAttributePlaybackSpeed_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute seek range end\n"); - err = TestReadAttributeSeekRangeEnd_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute seek range start\n"); - err = TestReadAttributeSeekRangeStart_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Media Playback Play Command\n"); - err = TestMediaPlaybackPlayCommand_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Media Playback Pause Command\n"); - err = TestMediaPlaybackPauseCommand_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Media Playback Stop Command\n"); - err = TestMediaPlaybackStopCommand_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Media Playback Start Over Command\n"); - err = TestMediaPlaybackStartOverCommand_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Media Playback Previous Command\n"); - err = TestMediaPlaybackPreviousCommand_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Media Playback Next Command\n"); - err = TestMediaPlaybackNextCommand_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Media Playback Rewind Command\n"); - err = TestMediaPlaybackRewindCommand_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Media Playback Fast Forward Command\n"); - err = TestMediaPlaybackFastForwardCommand_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Media Playback Skip Forward Command\n"); - err = TestMediaPlaybackSkipForwardCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read attribute position after skip forward\n"); - err = TestReadAttributePositionAfterSkipForward_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Media Playback Skip Backward Command\n"); - err = TestMediaPlaybackSkipBackwardCommand_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read attribute position after skip backward\n"); - err = TestReadAttributePositionAfterSkipBackward_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Media Playback Seek Command\n"); - err = TestMediaPlaybackSeekCommand_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute position after seek\n"); - err = TestReadAttributePositionAfterSeek_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributePlaybackState_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute playback state: Error: %@", err); - } else { - NSLog(@"Read attribute playback state: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeStartTime_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute start time: Error: %@", err); - } else { - NSLog(@"Read attribute start time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StartTime", actualValue)); - VerifyOrReturn(CheckValue("StartTime", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDuration_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDurationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute duration: Error: %@", err); - } else { - NSLog(@"Read attribute duration: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("Duration", actualValue)); - VerifyOrReturn(CheckValue("Duration", actualValue, 80000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePosition_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute position: Error: %@", err); - } else { - NSLog(@"Read attribute position: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePlaybackSpeed_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute playback speed: Error: %@", err); - } else { - NSLog(@"Read attribute playback speed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSeekRangeEnd_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSeekRangeEndWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute seek range end: Error: %@", err); - } else { - NSLog(@"Read attribute seek range end: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SeekRangeEnd", actualValue)); - VerifyOrReturn(CheckValue("SeekRangeEnd", actualValue, 80000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSeekRangeStart_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSeekRangeStartWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute seek range start: Error: %@", err); - } else { - NSLog(@"Read attribute seek range start: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SeekRangeStart", actualValue)); - VerifyOrReturn(CheckValue("SeekRangeStart", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackPlayCommand_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster playWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Play Command: Error: %@", err); - } else { - NSLog(@"Media Playback Play Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackPauseCommand_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Pause Command: Error: %@", err); - } else { - NSLog(@"Media Playback Pause Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackStopCommand_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Stop Command: Error: %@", err); - } else { - NSLog(@"Media Playback Stop Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackStartOverCommand_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster startOverWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Start Over Command: Error: %@", err); - } else { - NSLog(@"Media Playback Start Over Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackPreviousCommand_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster previousWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Previous Command: Error: %@", err); - } else { - NSLog(@"Media Playback Previous Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackNextCommand_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster nextWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Next Command: Error: %@", err); - } else { - NSLog(@"Media Playback Next Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackRewindCommand_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterRewindParams alloc] init]; - [cluster rewindWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Rewind Command: Error: %@", err); - } else { - NSLog(@"Media Playback Rewind Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackFastForwardCommand_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterFastForwardParams alloc] init]; - [cluster fastForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Fast Forward Command: Error: %@", err); - } else { - NSLog(@"Media Playback Fast Forward Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackSkipForwardCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSkipForwardParams alloc] init]; - params.deltaPositionMilliseconds = - [NSNumber numberWithUnsignedLongLong:500ULL]; - [cluster skipForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Skip Forward Command: Error: %@", err); - } else { - NSLog(@"Media Playback Skip Forward Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePositionAfterSkipForward_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute position after skip forward: Error: %@", err); - } else { - NSLog(@"Read attribute position after skip forward: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 500ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackSkipBackwardCommand_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSkipBackwardParams alloc] init]; - params.deltaPositionMilliseconds = - [NSNumber numberWithUnsignedLongLong:100ULL]; - [cluster skipBackwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Skip Backward Command: Error: %@", err); - } else { - NSLog(@"Media Playback Skip Backward Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePositionAfterSkipBackward_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute position after skip backward: Error: %@", err); - } else { - NSLog(@"Read attribute position after skip backward: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 400ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackSeekCommand_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSeekParams alloc] init]; - params.position = - [NSNumber numberWithUnsignedLongLong:1000ULL]; - [cluster seekWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Seek Command: Error: %@", err); - } else { - NSLog(@"Media Playback Seek Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePositionAfterSeek_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute position after seek: Error: %@", err); - } else { - NSLog(@"Read attribute position after seek: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 1000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_ChannelCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_ChannelCluster() - : TestCommandBridge("TV_ChannelCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_ChannelCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_ChannelCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_ChannelCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Channel list\n"); - err = TestReadAttributeChannelList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute channel lineup\n"); - err = TestReadAttributeChannelLineup_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute current channel\n"); - err = TestReadAttributeCurrentChannel_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Change Channel Command\n"); - err = TestChangeChannelCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Change Channel By Number Command\n"); - err = TestChangeChannelByNumberCommand_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Skip Channel Command\n"); - err = TestSkipChannelCommand_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Verify that Skip Channel Command set correct current channel\n"); - err = TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Skip Channel Command\n"); - err = TestSkipChannelCommand_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Verify that Skip Channel Command set correct current channel\n"); - err = TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Test 1.1 - Start from Channel 3\n"); - err = TestTest11StartFromChannel3_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Test 1.2 - Skip Up By 1\n"); - err = TestTest12SkipUpBy1_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Test 2.1 - Start from Channel 3\n"); - err = TestTest21StartFromChannel3_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Test 2.2 - Skip Up By 2\n"); - err = TestTest22SkipUpBy2_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Test 2.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Test 3.1 - Start from Channel 3\n"); - err = TestTest31StartFromChannel3_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Test 3.2 - Skip Up By 3\n"); - err = TestTest32SkipUpBy3_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Test 3.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Test 4.1 - Start from Channel 3\n"); - err = TestTest41StartFromChannel3_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Test 4.2 - Skip Up By 4\n"); - err = TestTest42SkipUpBy4_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Test 4.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Test 5.2 - Skip Up By 5\n"); - err = TestTest52SkipUpBy5_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Test 5.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Test 6.1 - Start from Channel 3\n"); - err = TestTest61StartFromChannel3_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Test 6.2 - Skip Up By 6\n"); - err = TestTest62SkipUpBy6_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Test 6.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Test 7.1 - Start from Channel 3\n"); - err = TestTest71StartFromChannel3_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Test 7.2 - Skip Up By 7\n"); - err = TestTest72SkipUpBy7_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Test 7.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Test 8.1 - Start from Channel 3\n"); - err = TestTest81StartFromChannel3_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Test 8.2 - Skip Up By 8\n"); - err = TestTest82SkipUpBy8_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Test 8.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Test 1.2 - Skip Down By 1\n"); - err = TestTest12SkipDownBy1_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Test 2.1 - Start from Channel 3\n"); - err = TestTest21StartFromChannel3_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Test 2.2 - Skip Down By 2\n"); - err = TestTest22SkipDownBy2_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Test 2.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Test 3.1 - Start from Channel 3\n"); - err = TestTest31StartFromChannel3_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Test 3.2 - Skip Down By 3\n"); - err = TestTest32SkipDownBy3_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Test 3.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Test 4.1 - Start from Channel 3\n"); - err = TestTest41StartFromChannel3_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Test 4.2 - Skip Down By 4\n"); - err = TestTest42SkipDownBy4_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Test 4.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Test 5.2 - Skip Down By 5\n"); - err = TestTest52SkipDownBy5_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Test 5.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Test 6.1 - Start from Channel 3\n"); - err = TestTest61StartFromChannel3_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Test 6.2 - Skip Down By 6\n"); - err = TestTest62SkipDownBy6_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Test 6.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Test 7.1 - Start from Channel 3\n"); - err = TestTest71StartFromChannel3_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Test 7.2 - Skip Down By 7\n"); - err = TestTest72SkipDownBy7_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Test 7.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Test 8.1 - Start from Channel 3\n"); - err = TestTest81StartFromChannel3_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Test 8.2 - Skip Down By 8\n"); - err = TestTest82SkipDownBy8_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Test 8.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Test 1.2 - Skip Up By 32,767\n"); - err = TestTest12SkipUpBy32767_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Test 1.1 - Start from Channel 3\n"); - err = TestTest11StartFromChannel3_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Test 1.2 - Skip Down By 32,768\n"); - err = TestTest12SkipDownBy32768_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_59(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 60; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeChannelList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Channel list: Error: %@", err); - } else { - NSLog(@"Read attribute Channel list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ChannelList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).affiliateCallSign, @"KAAL")); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).affiliateCallSign, @"KCTS")); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).affiliateCallSign, @"KCTS")); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeChannelLineup_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLineupWithCompletion:^(MTRChannelClusterLineupInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute channel lineup: Error: %@", err); - } else { - NSLog(@"Read attribute channel lineup: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("Lineup", actualValue)); - VerifyOrReturn(CheckValueAsString("OperatorName", ((MTRChannelClusterLineupInfoStruct *) actualValue).operatorName, @"Comcast")); - VerifyOrReturn(CheckValueAsString("LineupName", ((MTRChannelClusterLineupInfoStruct *) actualValue).lineupName, @"Comcast King County")); - VerifyOrReturn(CheckValueAsString("PostalCode", ((MTRChannelClusterLineupInfoStruct *) actualValue).postalCode, @"98052")); - VerifyOrReturn(CheckValue("LineupInfoType", ((MTRChannelClusterLineupInfoStruct *) actualValue).lineupInfoType, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCurrentChannel_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute current channel: Error: %@", err); - } else { - NSLog(@"Read attribute current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeChannelCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelParams alloc] init]; - params.match = @"PBS"; - [cluster changeChannelWithParams:params completion: - ^(MTRChannelClusterChangeChannelResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change Channel Command: Error: %@", err); - } else { - NSLog(@"Change Channel Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeChannelByNumberCommand_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:6U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:0U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change Channel By Number Command: Error: %@", err); - } else { - NSLog(@"Change Channel By Number Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSkipChannelCommand_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:2]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Skip Channel Command: Error: %@", err); - } else { - NSLog(@"Skip Channel Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSkipChannelCommand_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:123]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Skip Channel Command: Error: %@", err); - } else { - NSLog(@"Skip Channel Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest11StartFromChannel3_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 1.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest12SkipUpBy1_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:1]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.2 - Skip Up By 1: Error: %@", err); - } else { - NSLog(@"Test 1.2 - Skip Up By 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest21StartFromChannel3_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 2.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest22SkipUpBy2_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:2]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.2 - Skip Up By 2: Error: %@", err); - } else { - NSLog(@"Test 2.2 - Skip Up By 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest31StartFromChannel3_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 3.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest32SkipUpBy3_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:3]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.2 - Skip Up By 3: Error: %@", err); - } else { - NSLog(@"Test 3.2 - Skip Up By 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest41StartFromChannel3_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 4.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest42SkipUpBy4_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:4]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.2 - Skip Up By 4: Error: %@", err); - } else { - NSLog(@"Test 4.2 - Skip Up By 4: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest52SkipUpBy5_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:5]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 5.2 - Skip Up By 5: Error: %@", err); - } else { - NSLog(@"Test 5.2 - Skip Up By 5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest61StartFromChannel3_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 6.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest62SkipUpBy6_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:6]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.2 - Skip Up By 6: Error: %@", err); - } else { - NSLog(@"Test 6.2 - Skip Up By 6: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest71StartFromChannel3_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 7.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest72SkipUpBy7_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:7]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.2 - Skip Up By 7: Error: %@", err); - } else { - NSLog(@"Test 7.2 - Skip Up By 7: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest81StartFromChannel3_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 8.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest82SkipUpBy8_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:8]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.2 - Skip Up By 8: Error: %@", err); - } else { - NSLog(@"Test 8.2 - Skip Up By 8: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest12SkipDownBy1_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-1]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.2 - Skip Down By 1: Error: %@", err); - } else { - NSLog(@"Test 1.2 - Skip Down By 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest21StartFromChannel3_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 2.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest22SkipDownBy2_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-2]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.2 - Skip Down By 2: Error: %@", err); - } else { - NSLog(@"Test 2.2 - Skip Down By 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest31StartFromChannel3_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 3.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest32SkipDownBy3_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-3]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.2 - Skip Down By 3: Error: %@", err); - } else { - NSLog(@"Test 3.2 - Skip Down By 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest41StartFromChannel3_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 4.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest42SkipDownBy4_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-4]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.2 - Skip Down By 4: Error: %@", err); - } else { - NSLog(@"Test 4.2 - Skip Down By 4: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest52SkipDownBy5_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-5]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 5.2 - Skip Down By 5: Error: %@", err); - } else { - NSLog(@"Test 5.2 - Skip Down By 5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest61StartFromChannel3_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 6.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest62SkipDownBy6_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-6]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.2 - Skip Down By 6: Error: %@", err); - } else { - NSLog(@"Test 6.2 - Skip Down By 6: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest71StartFromChannel3_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 7.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest72SkipDownBy7_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-7]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.2 - Skip Down By 7: Error: %@", err); - } else { - NSLog(@"Test 7.2 - Skip Down By 7: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest81StartFromChannel3_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 8.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest82SkipDownBy8_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-8]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.2 - Skip Down By 8: Error: %@", err); - } else { - NSLog(@"Test 8.2 - Skip Down By 8: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest12SkipUpBy32767_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:32767]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.2 - Skip Up By 32,767: Error: %@", err); - } else { - NSLog(@"Test 1.2 - Skip Up By 32,767: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest11StartFromChannel3_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 1.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest12SkipDownBy32768_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-32768]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.2 - Skip Down By 32,768: Error: %@", err); - } else { - NSLog(@"Test 1.2 - Skip Down By 32,768: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_LowPowerCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_LowPowerCluster() - : TestCommandBridge("TV_LowPowerCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_LowPowerCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_LowPowerCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_LowPowerCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Sleep Input Status Command\n"); - err = TestSleepInputStatusCommand_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSleepInputStatusCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster sleepWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Sleep Input Status Command: Error: %@", err); - } else { - NSLog(@"Sleep Input Status Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_ContentLauncherCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_ContentLauncherCluster() - : TestCommandBridge("TV_ContentLauncherCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_ContentLauncherCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_ContentLauncherCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_ContentLauncherCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute accept header list\n"); - err = TestReadAttributeAcceptHeaderList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute supported streaming protocols\n"); - err = TestReadAttributeSupportedStreamingProtocols_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Launch Content Command\n"); - err = TestLaunchContentCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Launch URL Command\n"); - err = TestLaunchUrlCommand_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeAcceptHeaderList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptHeaderWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute accept header list: Error: %@", err); - } else { - NSLog(@"Read attribute accept header list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptHeader", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], @"example")); - VerifyOrReturn(CheckValueAsString("", actualValue[1], @"example")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSupportedStreamingProtocols_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedStreamingProtocolsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute supported streaming protocols: Error: %@", err); - } else { - NSLog(@"Read attribute supported streaming protocols: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SupportedStreamingProtocols", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLaunchContentCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"exampleValue"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = [[MTRContentLauncherClusterAdditionalInfoStruct alloc] init]; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).name = @"name"; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).value = @"value"; - - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).externalIDList = temp_4; - } - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.data = @"exampleData"; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - params.useCurrentContext = - [NSNumber numberWithBool:true]; - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Launch Content Command: Error: %@", err); - } else { - NSLog(@"Launch Content Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLaunchUrlCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = @"exampleUrl"; - params.displayString = @"exampleDisplayString"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = @"exampleName"; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Launch URL Command: Error: %@", err); - } else { - NSLog(@"Launch URL Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_MediaInputCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_MediaInputCluster() - : TestCommandBridge("TV_MediaInputCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_MediaInputCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_MediaInputCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_MediaInputCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute media input list\n"); - err = TestReadAttributeMediaInputList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current media input\n"); - err = TestReadCurrentMediaInput_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Select Input Command\n"); - err = TestSelectInputCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Hide Input Status Command\n"); - err = TestHideInputStatusCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Show Input Status Command\n"); - err = TestShowInputStatusCommand_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Rename Input Command\n"); - err = TestRenameInputCommand_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute media input list\n"); - err = TestReadAttributeMediaInputList_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeMediaInputList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute media input list: Error: %@", err); - } else { - NSLog(@"Read attribute media input list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("InputList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).index, 1U)); - VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).inputType, 4U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).name, @"HDMI")); - VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).descriptionString, @"High-Definition Multimedia Interface")); - VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).index, 2U)); - VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).inputType, 4U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).name, @"HDMI")); - VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).descriptionString, @"High-Definition Multimedia Interface")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentMediaInput_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentInputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current media input: Error: %@", err); - } else { - NSLog(@"Read current media input: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentInput", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSelectInputCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaInputClusterSelectInputParams alloc] init]; - params.index = - [NSNumber numberWithUnsignedChar:1U]; - [cluster selectInputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Select Input Command: Error: %@", err); - } else { - NSLog(@"Select Input Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestHideInputStatusCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster hideInputStatusWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Hide Input Status Command: Error: %@", err); - } else { - NSLog(@"Hide Input Status Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestShowInputStatusCommand_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster showInputStatusWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Show Input Status Command: Error: %@", err); - } else { - NSLog(@"Show Input Status Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRenameInputCommand_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaInputClusterRenameInputParams alloc] init]; - params.index = - [NSNumber numberWithUnsignedChar:1U]; - params.name = @"HDMI Test"; - [cluster renameInputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Rename Input Command: Error: %@", err); - } else { - NSLog(@"Rename Input Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeMediaInputList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute media input list: Error: %@", err); - } else { - NSLog(@"Read attribute media input list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("InputList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).index, 1U)); - VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).inputType, 4U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).name, @"HDMI Test")); - VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).descriptionString, @"High-Definition Multimedia Interface")); - VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).index, 2U)); - VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).inputType, 4U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).name, @"HDMI")); - VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).descriptionString, @"High-Definition Multimedia Interface")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestCASERecovery : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestCASERecovery() - : TestCommandBridge("TestCASERecovery") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestCASERecovery() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestCASERecovery\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestCASERecovery\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read an attribute\n"); - err = TestReadAnAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Reboot the server\n"); - err = TestRebootTheServer_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Re-get our session, but without expiring sesssions\n"); - err = TestReGetOurSessionButWithoutExpiringSesssions_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read an attribute again\n"); - err = TestReadAnAttributeAgain_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Re-get our session, but without expiring sesssions\n"); - err = TestReGetOurSessionButWithoutExpiringSesssions_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read an attribute a third time\n"); - err = TestReadAnAttributeAThirdTime_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAnAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDataModelRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read an attribute: Error: %@", err); - } else { - NSLog(@"Read an attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DataModelRevision", actualValue, 17U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootTheServer_2() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestReGetOurSessionButWithoutExpiringSesssions_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.expireExistingSession.Emplace(); - value.expireExistingSession.Value() = false; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAnAttributeAgain_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDataModelRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read an attribute again: Error: %@", err); - } else { - NSLog(@"Read an attribute again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReGetOurSessionButWithoutExpiringSesssions_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.expireExistingSession.Emplace(); - value.expireExistingSession.Value() = false; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAnAttributeAThirdTime_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDataModelRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read an attribute a third time: Error: %@", err); - } else { - NSLog(@"Read an attribute a third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DataModelRevision", actualValue, 17U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestCluster() - : TestCommandBridge("TestCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Test Command\n"); - err = TestSendTestCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Send Test Not Handled Command\n"); - err = TestSendTestNotHandledCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Send Test Specific Command\n"); - err = TestSendTestSpecificCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Send failing Test Add Arguments Command\n"); - err = TestSendFailingTestAddArgumentsCommand_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute BOOLEAN Default Value\n"); - err = TestReadAttributeBooleanDefaultValue_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write attribute BOOLEAN True\n"); - err = TestWriteAttributeBooleanTrue_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute BOOLEAN True\n"); - err = TestReadAttributeBooleanTrue_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Write attribute BOOLEAN False\n"); - err = TestWriteAttributeBooleanFalse_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read attribute BOOLEAN False\n"); - err = TestReadAttributeBooleanFalse_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read attribute BITMAP8 Default Value\n"); - err = TestReadAttributeBitmap8DefaultValue_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Write attribute BITMAP8 Max Value\n"); - err = TestWriteAttributeBitmap8MaxValue_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read attribute BITMAP8 Max Value\n"); - err = TestReadAttributeBitmap8MaxValue_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Write attribute BITMAP8 Min Value\n"); - err = TestWriteAttributeBitmap8MinValue_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read attribute BITMAP8 Min Value\n"); - err = TestReadAttributeBitmap8MinValue_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read attribute BITMAP16 Default Value\n"); - err = TestReadAttributeBitmap16DefaultValue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Write attribute BITMAP16 Max Value\n"); - err = TestWriteAttributeBitmap16MaxValue_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read attribute BITMAP16 Max Value\n"); - err = TestReadAttributeBitmap16MaxValue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Write attribute BITMAP16 Min Value\n"); - err = TestWriteAttributeBitmap16MinValue_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Read attribute BITMAP16 Min Value\n"); - err = TestReadAttributeBitmap16MinValue_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute BITMAP32 Default Value\n"); - err = TestReadAttributeBitmap32DefaultValue_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Write attribute BITMAP32 Max Value\n"); - err = TestWriteAttributeBitmap32MaxValue_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Read attribute BITMAP32 Max Value\n"); - err = TestReadAttributeBitmap32MaxValue_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Write attribute BITMAP32 Min Value\n"); - err = TestWriteAttributeBitmap32MinValue_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Read attribute BITMAP32 Min Value\n"); - err = TestReadAttributeBitmap32MinValue_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Read attribute BITMAP64 Default Value\n"); - err = TestReadAttributeBitmap64DefaultValue_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Write attribute BITMAP64 Max Value\n"); - err = TestWriteAttributeBitmap64MaxValue_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Read attribute BITMAP64 Max Value\n"); - err = TestReadAttributeBitmap64MaxValue_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Write attribute BITMAP64 Min Value\n"); - err = TestWriteAttributeBitmap64MinValue_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Read attribute BITMAP64 Min Value\n"); - err = TestReadAttributeBitmap64MinValue_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Read attribute INT8U Default Value\n"); - err = TestReadAttributeInt8uDefaultValue_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Write attribute INT8U Max Value\n"); - err = TestWriteAttributeInt8uMaxValue_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Read attribute INT8U Max Value\n"); - err = TestReadAttributeInt8uMaxValue_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Write attribute INT8U Min Value\n"); - err = TestWriteAttributeInt8uMinValue_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Read attribute INT8U Min Value\n"); - err = TestReadAttributeInt8uMinValue_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Read attribute INT16U Default Value\n"); - err = TestReadAttributeInt16uDefaultValue_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Write attribute INT16U Max Value\n"); - err = TestWriteAttributeInt16uMaxValue_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Read attribute INT16U Max Value\n"); - err = TestReadAttributeInt16uMaxValue_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Write attribute INT16U Min Value\n"); - err = TestWriteAttributeInt16uMinValue_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Read attribute INT16U Min Value\n"); - err = TestReadAttributeInt16uMinValue_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Read attribute INT32U Default Value\n"); - err = TestReadAttributeInt32uDefaultValue_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Write attribute INT32U Max Value\n"); - err = TestWriteAttributeInt32uMaxValue_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Read attribute INT32U Max Value\n"); - err = TestReadAttributeInt32uMaxValue_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Write attribute INT32U Min Value\n"); - err = TestWriteAttributeInt32uMinValue_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Read attribute INT32U Min Value\n"); - err = TestReadAttributeInt32uMinValue_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Read attribute INT64U Default Value\n"); - err = TestReadAttributeInt64uDefaultValue_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Write attribute INT64U Max Value\n"); - err = TestWriteAttributeInt64uMaxValue_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Read attribute INT64U Max Value\n"); - err = TestReadAttributeInt64uMaxValue_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Write attribute INT64U Min Value\n"); - err = TestWriteAttributeInt64uMinValue_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Read attribute INT64U Min Value\n"); - err = TestReadAttributeInt64uMinValue_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Read attribute INT8S Default Value\n"); - err = TestReadAttributeInt8sDefaultValue_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Write attribute INT8S Max Value\n"); - err = TestWriteAttributeInt8sMaxValue_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Read attribute INT8S Max Value\n"); - err = TestReadAttributeInt8sMaxValue_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Write attribute INT8S Min Value\n"); - err = TestWriteAttributeInt8sMinValue_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Read attribute INT8S Min Value\n"); - err = TestReadAttributeInt8sMinValue_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Write attribute INT8S Default Value\n"); - err = TestWriteAttributeInt8sDefaultValue_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Read attribute INT8S Default Value\n"); - err = TestReadAttributeInt8sDefaultValue_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Read attribute INT16S Default Value\n"); - err = TestReadAttributeInt16sDefaultValue_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Write attribute INT16S Max Value\n"); - err = TestWriteAttributeInt16sMaxValue_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Read attribute INT16S Max Value\n"); - err = TestReadAttributeInt16sMaxValue_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Write attribute INT16S Min Value\n"); - err = TestWriteAttributeInt16sMinValue_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Read attribute INT16S Min Value\n"); - err = TestReadAttributeInt16sMinValue_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Write attribute INT16S Default Value\n"); - err = TestWriteAttributeInt16sDefaultValue_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Read attribute INT16S Default Value\n"); - err = TestReadAttributeInt16sDefaultValue_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Read attribute INT32S Default Value\n"); - err = TestReadAttributeInt32sDefaultValue_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Write attribute INT32S Max Value\n"); - err = TestWriteAttributeInt32sMaxValue_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Read attribute INT32S Max Value\n"); - err = TestReadAttributeInt32sMaxValue_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Write attribute INT32S Min Value\n"); - err = TestWriteAttributeInt32sMinValue_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Read attribute INT32S Min Value\n"); - err = TestReadAttributeInt32sMinValue_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Write attribute INT32S Default Value\n"); - err = TestWriteAttributeInt32sDefaultValue_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Read attribute INT32S Default Value\n"); - err = TestReadAttributeInt32sDefaultValue_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Read attribute INT64S Default Value\n"); - err = TestReadAttributeInt64sDefaultValue_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Write attribute INT64S Max Value\n"); - err = TestWriteAttributeInt64sMaxValue_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Read attribute INT64S Max Value\n"); - err = TestReadAttributeInt64sMaxValue_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Write attribute INT64S Min Value\n"); - err = TestWriteAttributeInt64sMinValue_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Read attribute INT64S Min Value\n"); - err = TestReadAttributeInt64sMinValue_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Write attribute INT64S Default Value\n"); - err = TestWriteAttributeInt64sDefaultValue_77(); - break; - case 78: - ChipLogProgress(chipTool, " ***** Test Step 78 : Read attribute INT64S Default Value\n"); - err = TestReadAttributeInt64sDefaultValue_78(); - break; - case 79: - ChipLogProgress(chipTool, " ***** Test Step 79 : Read attribute SINGLE Default Value\n"); - err = TestReadAttributeSingleDefaultValue_79(); - break; - case 80: - ChipLogProgress(chipTool, " ***** Test Step 80 : Write attribute SINGLE medium Value\n"); - err = TestWriteAttributeSingleMediumValue_80(); - break; - case 81: - ChipLogProgress(chipTool, " ***** Test Step 81 : Read attribute SINGLE medium Value\n"); - err = TestReadAttributeSingleMediumValue_81(); - break; - case 82: - ChipLogProgress(chipTool, " ***** Test Step 82 : Write attribute SINGLE large Value\n"); - err = TestWriteAttributeSingleLargeValue_82(); - break; - case 83: - ChipLogProgress(chipTool, " ***** Test Step 83 : Read attribute SINGLE large Value\n"); - err = TestReadAttributeSingleLargeValue_83(); - break; - case 84: - ChipLogProgress(chipTool, " ***** Test Step 84 : Write attribute SINGLE small Value\n"); - err = TestWriteAttributeSingleSmallValue_84(); - break; - case 85: - ChipLogProgress(chipTool, " ***** Test Step 85 : Read attribute SINGLE small Value\n"); - err = TestReadAttributeSingleSmallValue_85(); - break; - case 86: - ChipLogProgress(chipTool, " ***** Test Step 86 : Write attribute SINGLE Default Value\n"); - err = TestWriteAttributeSingleDefaultValue_86(); - break; - case 87: - ChipLogProgress(chipTool, " ***** Test Step 87 : Read attribute SINGLE Default Value\n"); - err = TestReadAttributeSingleDefaultValue_87(); - break; - case 88: - ChipLogProgress(chipTool, " ***** Test Step 88 : Read attribute DOUBLE Default Value\n"); - err = TestReadAttributeDoubleDefaultValue_88(); - break; - case 89: - ChipLogProgress(chipTool, " ***** Test Step 89 : Write attribute DOUBLE medium Value\n"); - err = TestWriteAttributeDoubleMediumValue_89(); - break; - case 90: - ChipLogProgress(chipTool, " ***** Test Step 90 : Read attribute DOUBLE medium Value\n"); - err = TestReadAttributeDoubleMediumValue_90(); - break; - case 91: - ChipLogProgress(chipTool, " ***** Test Step 91 : Write attribute DOUBLE large Value\n"); - err = TestWriteAttributeDoubleLargeValue_91(); - break; - case 92: - ChipLogProgress(chipTool, " ***** Test Step 92 : Read attribute DOUBLE large Value\n"); - err = TestReadAttributeDoubleLargeValue_92(); - break; - case 93: - ChipLogProgress(chipTool, " ***** Test Step 93 : Write attribute DOUBLE small Value\n"); - err = TestWriteAttributeDoubleSmallValue_93(); - break; - case 94: - ChipLogProgress(chipTool, " ***** Test Step 94 : Read attribute DOUBLE small Value\n"); - err = TestReadAttributeDoubleSmallValue_94(); - break; - case 95: - ChipLogProgress(chipTool, " ***** Test Step 95 : Write attribute DOUBLE Default Value\n"); - err = TestWriteAttributeDoubleDefaultValue_95(); - break; - case 96: - ChipLogProgress(chipTool, " ***** Test Step 96 : Read attribute DOUBLE Default Value\n"); - err = TestReadAttributeDoubleDefaultValue_96(); - break; - case 97: - ChipLogProgress(chipTool, " ***** Test Step 97 : Read attribute ENUM8 Default Value\n"); - err = TestReadAttributeEnum8DefaultValue_97(); - break; - case 98: - ChipLogProgress(chipTool, " ***** Test Step 98 : Write attribute ENUM8 Max Value\n"); - err = TestWriteAttributeEnum8MaxValue_98(); - break; - case 99: - ChipLogProgress(chipTool, " ***** Test Step 99 : Read attribute ENUM8 Max Value\n"); - err = TestReadAttributeEnum8MaxValue_99(); - break; - case 100: - ChipLogProgress(chipTool, " ***** Test Step 100 : Write attribute ENUM8 Min Value\n"); - err = TestWriteAttributeEnum8MinValue_100(); - break; - case 101: - ChipLogProgress(chipTool, " ***** Test Step 101 : Read attribute ENUM8 Min Value\n"); - err = TestReadAttributeEnum8MinValue_101(); - break; - case 102: - ChipLogProgress(chipTool, " ***** Test Step 102 : Read attribute ENUM16 Default Value\n"); - err = TestReadAttributeEnum16DefaultValue_102(); - break; - case 103: - ChipLogProgress(chipTool, " ***** Test Step 103 : Write attribute ENUM16 Max Value\n"); - err = TestWriteAttributeEnum16MaxValue_103(); - break; - case 104: - ChipLogProgress(chipTool, " ***** Test Step 104 : Read attribute ENUM16 Max Value\n"); - err = TestReadAttributeEnum16MaxValue_104(); - break; - case 105: - ChipLogProgress(chipTool, " ***** Test Step 105 : Write attribute ENUM16 Min Value\n"); - err = TestWriteAttributeEnum16MinValue_105(); - break; - case 106: - ChipLogProgress(chipTool, " ***** Test Step 106 : Read attribute ENUM16 Min Value\n"); - err = TestReadAttributeEnum16MinValue_106(); - break; - case 107: - ChipLogProgress(chipTool, " ***** Test Step 107 : Read attribute OCTET_STRING Default Value\n"); - err = TestReadAttributeOctetStringDefaultValue_107(); - break; - case 108: - ChipLogProgress(chipTool, " ***** Test Step 108 : Write attribute OCTET_STRING with embedded null\n"); - err = TestWriteAttributeOctetStringWithEmbeddedNull_108(); - break; - case 109: - ChipLogProgress(chipTool, " ***** Test Step 109 : Read attribute OCTET_STRING with embedded null\n"); - err = TestReadAttributeOctetStringWithEmbeddedNull_109(); - break; - case 110: - ChipLogProgress(chipTool, " ***** Test Step 110 : Write attribute OCTET_STRING with hex: format\n"); - err = TestWriteAttributeOctetStringWithHexFormat_110(); - break; - case 111: - ChipLogProgress(chipTool, " ***** Test Step 111 : Read attribute OCTET_STRING with hex: format\n"); - err = TestReadAttributeOctetStringWithHexFormat_111(); - break; - case 112: - ChipLogProgress(chipTool, " ***** Test Step 112 : Write attribute OCTET_STRING with weird chars\n"); - err = TestWriteAttributeOctetStringWithWeirdChars_112(); - break; - case 113: - ChipLogProgress(chipTool, " ***** Test Step 113 : Read attribute OCTET_STRING with weird chars\n"); - err = TestReadAttributeOctetStringWithWeirdChars_113(); - break; - case 114: - ChipLogProgress(chipTool, " ***** Test Step 114 : Write attribute OCTET_STRING\n"); - err = TestWriteAttributeOctetString_114(); - break; - case 115: - ChipLogProgress(chipTool, " ***** Test Step 115 : Read attribute OCTET_STRING\n"); - err = TestReadAttributeOctetString_115(); - break; - case 116: - ChipLogProgress(chipTool, " ***** Test Step 116 : Write attribute OCTET_STRING\n"); - err = TestWriteAttributeOctetString_116(); - break; - case 117: - ChipLogProgress(chipTool, " ***** Test Step 117 : Read attribute OCTET_STRING\n"); - err = TestReadAttributeOctetString_117(); - break; - case 118: - ChipLogProgress(chipTool, " ***** Test Step 118 : Write attribute OCTET_STRING\n"); - err = TestWriteAttributeOctetString_118(); - break; - case 119: - ChipLogProgress(chipTool, " ***** Test Step 119 : Read attribute LONG_OCTET_STRING Default Value\n"); - err = TestReadAttributeLongOctetStringDefaultValue_119(); - break; - case 120: - ChipLogProgress(chipTool, " ***** Test Step 120 : Write attribute LONG_OCTET_STRING\n"); - err = TestWriteAttributeLongOctetString_120(); - break; - case 121: - ChipLogProgress(chipTool, " ***** Test Step 121 : Read attribute LONG_OCTET_STRING\n"); - err = TestReadAttributeLongOctetString_121(); - break; - case 122: - ChipLogProgress(chipTool, " ***** Test Step 122 : Write attribute LONG_OCTET_STRING\n"); - err = TestWriteAttributeLongOctetString_122(); - break; - case 123: - ChipLogProgress(chipTool, " ***** Test Step 123 : Read attribute CHAR_STRING Default Value\n"); - err = TestReadAttributeCharStringDefaultValue_123(); - break; - case 124: - ChipLogProgress(chipTool, " ***** Test Step 124 : Write attribute CHAR_STRING\n"); - err = TestWriteAttributeCharString_124(); - break; - case 125: - ChipLogProgress(chipTool, " ***** Test Step 125 : Read attribute CHAR_STRING\n"); - err = TestReadAttributeCharString_125(); - break; - case 126: - ChipLogProgress(chipTool, " ***** Test Step 126 : Write attribute CHAR_STRING - Value too long\n"); - err = TestWriteAttributeCharStringValueTooLong_126(); - break; - case 127: - ChipLogProgress(chipTool, " ***** Test Step 127 : Read attribute CHAR_STRING\n"); - err = TestReadAttributeCharString_127(); - break; - case 128: - ChipLogProgress(chipTool, " ***** Test Step 128 : Write attribute CHAR_STRING - Empty\n"); - err = TestWriteAttributeCharStringEmpty_128(); - break; - case 129: - ChipLogProgress(chipTool, " ***** Test Step 129 : Read attribute LONG_CHAR_STRING Default Value\n"); - err = TestReadAttributeLongCharStringDefaultValue_129(); - break; - case 130: - ChipLogProgress(chipTool, " ***** Test Step 130 : Write attribute LONG_CHAR_STRING\n"); - err = TestWriteAttributeLongCharString_130(); - break; - case 131: - ChipLogProgress(chipTool, " ***** Test Step 131 : Read attribute LONG_CHAR_STRING\n"); - err = TestReadAttributeLongCharString_131(); - break; - case 132: - ChipLogProgress(chipTool, " ***** Test Step 132 : Write attribute LONG_CHAR_STRING\n"); - err = TestWriteAttributeLongCharString_132(); - break; - case 133: - ChipLogProgress(chipTool, " ***** Test Step 133 : Read attribute LIST_LONG_OCTET_STRING (for chunked read)\n"); - err = TestReadAttributeListLongOctetStringForChunkedRead_133(); - break; - case 134: - ChipLogProgress(chipTool, " ***** Test Step 134 : Write attribute LIST_LONG_OCTET_STRING (for chunked write)\n"); - err = TestWriteAttributeListLongOctetStringForChunkedWrite_134(); - break; - case 135: - ChipLogProgress(chipTool, " ***** Test Step 135 : Read attribute LIST_LONG_OCTET_STRING (for chunked read)\n"); - err = TestReadAttributeListLongOctetStringForChunkedRead_135(); - break; - case 136: - ChipLogProgress(chipTool, " ***** Test Step 136 : Write attribute LIST_LONG_OCTET_STRING (for chunked write)\n"); - err = TestWriteAttributeListLongOctetStringForChunkedWrite_136(); - break; - case 137: - ChipLogProgress(chipTool, " ***** Test Step 137 : Read attribute EPOCH_US Default Value\n"); - err = TestReadAttributeEpochUsDefaultValue_137(); - break; - case 138: - ChipLogProgress(chipTool, " ***** Test Step 138 : Write attribute EPOCH_US Max Value\n"); - err = TestWriteAttributeEpochUsMaxValue_138(); - break; - case 139: - ChipLogProgress(chipTool, " ***** Test Step 139 : Read attribute EPOCH_US Max Value\n"); - err = TestReadAttributeEpochUsMaxValue_139(); - break; - case 140: - ChipLogProgress(chipTool, " ***** Test Step 140 : Write attribute EPOCH_US Min Value\n"); - err = TestWriteAttributeEpochUsMinValue_140(); - break; - case 141: - ChipLogProgress(chipTool, " ***** Test Step 141 : Read attribute EPOCH_US Min Value\n"); - err = TestReadAttributeEpochUsMinValue_141(); - break; - case 142: - ChipLogProgress(chipTool, " ***** Test Step 142 : Read attribute EPOCH_S Default Value\n"); - err = TestReadAttributeEpochSDefaultValue_142(); - break; - case 143: - ChipLogProgress(chipTool, " ***** Test Step 143 : Write attribute EPOCH_S Max Value\n"); - err = TestWriteAttributeEpochSMaxValue_143(); - break; - case 144: - ChipLogProgress(chipTool, " ***** Test Step 144 : Read attribute EPOCH_S Max Value\n"); - err = TestReadAttributeEpochSMaxValue_144(); - break; - case 145: - ChipLogProgress(chipTool, " ***** Test Step 145 : Write attribute EPOCH_S Min Value\n"); - err = TestWriteAttributeEpochSMinValue_145(); - break; - case 146: - ChipLogProgress(chipTool, " ***** Test Step 146 : Read attribute EPOCH_S Min Value\n"); - err = TestReadAttributeEpochSMinValue_146(); - break; - case 147: - ChipLogProgress(chipTool, " ***** Test Step 147 : Read attribute UNSUPPORTED\n"); - err = TestReadAttributeUnsupported_147(); - break; - case 148: - ChipLogProgress(chipTool, " ***** Test Step 148 : Writeattribute UNSUPPORTED\n"); - err = TestWriteattributeUnsupported_148(); - break; - case 149: - ChipLogProgress(chipTool, " ***** Test Step 149 : Send Test Command to unsupported endpoint\n"); - err = TestSendTestCommandToUnsupportedEndpoint_149(); - break; - case 150: - ChipLogProgress(chipTool, " ***** Test Step 150 : Send Test Command to unsupported cluster\n"); - err = TestSendTestCommandToUnsupportedCluster_150(); - break; - case 151: - ChipLogProgress(chipTool, " ***** Test Step 151 : Read attribute vendor_id Default Value\n"); - err = TestReadAttributeVendorIdDefaultValue_151(); - break; - case 152: - ChipLogProgress(chipTool, " ***** Test Step 152 : Write attribute vendor_id\n"); - err = TestWriteAttributeVendorId_152(); - break; - case 153: - ChipLogProgress(chipTool, " ***** Test Step 153 : Read attribute vendor_id\n"); - err = TestReadAttributeVendorId_153(); - break; - case 154: - ChipLogProgress(chipTool, " ***** Test Step 154 : Restore attribute vendor_id\n"); - err = TestRestoreAttributeVendorId_154(); - break; - case 155: - ChipLogProgress(chipTool, " ***** Test Step 155 : Send a command with a vendor_id and enum\n"); - err = TestSendACommandWithAVendorIdAndEnum_155(); - break; - case 156: - ChipLogProgress(chipTool, " ***** Test Step 156 : Send a command with a vendor_id and invalid enum\n"); - err = TestSendACommandWithAVendorIdAndInvalidEnum_156(); - break; - case 157: - ChipLogProgress(chipTool, " ***** Test Step 157 : Send Test Command With Struct Argument and arg1.b is true\n"); - err = TestSendTestCommandWithStructArgumentAndArg1bIsTrue_157(); - break; - case 158: - ChipLogProgress(chipTool, " ***** Test Step 158 : Send Test Command With Struct Argument and arg1.b is false\n"); - err = TestSendTestCommandWithStructArgumentAndArg1bIsFalse_158(); - break; - case 159: - ChipLogProgress(chipTool, " ***** Test Step 159 : Send Test Command With Nested Struct Argument and arg1.c.b is true\n"); - err = TestSendTestCommandWithNestedStructArgumentAndArg1cbIsTrue_159(); - break; - case 160: - ChipLogProgress(chipTool, " ***** Test Step 160 : Send Test Command With Nested Struct Argument arg1.c.b is false\n"); - err = TestSendTestCommandWithNestedStructArgumentArg1cbIsFalse_160(); - break; - case 161: - ChipLogProgress(chipTool, " ***** Test Step 161 : Send Test Command With Nested Struct List Argument and all fields b of arg1.d are true\n"); - err = TestSendTestCommandWithNestedStructListArgumentAndAllFieldsBOfArg1dAreTrue_161(); - break; - case 162: - ChipLogProgress(chipTool, " ***** Test Step 162 : Send Test Command With Nested Struct List Argument and some fields b of arg1.d are false\n"); - err = TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfArg1dAreFalse_162(); - break; - case 163: - ChipLogProgress(chipTool, " ***** Test Step 163 : Send Test Command With Struct Argument and see what we get back\n"); - err = TestSendTestCommandWithStructArgumentAndSeeWhatWeGetBack_163(); - break; - case 164: - ChipLogProgress(chipTool, " ***** Test Step 164 : Send MEI command in cluster\n"); - err = TestSendMeiCommandInCluster_164(); - break; - case 165: - ChipLogProgress(chipTool, " ***** Test Step 165 : Send Test Command With List of INT8U and none of them is set to 0\n"); - err = TestSendTestCommandWithListOfInt8uAndNoneOfThemIsSetTo0_165(); - break; - case 166: - ChipLogProgress(chipTool, " ***** Test Step 166 : Send Test Command With List of INT8U and one of them is set to 0\n"); - err = TestSendTestCommandWithListOfInt8uAndOneOfThemIsSetTo0_166(); - break; - case 167: - ChipLogProgress(chipTool, " ***** Test Step 167 : Send Test Command With List of INT8U and get it reversed\n"); - err = TestSendTestCommandWithListOfInt8uAndGetItReversed_167(); - break; - case 168: - ChipLogProgress(chipTool, " ***** Test Step 168 : Send Test Command With empty List of INT8U and get an empty list back\n"); - err = TestSendTestCommandWithEmptyListOfInt8uAndGetAnEmptyListBack_168(); - break; - case 169: - ChipLogProgress(chipTool, " ***** Test Step 169 : Send Test Command With List of Struct Argument and arg1.b of first item is true\n"); - err = TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsTrue_169(); - break; - case 170: - ChipLogProgress(chipTool, " ***** Test Step 170 : Send Test Command With List of Struct Argument and arg1.b of first item is false\n"); - err = TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsFalse_170(); - break; - case 171: - ChipLogProgress(chipTool, " ***** Test Step 171 : Send Test Command With List of Nested Struct List Argument and all fields b of elements of arg1.d are true\n"); - err = TestSendTestCommandWithListOfNestedStructListArgumentAndAllFieldsBOfElementsOfArg1dAreTrue_171(); - break; - case 172: - ChipLogProgress(chipTool, " ***** Test Step 172 : Send Test Command With Nested Struct List Argument and some fields b of elements of arg1.d are false\n"); - err = TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfElementsOfArg1dAreFalse_172(); - break; - case 173: - ChipLogProgress(chipTool, " ***** Test Step 173 : Write attribute LIST With List of INT8U and none of them is set to 0\n"); - err = TestWriteAttributeListWithListOfInt8uAndNoneOfThemIsSetTo0_173(); - break; - case 174: - ChipLogProgress(chipTool, " ***** Test Step 174 : Read attribute LIST With List of INT8U\n"); - err = TestReadAttributeListWithListOfInt8u_174(); - break; - case 175: - ChipLogProgress(chipTool, " ***** Test Step 175 : Write attribute LIST With List of OCTET_STRING\n"); - err = TestWriteAttributeListWithListOfOctetString_175(); - break; - case 176: - ChipLogProgress(chipTool, " ***** Test Step 176 : Read attribute LIST With List of OCTET_STRING\n"); - err = TestReadAttributeListWithListOfOctetString_176(); - break; - case 177: - ChipLogProgress(chipTool, " ***** Test Step 177 : Write attribute LIST With List of LIST_STRUCT_OCTET_STRING\n"); - err = TestWriteAttributeListWithListOfListStructOctetString_177(); - break; - case 178: - ChipLogProgress(chipTool, " ***** Test Step 178 : Read attribute LIST With List of LIST_STRUCT_OCTET_STRING\n"); - err = TestReadAttributeListWithListOfListStructOctetString_178(); - break; - case 179: - ChipLogProgress(chipTool, " ***** Test Step 179 : Send Test Command with optional arg set.\n"); - err = TestSendTestCommandWithOptionalArgSet_179(); - break; - case 180: - ChipLogProgress(chipTool, " ***** Test Step 180 : Send Test Command without its optional arg.\n"); - err = TestSendTestCommandWithoutItsOptionalArg_180(); - break; - case 181: - ChipLogProgress(chipTool, " ***** Test Step 181 : Read list of structs containing nullables and optionals\n"); - err = TestReadListOfStructsContainingNullablesAndOptionals_181(); - break; - case 182: - ChipLogProgress(chipTool, " ***** Test Step 182 : Write list of structs containing nullables and optionals\n"); - err = TestWriteListOfStructsContainingNullablesAndOptionals_182(); - break; - case 183: - ChipLogProgress(chipTool, " ***** Test Step 183 : Read list of structs containing nullables and optionals after writing\n"); - err = TestReadListOfStructsContainingNullablesAndOptionalsAfterWriting_183(); - break; - case 184: - ChipLogProgress(chipTool, " ***** Test Step 184 : Write attribute NULLABLE_BOOLEAN null\n"); - err = TestWriteAttributeNullableBooleanNull_184(); - break; - case 185: - ChipLogProgress(chipTool, " ***** Test Step 185 : Read attribute NULLABLE_BOOLEAN null\n"); - err = TestReadAttributeNullableBooleanNull_185(); - break; - case 186: - ChipLogProgress(chipTool, " ***** Test Step 186 : Write attribute NULLABLE_BOOLEAN True\n"); - err = TestWriteAttributeNullableBooleanTrue_186(); - break; - case 187: - ChipLogProgress(chipTool, " ***** Test Step 187 : Read attribute NULLABLE_BOOLEAN True\n"); - err = TestReadAttributeNullableBooleanTrue_187(); - break; - case 188: - ChipLogProgress(chipTool, " ***** Test Step 188 : Read attribute NULLABLE_BOOLEAN not null\n"); - err = TestReadAttributeNullableBooleanNotNull_188(); - break; - case 189: - ChipLogProgress(chipTool, " ***** Test Step 189 : Write attribute NULLABLE_BITMAP8 Max Value\n"); - err = TestWriteAttributeNullableBitmap8MaxValue_189(); - break; - case 190: - ChipLogProgress(chipTool, " ***** Test Step 190 : Read attribute NULLABLE_BITMAP8 Max Value\n"); - err = TestReadAttributeNullableBitmap8MaxValue_190(); - break; - case 191: - ChipLogProgress(chipTool, " ***** Test Step 191 : Write attribute NULLABLE_BITMAP8 Invalid Value\n"); - err = TestWriteAttributeNullableBitmap8InvalidValue_191(); - break; - case 192: - ChipLogProgress(chipTool, " ***** Test Step 192 : Read attribute NULLABLE_BITMAP8 unchanged Value\n"); - err = TestReadAttributeNullableBitmap8UnchangedValue_192(); - break; - case 193: - ChipLogProgress(chipTool, " ***** Test Step 193 : Write attribute NULLABLE_BITMAP8 null Value\n"); - err = TestWriteAttributeNullableBitmap8NullValue_193(); - break; - case 194: - ChipLogProgress(chipTool, " ***** Test Step 194 : Read attribute NULLABLE_BITMAP8 null Value\n"); - err = TestReadAttributeNullableBitmap8NullValue_194(); - break; - case 195: - ChipLogProgress(chipTool, " ***** Test Step 195 : Read attribute NULLABLE_BITMAP8 not 254 Value\n"); - err = TestReadAttributeNullableBitmap8Not254Value_195(); - break; - case 196: - ChipLogProgress(chipTool, " ***** Test Step 196 : Write attribute NULLABLE_BITMAP16 Max Value\n"); - err = TestWriteAttributeNullableBitmap16MaxValue_196(); - break; - case 197: - ChipLogProgress(chipTool, " ***** Test Step 197 : Read attribute NULLABLE_BITMAP16 Max Value\n"); - err = TestReadAttributeNullableBitmap16MaxValue_197(); - break; - case 198: - ChipLogProgress(chipTool, " ***** Test Step 198 : Write attribute NULLABLE_BITMAP16 Invalid Value\n"); - err = TestWriteAttributeNullableBitmap16InvalidValue_198(); - break; - case 199: - ChipLogProgress(chipTool, " ***** Test Step 199 : Read attribute NULLABLE_BITMAP16 unchanged Value\n"); - err = TestReadAttributeNullableBitmap16UnchangedValue_199(); - break; - case 200: - ChipLogProgress(chipTool, " ***** Test Step 200 : Write attribute NULLABLE_BITMAP16 null Value\n"); - err = TestWriteAttributeNullableBitmap16NullValue_200(); - break; - case 201: - ChipLogProgress(chipTool, " ***** Test Step 201 : Read attribute NULLABLE_BITMAP16 null Value\n"); - err = TestReadAttributeNullableBitmap16NullValue_201(); - break; - case 202: - ChipLogProgress(chipTool, " ***** Test Step 202 : Write attribute NULLABLE_BITMAP32 Max Value\n"); - err = TestWriteAttributeNullableBitmap32MaxValue_202(); - break; - case 203: - ChipLogProgress(chipTool, " ***** Test Step 203 : Read attribute NULLABLE_BITMAP32 Max Value\n"); - err = TestReadAttributeNullableBitmap32MaxValue_203(); - break; - case 204: - ChipLogProgress(chipTool, " ***** Test Step 204 : Write attribute NULLABLE_BITMAP32 Invalid Value\n"); - err = TestWriteAttributeNullableBitmap32InvalidValue_204(); - break; - case 205: - ChipLogProgress(chipTool, " ***** Test Step 205 : Read attribute NULLABLE_BITMAP32 unchanged Value\n"); - err = TestReadAttributeNullableBitmap32UnchangedValue_205(); - break; - case 206: - ChipLogProgress(chipTool, " ***** Test Step 206 : Write attribute NULLABLE_BITMAP32 null Value\n"); - err = TestWriteAttributeNullableBitmap32NullValue_206(); - break; - case 207: - ChipLogProgress(chipTool, " ***** Test Step 207 : Read attribute NULLABLE_BITMAP32 null Value\n"); - err = TestReadAttributeNullableBitmap32NullValue_207(); - break; - case 208: - ChipLogProgress(chipTool, " ***** Test Step 208 : Write attribute NULLABLE_BITMAP64 Max Value\n"); - err = TestWriteAttributeNullableBitmap64MaxValue_208(); - break; - case 209: - ChipLogProgress(chipTool, " ***** Test Step 209 : Read attribute NULLABLE_BITMAP64 Max Value\n"); - err = TestReadAttributeNullableBitmap64MaxValue_209(); - break; - case 210: - ChipLogProgress(chipTool, " ***** Test Step 210 : Write attribute NULLABLE_BITMAP64 Invalid Value\n"); - err = TestWriteAttributeNullableBitmap64InvalidValue_210(); - break; - case 211: - ChipLogProgress(chipTool, " ***** Test Step 211 : Read attribute NULLABLE_BITMAP64 unchanged Value\n"); - err = TestReadAttributeNullableBitmap64UnchangedValue_211(); - break; - case 212: - ChipLogProgress(chipTool, " ***** Test Step 212 : Write attribute NULLABLE_BITMAP64 null Value\n"); - err = TestWriteAttributeNullableBitmap64NullValue_212(); - break; - case 213: - ChipLogProgress(chipTool, " ***** Test Step 213 : Read attribute NULLABLE_BITMAP64 null Value\n"); - err = TestReadAttributeNullableBitmap64NullValue_213(); - break; - case 214: - ChipLogProgress(chipTool, " ***** Test Step 214 : Write attribute NULLABLE_INT8U Min Value\n"); - err = TestWriteAttributeNullableInt8uMinValue_214(); - break; - case 215: - ChipLogProgress(chipTool, " ***** Test Step 215 : Read attribute NULLABLE_INT8U Min Value\n"); - err = TestReadAttributeNullableInt8uMinValue_215(); - break; - case 216: - ChipLogProgress(chipTool, " ***** Test Step 216 : Write attribute NULLABLE_INT8U Max Value\n"); - err = TestWriteAttributeNullableInt8uMaxValue_216(); - break; - case 217: - ChipLogProgress(chipTool, " ***** Test Step 217 : Read attribute NULLABLE_INT8U Max Value\n"); - err = TestReadAttributeNullableInt8uMaxValue_217(); - break; - case 218: - ChipLogProgress(chipTool, " ***** Test Step 218 : Write attribute NULLABLE_INT8U Invalid Value\n"); - err = TestWriteAttributeNullableInt8uInvalidValue_218(); - break; - case 219: - ChipLogProgress(chipTool, " ***** Test Step 219 : Read attribute NULLABLE_INT8U unchanged Value\n"); - err = TestReadAttributeNullableInt8uUnchangedValue_219(); - break; - case 220: - ChipLogProgress(chipTool, " ***** Test Step 220 : Read attribute NULLABLE_INT8U unchanged Value with constraint\n"); - err = TestReadAttributeNullableInt8uUnchangedValueWithConstraint_220(); - break; - case 221: - ChipLogProgress(chipTool, " ***** Test Step 221 : Write attribute NULLABLE_INT8U null Value\n"); - err = TestWriteAttributeNullableInt8uNullValue_221(); - break; - case 222: - ChipLogProgress(chipTool, " ***** Test Step 222 : Read attribute NULLABLE_INT8U null Value\n"); - err = TestReadAttributeNullableInt8uNullValue_222(); - break; - case 223: - ChipLogProgress(chipTool, " ***** Test Step 223 : Read attribute NULLABLE_INT8U null Value & range\n"); - err = TestReadAttributeNullableInt8uNullValueRange_223(); - break; - case 224: - ChipLogProgress(chipTool, " ***** Test Step 224 : Read attribute NULLABLE_INT8U null Value & not\n"); - err = TestReadAttributeNullableInt8uNullValueNot_224(); - break; - case 225: - ChipLogProgress(chipTool, " ***** Test Step 225 : Write attribute NULLABLE_INT8U Value\n"); - err = TestWriteAttributeNullableInt8uValue_225(); - break; - case 226: - ChipLogProgress(chipTool, " ***** Test Step 226 : Read attribute NULLABLE_INT8U Value in range\n"); - err = TestReadAttributeNullableInt8uValueInRange_226(); - break; - case 227: - ChipLogProgress(chipTool, " ***** Test Step 227 : Read attribute NULLABLE_INT8U notValue OK\n"); - err = TestReadAttributeNullableInt8uNotValueOk_227(); - break; - case 228: - ChipLogProgress(chipTool, " ***** Test Step 228 : Write attribute NULLABLE_INT16U Min Value\n"); - err = TestWriteAttributeNullableInt16uMinValue_228(); - break; - case 229: - ChipLogProgress(chipTool, " ***** Test Step 229 : Read attribute NULLABLE_INT16U Min Value\n"); - err = TestReadAttributeNullableInt16uMinValue_229(); - break; - case 230: - ChipLogProgress(chipTool, " ***** Test Step 230 : Write attribute NULLABLE_INT16U Max Value\n"); - err = TestWriteAttributeNullableInt16uMaxValue_230(); - break; - case 231: - ChipLogProgress(chipTool, " ***** Test Step 231 : Read attribute NULLABLE_INT16U Max Value\n"); - err = TestReadAttributeNullableInt16uMaxValue_231(); - break; - case 232: - ChipLogProgress(chipTool, " ***** Test Step 232 : Write attribute NULLABLE_INT16U Invalid Value\n"); - err = TestWriteAttributeNullableInt16uInvalidValue_232(); - break; - case 233: - ChipLogProgress(chipTool, " ***** Test Step 233 : Read attribute NULLABLE_INT16U unchanged Value\n"); - err = TestReadAttributeNullableInt16uUnchangedValue_233(); - break; - case 234: - ChipLogProgress(chipTool, " ***** Test Step 234 : Write attribute NULLABLE_INT16U null Value\n"); - err = TestWriteAttributeNullableInt16uNullValue_234(); - break; - case 235: - ChipLogProgress(chipTool, " ***** Test Step 235 : Read attribute NULLABLE_INT16U null Value\n"); - err = TestReadAttributeNullableInt16uNullValue_235(); - break; - case 236: - ChipLogProgress(chipTool, " ***** Test Step 236 : Read attribute NULLABLE_INT16U null Value & range\n"); - err = TestReadAttributeNullableInt16uNullValueRange_236(); - break; - case 237: - ChipLogProgress(chipTool, " ***** Test Step 237 : Read attribute NULLABLE_INT16U null Value & not\n"); - err = TestReadAttributeNullableInt16uNullValueNot_237(); - break; - case 238: - ChipLogProgress(chipTool, " ***** Test Step 238 : Write attribute NULLABLE_INT16U Value\n"); - err = TestWriteAttributeNullableInt16uValue_238(); - break; - case 239: - ChipLogProgress(chipTool, " ***** Test Step 239 : Read attribute NULLABLE_INT16U Value in range\n"); - err = TestReadAttributeNullableInt16uValueInRange_239(); - break; - case 240: - ChipLogProgress(chipTool, " ***** Test Step 240 : Read attribute NULLABLE_INT16U notValue OK\n"); - err = TestReadAttributeNullableInt16uNotValueOk_240(); - break; - case 241: - ChipLogProgress(chipTool, " ***** Test Step 241 : Write attribute NULLABLE_INT32U Min Value\n"); - err = TestWriteAttributeNullableInt32uMinValue_241(); - break; - case 242: - ChipLogProgress(chipTool, " ***** Test Step 242 : Read attribute NULLABLE_INT32U Min Value\n"); - err = TestReadAttributeNullableInt32uMinValue_242(); - break; - case 243: - ChipLogProgress(chipTool, " ***** Test Step 243 : Write attribute NULLABLE_INT32U Max Value\n"); - err = TestWriteAttributeNullableInt32uMaxValue_243(); - break; - case 244: - ChipLogProgress(chipTool, " ***** Test Step 244 : Read attribute NULLABLE_INT32U Max Value\n"); - err = TestReadAttributeNullableInt32uMaxValue_244(); - break; - case 245: - ChipLogProgress(chipTool, " ***** Test Step 245 : Write attribute NULLABLE_INT32U Invalid Value\n"); - err = TestWriteAttributeNullableInt32uInvalidValue_245(); - break; - case 246: - ChipLogProgress(chipTool, " ***** Test Step 246 : Read attribute NULLABLE_INT32U unchanged Value\n"); - err = TestReadAttributeNullableInt32uUnchangedValue_246(); - break; - case 247: - ChipLogProgress(chipTool, " ***** Test Step 247 : Write attribute NULLABLE_INT32U null Value\n"); - err = TestWriteAttributeNullableInt32uNullValue_247(); - break; - case 248: - ChipLogProgress(chipTool, " ***** Test Step 248 : Read attribute NULLABLE_INT32U null Value\n"); - err = TestReadAttributeNullableInt32uNullValue_248(); - break; - case 249: - ChipLogProgress(chipTool, " ***** Test Step 249 : Read attribute NULLABLE_INT32U null Value & range\n"); - err = TestReadAttributeNullableInt32uNullValueRange_249(); - break; - case 250: - ChipLogProgress(chipTool, " ***** Test Step 250 : Read attribute NULLABLE_INT32U null Value & not\n"); - err = TestReadAttributeNullableInt32uNullValueNot_250(); - break; - case 251: - ChipLogProgress(chipTool, " ***** Test Step 251 : Write attribute NULLABLE_INT32U Value\n"); - err = TestWriteAttributeNullableInt32uValue_251(); - break; - case 252: - ChipLogProgress(chipTool, " ***** Test Step 252 : Read attribute NULLABLE_INT32U Value in range\n"); - err = TestReadAttributeNullableInt32uValueInRange_252(); - break; - case 253: - ChipLogProgress(chipTool, " ***** Test Step 253 : Read attribute NULLABLE_INT32U notValue OK\n"); - err = TestReadAttributeNullableInt32uNotValueOk_253(); - break; - case 254: - ChipLogProgress(chipTool, " ***** Test Step 254 : Write attribute NULLABLE_INT64U Min Value\n"); - err = TestWriteAttributeNullableInt64uMinValue_254(); - break; - case 255: - ChipLogProgress(chipTool, " ***** Test Step 255 : Read attribute NULLABLE_INT64U Min Value\n"); - err = TestReadAttributeNullableInt64uMinValue_255(); - break; - case 256: - ChipLogProgress(chipTool, " ***** Test Step 256 : Write attribute NULLABLE_INT64U Max Value\n"); - err = TestWriteAttributeNullableInt64uMaxValue_256(); - break; - case 257: - ChipLogProgress(chipTool, " ***** Test Step 257 : Read attribute NULLABLE_INT64U Max Value\n"); - err = TestReadAttributeNullableInt64uMaxValue_257(); - break; - case 258: - ChipLogProgress(chipTool, " ***** Test Step 258 : Write attribute NULLABLE_INT64U Invalid Value\n"); - err = TestWriteAttributeNullableInt64uInvalidValue_258(); - break; - case 259: - ChipLogProgress(chipTool, " ***** Test Step 259 : Read attribute NULLABLE_INT64U unchanged Value\n"); - err = TestReadAttributeNullableInt64uUnchangedValue_259(); - break; - case 260: - ChipLogProgress(chipTool, " ***** Test Step 260 : Write attribute NULLABLE_INT64U null Value\n"); - err = TestWriteAttributeNullableInt64uNullValue_260(); - break; - case 261: - ChipLogProgress(chipTool, " ***** Test Step 261 : Read attribute NULLABLE_INT64U null Value\n"); - err = TestReadAttributeNullableInt64uNullValue_261(); - break; - case 262: - ChipLogProgress(chipTool, " ***** Test Step 262 : Read attribute NULLABLE_INT64U null Value & range\n"); - err = TestReadAttributeNullableInt64uNullValueRange_262(); - break; - case 263: - ChipLogProgress(chipTool, " ***** Test Step 263 : Read attribute NULLABLE_INT64U null Value & not\n"); - err = TestReadAttributeNullableInt64uNullValueNot_263(); - break; - case 264: - ChipLogProgress(chipTool, " ***** Test Step 264 : Write attribute NULLABLE_INT64U Value\n"); - err = TestWriteAttributeNullableInt64uValue_264(); - break; - case 265: - ChipLogProgress(chipTool, " ***** Test Step 265 : Read attribute NULLABLE_INT64U Value in range\n"); - err = TestReadAttributeNullableInt64uValueInRange_265(); - break; - case 266: - ChipLogProgress(chipTool, " ***** Test Step 266 : Read attribute NULLABLE_INT64U notValue OK\n"); - err = TestReadAttributeNullableInt64uNotValueOk_266(); - break; - case 267: - ChipLogProgress(chipTool, " ***** Test Step 267 : Write attribute NULLABLE_INT8S Min Value\n"); - err = TestWriteAttributeNullableInt8sMinValue_267(); - break; - case 268: - ChipLogProgress(chipTool, " ***** Test Step 268 : Read attribute NULLABLE_INT8S Min Value\n"); - err = TestReadAttributeNullableInt8sMinValue_268(); - break; - case 269: - ChipLogProgress(chipTool, " ***** Test Step 269 : Write attribute NULLABLE_INT8S Invalid Value\n"); - err = TestWriteAttributeNullableInt8sInvalidValue_269(); - break; - case 270: - ChipLogProgress(chipTool, " ***** Test Step 270 : Read attribute NULLABLE_INT8S unchanged Value\n"); - err = TestReadAttributeNullableInt8sUnchangedValue_270(); - break; - case 271: - ChipLogProgress(chipTool, " ***** Test Step 271 : Write attribute NULLABLE_INT8S null Value\n"); - err = TestWriteAttributeNullableInt8sNullValue_271(); - break; - case 272: - ChipLogProgress(chipTool, " ***** Test Step 272 : Read attribute NULLABLE_INT8S null Value\n"); - err = TestReadAttributeNullableInt8sNullValue_272(); - break; - case 273: - ChipLogProgress(chipTool, " ***** Test Step 273 : Read attribute NULLABLE_INT8S null Value & range\n"); - err = TestReadAttributeNullableInt8sNullValueRange_273(); - break; - case 274: - ChipLogProgress(chipTool, " ***** Test Step 274 : Read attribute NULLABLE_INT8S null Value & not\n"); - err = TestReadAttributeNullableInt8sNullValueNot_274(); - break; - case 275: - ChipLogProgress(chipTool, " ***** Test Step 275 : Write attribute NULLABLE_INT8S Value\n"); - err = TestWriteAttributeNullableInt8sValue_275(); - break; - case 276: - ChipLogProgress(chipTool, " ***** Test Step 276 : Read attribute NULLABLE_INT8S Value in range\n"); - err = TestReadAttributeNullableInt8sValueInRange_276(); - break; - case 277: - ChipLogProgress(chipTool, " ***** Test Step 277 : Read attribute NULLABLE_INT8S notValue OK\n"); - err = TestReadAttributeNullableInt8sNotValueOk_277(); - break; - case 278: - ChipLogProgress(chipTool, " ***** Test Step 278 : Write attribute NULLABLE_INT16S Min Value\n"); - err = TestWriteAttributeNullableInt16sMinValue_278(); - break; - case 279: - ChipLogProgress(chipTool, " ***** Test Step 279 : Read attribute NULLABLE_INT16S Min Value\n"); - err = TestReadAttributeNullableInt16sMinValue_279(); - break; - case 280: - ChipLogProgress(chipTool, " ***** Test Step 280 : Write attribute NULLABLE_INT16S Invalid Value\n"); - err = TestWriteAttributeNullableInt16sInvalidValue_280(); - break; - case 281: - ChipLogProgress(chipTool, " ***** Test Step 281 : Read attribute NULLABLE_INT16S unchanged Value\n"); - err = TestReadAttributeNullableInt16sUnchangedValue_281(); - break; - case 282: - ChipLogProgress(chipTool, " ***** Test Step 282 : Write attribute NULLABLE_INT16S null Value\n"); - err = TestWriteAttributeNullableInt16sNullValue_282(); - break; - case 283: - ChipLogProgress(chipTool, " ***** Test Step 283 : Read attribute NULLABLE_INT16S null Value\n"); - err = TestReadAttributeNullableInt16sNullValue_283(); - break; - case 284: - ChipLogProgress(chipTool, " ***** Test Step 284 : Read attribute NULLABLE_INT16S null Value & range\n"); - err = TestReadAttributeNullableInt16sNullValueRange_284(); - break; - case 285: - ChipLogProgress(chipTool, " ***** Test Step 285 : Read attribute NULLABLE_INT16S null Value & not\n"); - err = TestReadAttributeNullableInt16sNullValueNot_285(); - break; - case 286: - ChipLogProgress(chipTool, " ***** Test Step 286 : Write attribute NULLABLE_INT16S Value\n"); - err = TestWriteAttributeNullableInt16sValue_286(); - break; - case 287: - ChipLogProgress(chipTool, " ***** Test Step 287 : Read attribute NULLABLE_INT16S Value in range\n"); - err = TestReadAttributeNullableInt16sValueInRange_287(); - break; - case 288: - ChipLogProgress(chipTool, " ***** Test Step 288 : Read attribute NULLABLE_INT16S notValue OK\n"); - err = TestReadAttributeNullableInt16sNotValueOk_288(); - break; - case 289: - ChipLogProgress(chipTool, " ***** Test Step 289 : Write attribute NULLABLE_INT32S Min Value\n"); - err = TestWriteAttributeNullableInt32sMinValue_289(); - break; - case 290: - ChipLogProgress(chipTool, " ***** Test Step 290 : Read attribute NULLABLE_INT32S Min Value\n"); - err = TestReadAttributeNullableInt32sMinValue_290(); - break; - case 291: - ChipLogProgress(chipTool, " ***** Test Step 291 : Write attribute NULLABLE_INT32S Invalid Value\n"); - err = TestWriteAttributeNullableInt32sInvalidValue_291(); - break; - case 292: - ChipLogProgress(chipTool, " ***** Test Step 292 : Read attribute NULLABLE_INT32S unchanged Value\n"); - err = TestReadAttributeNullableInt32sUnchangedValue_292(); - break; - case 293: - ChipLogProgress(chipTool, " ***** Test Step 293 : Write attribute NULLABLE_INT32S null Value\n"); - err = TestWriteAttributeNullableInt32sNullValue_293(); - break; - case 294: - ChipLogProgress(chipTool, " ***** Test Step 294 : Read attribute NULLABLE_INT32S null Value\n"); - err = TestReadAttributeNullableInt32sNullValue_294(); - break; - case 295: - ChipLogProgress(chipTool, " ***** Test Step 295 : Read attribute NULLABLE_INT32S null Value & range\n"); - err = TestReadAttributeNullableInt32sNullValueRange_295(); - break; - case 296: - ChipLogProgress(chipTool, " ***** Test Step 296 : Read attribute NULLABLE_INT32S null Value & not\n"); - err = TestReadAttributeNullableInt32sNullValueNot_296(); - break; - case 297: - ChipLogProgress(chipTool, " ***** Test Step 297 : Write attribute NULLABLE_INT32S Value\n"); - err = TestWriteAttributeNullableInt32sValue_297(); - break; - case 298: - ChipLogProgress(chipTool, " ***** Test Step 298 : Read attribute NULLABLE_INT32S Value in range\n"); - err = TestReadAttributeNullableInt32sValueInRange_298(); - break; - case 299: - ChipLogProgress(chipTool, " ***** Test Step 299 : Read attribute NULLABLE_INT32S notValue OK\n"); - err = TestReadAttributeNullableInt32sNotValueOk_299(); - break; - case 300: - ChipLogProgress(chipTool, " ***** Test Step 300 : Write attribute NULLABLE_INT64S Min Value\n"); - err = TestWriteAttributeNullableInt64sMinValue_300(); - break; - case 301: - ChipLogProgress(chipTool, " ***** Test Step 301 : Read attribute NULLABLE_INT64S Min Value\n"); - err = TestReadAttributeNullableInt64sMinValue_301(); - break; - case 302: - ChipLogProgress(chipTool, " ***** Test Step 302 : Write attribute NULLABLE_INT64S Invalid Value\n"); - err = TestWriteAttributeNullableInt64sInvalidValue_302(); - break; - case 303: - ChipLogProgress(chipTool, " ***** Test Step 303 : Read attribute NULLABLE_INT64S unchanged Value\n"); - err = TestReadAttributeNullableInt64sUnchangedValue_303(); - break; - case 304: - ChipLogProgress(chipTool, " ***** Test Step 304 : Write attribute NULLABLE_INT64S null Value\n"); - err = TestWriteAttributeNullableInt64sNullValue_304(); - break; - case 305: - ChipLogProgress(chipTool, " ***** Test Step 305 : Read attribute NULLABLE_INT64S null Value\n"); - err = TestReadAttributeNullableInt64sNullValue_305(); - break; - case 306: - ChipLogProgress(chipTool, " ***** Test Step 306 : Read attribute NULLABLE_INT64S null Value & range\n"); - err = TestReadAttributeNullableInt64sNullValueRange_306(); - break; - case 307: - ChipLogProgress(chipTool, " ***** Test Step 307 : Read attribute NULLABLE_INT64S null Value & not\n"); - err = TestReadAttributeNullableInt64sNullValueNot_307(); - break; - case 308: - ChipLogProgress(chipTool, " ***** Test Step 308 : Write attribute NULLABLE_INT64S Value\n"); - err = TestWriteAttributeNullableInt64sValue_308(); - break; - case 309: - ChipLogProgress(chipTool, " ***** Test Step 309 : Read attribute NULLABLE_INT64S Value in range\n"); - err = TestReadAttributeNullableInt64sValueInRange_309(); - break; - case 310: - ChipLogProgress(chipTool, " ***** Test Step 310 : Read attribute NULLABLE_INT64S notValue OK\n"); - err = TestReadAttributeNullableInt64sNotValueOk_310(); - break; - case 311: - ChipLogProgress(chipTool, " ***** Test Step 311 : Write attribute NULLABLE_SINGLE medium Value\n"); - err = TestWriteAttributeNullableSingleMediumValue_311(); - break; - case 312: - ChipLogProgress(chipTool, " ***** Test Step 312 : Read attribute NULLABLE_SINGLE medium Value\n"); - err = TestReadAttributeNullableSingleMediumValue_312(); - break; - case 313: - ChipLogProgress(chipTool, " ***** Test Step 313 : Write attribute NULLABLE_SINGLE largest Value\n"); - err = TestWriteAttributeNullableSingleLargestValue_313(); - break; - case 314: - ChipLogProgress(chipTool, " ***** Test Step 314 : Read attribute NULLABLE_SINGLE largest Value\n"); - err = TestReadAttributeNullableSingleLargestValue_314(); - break; - case 315: - ChipLogProgress(chipTool, " ***** Test Step 315 : Write attribute NULLABLE_SINGLE smallest Value\n"); - err = TestWriteAttributeNullableSingleSmallestValue_315(); - break; - case 316: - ChipLogProgress(chipTool, " ***** Test Step 316 : Read attribute NULLABLE_SINGLE smallest Value\n"); - err = TestReadAttributeNullableSingleSmallestValue_316(); - break; - case 317: - ChipLogProgress(chipTool, " ***** Test Step 317 : Write attribute NULLABLE_SINGLE null Value\n"); - err = TestWriteAttributeNullableSingleNullValue_317(); - break; - case 318: - ChipLogProgress(chipTool, " ***** Test Step 318 : Read attribute NULLABLE_SINGLE null Value\n"); - err = TestReadAttributeNullableSingleNullValue_318(); - break; - case 319: - ChipLogProgress(chipTool, " ***** Test Step 319 : Write attribute NULLABLE_SINGLE 0 Value\n"); - err = TestWriteAttributeNullableSingle0Value_319(); - break; - case 320: - ChipLogProgress(chipTool, " ***** Test Step 320 : Read attribute NULLABLE_SINGLE 0 Value\n"); - err = TestReadAttributeNullableSingle0Value_320(); - break; - case 321: - ChipLogProgress(chipTool, " ***** Test Step 321 : Write attribute NULLABLE_DOUBLE medium Value\n"); - err = TestWriteAttributeNullableDoubleMediumValue_321(); - break; - case 322: - ChipLogProgress(chipTool, " ***** Test Step 322 : Read attribute NULLABLE_DOUBLE medium Value\n"); - err = TestReadAttributeNullableDoubleMediumValue_322(); - break; - case 323: - ChipLogProgress(chipTool, " ***** Test Step 323 : Write attribute NULLABLE_DOUBLE largest Value\n"); - err = TestWriteAttributeNullableDoubleLargestValue_323(); - break; - case 324: - ChipLogProgress(chipTool, " ***** Test Step 324 : Read attribute NULLABLE_DOUBLE largest Value\n"); - err = TestReadAttributeNullableDoubleLargestValue_324(); - break; - case 325: - ChipLogProgress(chipTool, " ***** Test Step 325 : Write attribute NULLABLE_DOUBLE smallest Value\n"); - err = TestWriteAttributeNullableDoubleSmallestValue_325(); - break; - case 326: - ChipLogProgress(chipTool, " ***** Test Step 326 : Read attribute NULLABLE_DOUBLE smallest Value\n"); - err = TestReadAttributeNullableDoubleSmallestValue_326(); - break; - case 327: - ChipLogProgress(chipTool, " ***** Test Step 327 : Write attribute NULLABLE_DOUBLE null Value\n"); - err = TestWriteAttributeNullableDoubleNullValue_327(); - break; - case 328: - ChipLogProgress(chipTool, " ***** Test Step 328 : Read attribute NULLABLE_DOUBLE null Value\n"); - err = TestReadAttributeNullableDoubleNullValue_328(); - break; - case 329: - ChipLogProgress(chipTool, " ***** Test Step 329 : Write attribute NULLABLE_DOUBLE 0 Value\n"); - err = TestWriteAttributeNullableDouble0Value_329(); - break; - case 330: - ChipLogProgress(chipTool, " ***** Test Step 330 : Read attribute NULLABLE_DOUBLE 0 Value\n"); - err = TestReadAttributeNullableDouble0Value_330(); - break; - case 331: - ChipLogProgress(chipTool, " ***** Test Step 331 : Write attribute NULLABLE_ENUM8 Min Value\n"); - err = TestWriteAttributeNullableEnum8MinValue_331(); - break; - case 332: - ChipLogProgress(chipTool, " ***** Test Step 332 : Read attribute NULLABLE_ENUM8 Min Value\n"); - err = TestReadAttributeNullableEnum8MinValue_332(); - break; - case 333: - ChipLogProgress(chipTool, " ***** Test Step 333 : Write attribute NULLABLE_ENUM8 Max Value\n"); - err = TestWriteAttributeNullableEnum8MaxValue_333(); - break; - case 334: - ChipLogProgress(chipTool, " ***** Test Step 334 : Read attribute NULLABLE_ENUM8 Max Value\n"); - err = TestReadAttributeNullableEnum8MaxValue_334(); - break; - case 335: - ChipLogProgress(chipTool, " ***** Test Step 335 : Write attribute NULLABLE_ENUM8 Invalid Value\n"); - err = TestWriteAttributeNullableEnum8InvalidValue_335(); - break; - case 336: - ChipLogProgress(chipTool, " ***** Test Step 336 : Read attribute NULLABLE_ENUM8 unchanged Value\n"); - err = TestReadAttributeNullableEnum8UnchangedValue_336(); - break; - case 337: - ChipLogProgress(chipTool, " ***** Test Step 337 : Write attribute NULLABLE_ENUM8 null Value\n"); - err = TestWriteAttributeNullableEnum8NullValue_337(); - break; - case 338: - ChipLogProgress(chipTool, " ***** Test Step 338 : Read attribute NULLABLE_ENUM8 null Value\n"); - err = TestReadAttributeNullableEnum8NullValue_338(); - break; - case 339: - ChipLogProgress(chipTool, " ***** Test Step 339 : Write attribute NULLABLE_ENUM16 Min Value\n"); - err = TestWriteAttributeNullableEnum16MinValue_339(); - break; - case 340: - ChipLogProgress(chipTool, " ***** Test Step 340 : Read attribute NULLABLE_ENUM16 Min Value\n"); - err = TestReadAttributeNullableEnum16MinValue_340(); - break; - case 341: - ChipLogProgress(chipTool, " ***** Test Step 341 : Write attribute NULLABLE_ENUM16 Max Value\n"); - err = TestWriteAttributeNullableEnum16MaxValue_341(); - break; - case 342: - ChipLogProgress(chipTool, " ***** Test Step 342 : Read attribute NULLABLE_ENUM16 Max Value\n"); - err = TestReadAttributeNullableEnum16MaxValue_342(); - break; - case 343: - ChipLogProgress(chipTool, " ***** Test Step 343 : Write attribute NULLABLE_ENUM16 Invalid Value\n"); - err = TestWriteAttributeNullableEnum16InvalidValue_343(); - break; - case 344: - ChipLogProgress(chipTool, " ***** Test Step 344 : Read attribute NULLABLE_ENUM16 unchanged Value\n"); - err = TestReadAttributeNullableEnum16UnchangedValue_344(); - break; - case 345: - ChipLogProgress(chipTool, " ***** Test Step 345 : Write attribute NULLABLE_ENUM16 null Value\n"); - err = TestWriteAttributeNullableEnum16NullValue_345(); - break; - case 346: - ChipLogProgress(chipTool, " ***** Test Step 346 : Read attribute NULLABLE_ENUM16 null Value\n"); - err = TestReadAttributeNullableEnum16NullValue_346(); - break; - case 347: - ChipLogProgress(chipTool, " ***** Test Step 347 : Write attribute NULLABLE_SIMPLE_ENUM Min Value\n"); - err = TestWriteAttributeNullableSimpleEnumMinValue_347(); - break; - case 348: - ChipLogProgress(chipTool, " ***** Test Step 348 : Read attribute NULLABLE_SIMPLE_ENUM Min Value\n"); - err = TestReadAttributeNullableSimpleEnumMinValue_348(); - break; - case 349: - ChipLogProgress(chipTool, " ***** Test Step 349 : Write attribute NULLABLE_SIMPLE_ENUM Max Value\n"); - err = TestWriteAttributeNullableSimpleEnumMaxValue_349(); - break; - case 350: - ChipLogProgress(chipTool, " ***** Test Step 350 : Read attribute NULLABLE_SIMPLE_ENUM Max Value\n"); - err = TestReadAttributeNullableSimpleEnumMaxValue_350(); - break; - case 351: - ChipLogProgress(chipTool, " ***** Test Step 351 : Write attribute NULLABLE_SIMPLE_ENUM Invalid Value\n"); - err = TestWriteAttributeNullableSimpleEnumInvalidValue_351(); - break; - case 352: - ChipLogProgress(chipTool, " ***** Test Step 352 : Read attribute NULLABLE_SIMPLE_ENUM unchanged Value\n"); - err = TestReadAttributeNullableSimpleEnumUnchangedValue_352(); - break; - case 353: - ChipLogProgress(chipTool, " ***** Test Step 353 : Write attribute NULLABLE_SIMPLE_ENUM null Value\n"); - err = TestWriteAttributeNullableSimpleEnumNullValue_353(); - break; - case 354: - ChipLogProgress(chipTool, " ***** Test Step 354 : Read attribute NULLABLE_SIMPLE_ENUM null Value\n"); - err = TestReadAttributeNullableSimpleEnumNullValue_354(); - break; - case 355: - ChipLogProgress(chipTool, " ***** Test Step 355 : Read attribute NULLABLE_SIMPLE_ENUM not 3 Value\n"); - err = TestReadAttributeNullableSimpleEnumNot3Value_355(); - break; - case 356: - ChipLogProgress(chipTool, " ***** Test Step 356 : Read attribute NULLABLE_OCTET_STRING Default Value\n"); - err = TestReadAttributeNullableOctetStringDefaultValue_356(); - break; - case 357: - ChipLogProgress(chipTool, " ***** Test Step 357 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_357(); - break; - case 358: - ChipLogProgress(chipTool, " ***** Test Step 358 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_358(); - break; - case 359: - ChipLogProgress(chipTool, " ***** Test Step 359 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_359(); - break; - case 360: - ChipLogProgress(chipTool, " ***** Test Step 360 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_360(); - break; - case 361: - ChipLogProgress(chipTool, " ***** Test Step 361 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_361(); - break; - case 362: - ChipLogProgress(chipTool, " ***** Test Step 362 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_362(); - break; - case 363: - ChipLogProgress(chipTool, " ***** Test Step 363 : Read attribute NULLABLE_OCTET_STRING not TestValue\n"); - err = TestReadAttributeNullableOctetStringNotTestValue_363(); - break; - case 364: - ChipLogProgress(chipTool, " ***** Test Step 364 : Read attribute NULLABLE_CHAR_STRING Default Value\n"); - err = TestReadAttributeNullableCharStringDefaultValue_364(); - break; - case 365: - ChipLogProgress(chipTool, " ***** Test Step 365 : Write attribute NULLABLE_CHAR_STRING\n"); - err = TestWriteAttributeNullableCharString_365(); - break; - case 366: - ChipLogProgress(chipTool, " ***** Test Step 366 : Read attribute NULLABLE_CHAR_STRING\n"); - err = TestReadAttributeNullableCharString_366(); - break; - case 367: - ChipLogProgress(chipTool, " ***** Test Step 367 : Read attribute NULLABLE_CHAR_STRING\n"); - err = TestReadAttributeNullableCharString_367(); - break; - case 368: - ChipLogProgress(chipTool, " ***** Test Step 368 : Write attribute NULLABLE_CHAR_STRING - Value too long\n"); - err = TestWriteAttributeNullableCharStringValueTooLong_368(); - break; - case 369: - ChipLogProgress(chipTool, " ***** Test Step 369 : Read attribute NULLABLE_CHAR_STRING\n"); - err = TestReadAttributeNullableCharString_369(); - break; - case 370: - ChipLogProgress(chipTool, " ***** Test Step 370 : Write attribute NULLABLE_CHAR_STRING - Empty\n"); - err = TestWriteAttributeNullableCharStringEmpty_370(); - break; - case 371: - ChipLogProgress(chipTool, " ***** Test Step 371 : Read attribute NULLABLE_CHAR_STRING\n"); - err = TestReadAttributeNullableCharString_371(); - break; - case 372: - ChipLogProgress(chipTool, " ***** Test Step 372 : Read attribute NULLABLE_CHAR_STRING not ☉T☉\n"); - err = TestReadAttributeNullableCharStringNott_372(); - break; - case 373: - ChipLogProgress(chipTool, " ***** Test Step 373 : Read attribute from nonexistent endpoint.\n"); - err = TestReadAttributeFromNonexistentEndpoint_373(); - break; - case 374: - ChipLogProgress(chipTool, " ***** Test Step 374 : Read attribute from nonexistent cluster.\n"); - err = TestReadAttributeFromNonexistentCluster_374(); - break; - case 375: - ChipLogProgress(chipTool, " ***** Test Step 375 : Send a command that takes an optional parameter but do not set it.\n"); - err = TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_375(); - break; - case 376: - ChipLogProgress(chipTool, " ***** Test Step 376 : Send a command that takes an optional parameter but do not set it.\n"); - err = TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_376(); - break; - case 377: - ChipLogProgress(chipTool, " ***** Test Step 377 : Report: Subscribe to list attribute\n"); - err = TestReportSubscribeToListAttribute_377(); - break; - case 378: - ChipLogProgress(chipTool, " ***** Test Step 378 : Subscribe to list attribute\n"); - err = TestSubscribeToListAttribute_378(); - break; - case 379: - ChipLogProgress(chipTool, " ***** Test Step 379 : Write subscribed-to list attribute\n"); - err = TestWriteSubscribedToListAttribute_379(); - break; - case 380: - ChipLogProgress(chipTool, " ***** Test Step 380 : Check for list attribute report\n"); - err = TestCheckForListAttributeReport_380(); - break; - case 381: - ChipLogProgress(chipTool, " ***** Test Step 381 : Read range-restricted unsigned 8-bit integer\n"); - err = TestReadRangeRestrictedUnsigned8BitInteger_381(); - break; - case 382: - ChipLogProgress(chipTool, " ***** Test Step 382 : Write min value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMinValueToARangeRestrictedUnsigned8BitInteger_382(); - break; - case 383: - ChipLogProgress(chipTool, " ***** Test Step 383 : Write just-below-range value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteJustBelowRangeValueToARangeRestrictedUnsigned8BitInteger_383(); - break; - case 384: - ChipLogProgress(chipTool, " ***** Test Step 384 : Write just-above-range value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteJustAboveRangeValueToARangeRestrictedUnsigned8BitInteger_384(); - break; - case 385: - ChipLogProgress(chipTool, " ***** Test Step 385 : Write max value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMaxValueToARangeRestrictedUnsigned8BitInteger_385(); - break; - case 386: - ChipLogProgress(chipTool, " ***** Test Step 386 : Verify range-restricted unsigned 8-bit integer value has not changed\n"); - err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_386(); - break; - case 387: - ChipLogProgress(chipTool, " ***** Test Step 387 : Write min valid value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMinValidValueToARangeRestrictedUnsigned8BitInteger_387(); - break; - case 388: - ChipLogProgress(chipTool, " ***** Test Step 388 : Verify range-restricted unsigned 8-bit integer value is at min valid\n"); - err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_388(); - break; - case 389: - ChipLogProgress(chipTool, " ***** Test Step 389 : Write max valid value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMaxValidValueToARangeRestrictedUnsigned8BitInteger_389(); - break; - case 390: - ChipLogProgress(chipTool, " ***** Test Step 390 : Verify range-restricted unsigned 8-bit integer value is at max valid\n"); - err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_390(); - break; - case 391: - ChipLogProgress(chipTool, " ***** Test Step 391 : Write middle valid value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMiddleValidValueToARangeRestrictedUnsigned8BitInteger_391(); - break; - case 392: - ChipLogProgress(chipTool, " ***** Test Step 392 : Verify range-restricted unsigned 8-bit integer value is at mid valid\n"); - err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_392(); - break; - case 393: - ChipLogProgress(chipTool, " ***** Test Step 393 : Read range-restricted unsigned 16-bit integer\n"); - err = TestReadRangeRestrictedUnsigned16BitInteger_393(); - break; - case 394: - ChipLogProgress(chipTool, " ***** Test Step 394 : Write min value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMinValueToARangeRestrictedUnsigned16BitInteger_394(); - break; - case 395: - ChipLogProgress(chipTool, " ***** Test Step 395 : Write just-below-range value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteJustBelowRangeValueToARangeRestrictedUnsigned16BitInteger_395(); - break; - case 396: - ChipLogProgress(chipTool, " ***** Test Step 396 : Write just-above-range value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteJustAboveRangeValueToARangeRestrictedUnsigned16BitInteger_396(); - break; - case 397: - ChipLogProgress(chipTool, " ***** Test Step 397 : Write max value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMaxValueToARangeRestrictedUnsigned16BitInteger_397(); - break; - case 398: - ChipLogProgress(chipTool, " ***** Test Step 398 : Verify range-restricted unsigned 16-bit integer value has not changed\n"); - err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_398(); - break; - case 399: - ChipLogProgress(chipTool, " ***** Test Step 399 : Write min valid value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMinValidValueToARangeRestrictedUnsigned16BitInteger_399(); - break; - case 400: - ChipLogProgress(chipTool, " ***** Test Step 400 : Verify range-restricted unsigned 16-bit integer value is at min valid\n"); - err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_400(); - break; - case 401: - ChipLogProgress(chipTool, " ***** Test Step 401 : Write max valid value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMaxValidValueToARangeRestrictedUnsigned16BitInteger_401(); - break; - case 402: - ChipLogProgress(chipTool, " ***** Test Step 402 : Verify range-restricted unsigned 16-bit integer value is at max valid\n"); - err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_402(); - break; - case 403: - ChipLogProgress(chipTool, " ***** Test Step 403 : Write middle valid value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMiddleValidValueToARangeRestrictedUnsigned16BitInteger_403(); - break; - case 404: - ChipLogProgress(chipTool, " ***** Test Step 404 : Verify range-restricted unsigned 16-bit integer value is at mid valid\n"); - err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_404(); - break; - case 405: - ChipLogProgress(chipTool, " ***** Test Step 405 : Read range-restricted signed 8-bit integer\n"); - err = TestReadRangeRestrictedSigned8BitInteger_405(); - break; - case 406: - ChipLogProgress(chipTool, " ***** Test Step 406 : Write min value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMinValueToARangeRestrictedSigned8BitInteger_406(); - break; - case 407: - ChipLogProgress(chipTool, " ***** Test Step 407 : Write just-below-range value to a range-restricted signed 8-bit integer\n"); - err = TestWriteJustBelowRangeValueToARangeRestrictedSigned8BitInteger_407(); - break; - case 408: - ChipLogProgress(chipTool, " ***** Test Step 408 : Write just-above-range value to a range-restricted signed 8-bit integer\n"); - err = TestWriteJustAboveRangeValueToARangeRestrictedSigned8BitInteger_408(); - break; - case 409: - ChipLogProgress(chipTool, " ***** Test Step 409 : Write max value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMaxValueToARangeRestrictedSigned8BitInteger_409(); - break; - case 410: - ChipLogProgress(chipTool, " ***** Test Step 410 : Verify range-restricted signed 8-bit integer value has not changed\n"); - err = TestVerifyRangeRestrictedSigned8BitIntegerValueHasNotChanged_410(); - break; - case 411: - ChipLogProgress(chipTool, " ***** Test Step 411 : Write min valid value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMinValidValueToARangeRestrictedSigned8BitInteger_411(); - break; - case 412: - ChipLogProgress(chipTool, " ***** Test Step 412 : Verify range-restricted signed 8-bit integer value is at min valid\n"); - err = TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMinValid_412(); - break; - case 413: - ChipLogProgress(chipTool, " ***** Test Step 413 : Write max valid value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMaxValidValueToARangeRestrictedSigned8BitInteger_413(); - break; - case 414: - ChipLogProgress(chipTool, " ***** Test Step 414 : Verify range-restricted signed 8-bit integer value is at max valid\n"); - err = TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_414(); - break; - case 415: - ChipLogProgress(chipTool, " ***** Test Step 415 : Write middle valid value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMiddleValidValueToARangeRestrictedSigned8BitInteger_415(); - break; - case 416: - ChipLogProgress(chipTool, " ***** Test Step 416 : Verify range-restricted signed 8-bit integer value is at mid valid\n"); - err = TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMidValid_416(); - break; - case 417: - ChipLogProgress(chipTool, " ***** Test Step 417 : Read range-restricted signed 16-bit integer\n"); - err = TestReadRangeRestrictedSigned16BitInteger_417(); - break; - case 418: - ChipLogProgress(chipTool, " ***** Test Step 418 : Write min value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMinValueToARangeRestrictedSigned16BitInteger_418(); - break; - case 419: - ChipLogProgress(chipTool, " ***** Test Step 419 : Write just-below-range value to a range-restricted signed 16-bit integer\n"); - err = TestWriteJustBelowRangeValueToARangeRestrictedSigned16BitInteger_419(); - break; - case 420: - ChipLogProgress(chipTool, " ***** Test Step 420 : Write just-above-range value to a range-restricted signed 16-bit integer\n"); - err = TestWriteJustAboveRangeValueToARangeRestrictedSigned16BitInteger_420(); - break; - case 421: - ChipLogProgress(chipTool, " ***** Test Step 421 : Write max value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMaxValueToARangeRestrictedSigned16BitInteger_421(); - break; - case 422: - ChipLogProgress(chipTool, " ***** Test Step 422 : Verify range-restricted signed 16-bit integer value has not changed\n"); - err = TestVerifyRangeRestrictedSigned16BitIntegerValueHasNotChanged_422(); - break; - case 423: - ChipLogProgress(chipTool, " ***** Test Step 423 : Write min valid value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMinValidValueToARangeRestrictedSigned16BitInteger_423(); - break; - case 424: - ChipLogProgress(chipTool, " ***** Test Step 424 : Verify range-restricted signed 16-bit integer value is at min valid\n"); - err = TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMinValid_424(); - break; - case 425: - ChipLogProgress(chipTool, " ***** Test Step 425 : Write max valid value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMaxValidValueToARangeRestrictedSigned16BitInteger_425(); - break; - case 426: - ChipLogProgress(chipTool, " ***** Test Step 426 : Verify range-restricted signed 16-bit integer value is at max valid\n"); - err = TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_426(); - break; - case 427: - ChipLogProgress(chipTool, " ***** Test Step 427 : Write middle valid value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMiddleValidValueToARangeRestrictedSigned16BitInteger_427(); - break; - case 428: - ChipLogProgress(chipTool, " ***** Test Step 428 : Verify range-restricted signed 16-bit integer value is at mid valid\n"); - err = TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMidValid_428(); - break; - case 429: - ChipLogProgress(chipTool, " ***** Test Step 429 : Read nullable range-restricted unsigned 8-bit integer\n"); - err = TestReadNullableRangeRestrictedUnsigned8BitInteger_429(); - break; - case 430: - ChipLogProgress(chipTool, " ***** Test Step 430 : Write min value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMinValueToANullableRangeRestrictedUnsigned8BitInteger_430(); - break; - case 431: - ChipLogProgress(chipTool, " ***** Test Step 431 : Write just-below-range value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned8BitInteger_431(); - break; - case 432: - ChipLogProgress(chipTool, " ***** Test Step 432 : Write just-above-range value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned8BitInteger_432(); - break; - case 433: - ChipLogProgress(chipTool, " ***** Test Step 433 : Write max value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMaxValueToANullableRangeRestrictedUnsigned8BitInteger_433(); - break; - case 434: - ChipLogProgress(chipTool, " ***** Test Step 434 : Verify nullable range-restricted unsigned 8-bit integer value has not changed\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_434(); - break; - case 435: - ChipLogProgress(chipTool, " ***** Test Step 435 : Write min valid value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMinValidValueToANullableRangeRestrictedUnsigned8BitInteger_435(); - break; - case 436: - ChipLogProgress(chipTool, " ***** Test Step 436 : Verify nullable range-restricted unsigned 8-bit integer value is at min valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_436(); - break; - case 437: - ChipLogProgress(chipTool, " ***** Test Step 437 : Write max valid value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMaxValidValueToANullableRangeRestrictedUnsigned8BitInteger_437(); - break; - case 438: - ChipLogProgress(chipTool, " ***** Test Step 438 : Verify nullable range-restricted unsigned 8-bit integer value is at max valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_438(); - break; - case 439: - ChipLogProgress(chipTool, " ***** Test Step 439 : Write middle valid value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned8BitInteger_439(); - break; - case 440: - ChipLogProgress(chipTool, " ***** Test Step 440 : Verify nullable range-restricted unsigned 8-bit integer value is at mid valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_440(); - break; - case 441: - ChipLogProgress(chipTool, " ***** Test Step 441 : Write null value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteNullValueToANullableRangeRestrictedUnsigned8BitInteger_441(); - break; - case 442: - ChipLogProgress(chipTool, " ***** Test Step 442 : Verify nullable range-restricted unsigned 8-bit integer value is null\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsNull_442(); - break; - case 443: - ChipLogProgress(chipTool, " ***** Test Step 443 : Read nullable range-restricted unsigned 16-bit integer\n"); - err = TestReadNullableRangeRestrictedUnsigned16BitInteger_443(); - break; - case 444: - ChipLogProgress(chipTool, " ***** Test Step 444 : Write min value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMinValueToANullableRangeRestrictedUnsigned16BitInteger_444(); - break; - case 445: - ChipLogProgress(chipTool, " ***** Test Step 445 : Write just-below-range value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned16BitInteger_445(); - break; - case 446: - ChipLogProgress(chipTool, " ***** Test Step 446 : Write just-above-range value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned16BitInteger_446(); - break; - case 447: - ChipLogProgress(chipTool, " ***** Test Step 447 : Write max value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMaxValueToANullableRangeRestrictedUnsigned16BitInteger_447(); - break; - case 448: - ChipLogProgress(chipTool, " ***** Test Step 448 : Verify nullable range-restricted unsigned 16-bit integer value has not changed\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_448(); - break; - case 449: - ChipLogProgress(chipTool, " ***** Test Step 449 : Write min valid value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMinValidValueToANullableRangeRestrictedUnsigned16BitInteger_449(); - break; - case 450: - ChipLogProgress(chipTool, " ***** Test Step 450 : Verify nullable range-restricted unsigned 16-bit integer value is at min valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_450(); - break; - case 451: - ChipLogProgress(chipTool, " ***** Test Step 451 : Write max valid value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMaxValidValueToANullableRangeRestrictedUnsigned16BitInteger_451(); - break; - case 452: - ChipLogProgress(chipTool, " ***** Test Step 452 : Verify nullable range-restricted unsigned 16-bit integer value is at max valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_452(); - break; - case 453: - ChipLogProgress(chipTool, " ***** Test Step 453 : Write middle valid value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned16BitInteger_453(); - break; - case 454: - ChipLogProgress(chipTool, " ***** Test Step 454 : Verify nullable range-restricted unsigned 16-bit integer value is at mid valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_454(); - break; - case 455: - ChipLogProgress(chipTool, " ***** Test Step 455 : Write null value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteNullValueToANullableRangeRestrictedUnsigned16BitInteger_455(); - break; - case 456: - ChipLogProgress(chipTool, " ***** Test Step 456 : Verify nullable range-restricted unsigned 16-bit integer value is null\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsNull_456(); - break; - case 457: - ChipLogProgress(chipTool, " ***** Test Step 457 : Read nullable range-restricted signed 8-bit integer\n"); - err = TestReadNullableRangeRestrictedSigned8BitInteger_457(); - break; - case 458: - ChipLogProgress(chipTool, " ***** Test Step 458 : Write min value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMinValueToANullableRangeRestrictedSigned8BitInteger_458(); - break; - case 459: - ChipLogProgress(chipTool, " ***** Test Step 459 : Write just-below-range value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned8BitInteger_459(); - break; - case 460: - ChipLogProgress(chipTool, " ***** Test Step 460 : Write just-above-range value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned8BitInteger_460(); - break; - case 461: - ChipLogProgress(chipTool, " ***** Test Step 461 : Write max value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMaxValueToANullableRangeRestrictedSigned8BitInteger_461(); - break; - case 462: - ChipLogProgress(chipTool, " ***** Test Step 462 : Verify nullable range-restricted signed 8-bit integer value has not changed\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueHasNotChanged_462(); - break; - case 463: - ChipLogProgress(chipTool, " ***** Test Step 463 : Write min valid value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMinValidValueToANullableRangeRestrictedSigned8BitInteger_463(); - break; - case 464: - ChipLogProgress(chipTool, " ***** Test Step 464 : Verify nullable range-restricted signed 8-bit integer value is at min valid\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMinValid_464(); - break; - case 465: - ChipLogProgress(chipTool, " ***** Test Step 465 : Write max valid value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMaxValidValueToANullableRangeRestrictedSigned8BitInteger_465(); - break; - case 466: - ChipLogProgress(chipTool, " ***** Test Step 466 : Verify nullable range-restricted signed 8-bit integer value is at max valid\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_466(); - break; - case 467: - ChipLogProgress(chipTool, " ***** Test Step 467 : Write middle valid value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMiddleValidValueToANullableRangeRestrictedSigned8BitInteger_467(); - break; - case 468: - ChipLogProgress(chipTool, " ***** Test Step 468 : Verify nullable range-restricted signed 8-bit integer value is at mid valid\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMidValid_468(); - break; - case 469: - ChipLogProgress(chipTool, " ***** Test Step 469 : Write null value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteNullValueToANullableRangeRestrictedSigned8BitInteger_469(); - break; - case 470: - ChipLogProgress(chipTool, " ***** Test Step 470 : Verify nullable range-restricted signed 8-bit integer value is at null\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtNull_470(); - break; - case 471: - ChipLogProgress(chipTool, " ***** Test Step 471 : Read nullable range-restricted signed 16-bit integer\n"); - err = TestReadNullableRangeRestrictedSigned16BitInteger_471(); - break; - case 472: - ChipLogProgress(chipTool, " ***** Test Step 472 : Write min value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMinValueToANullableRangeRestrictedSigned16BitInteger_472(); - break; - case 473: - ChipLogProgress(chipTool, " ***** Test Step 473 : Write just-below-range value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned16BitInteger_473(); - break; - case 474: - ChipLogProgress(chipTool, " ***** Test Step 474 : Write just-above-range value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned16BitInteger_474(); - break; - case 475: - ChipLogProgress(chipTool, " ***** Test Step 475 : Write max value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMaxValueToANullableRangeRestrictedSigned16BitInteger_475(); - break; - case 476: - ChipLogProgress(chipTool, " ***** Test Step 476 : Verify nullable range-restricted signed 16-bit integer value has not changed\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueHasNotChanged_476(); - break; - case 477: - ChipLogProgress(chipTool, " ***** Test Step 477 : Write min valid value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMinValidValueToANullableRangeRestrictedSigned16BitInteger_477(); - break; - case 478: - ChipLogProgress(chipTool, " ***** Test Step 478 : Verify nullable range-restricted signed 16-bit integer value is at min valid\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMinValid_478(); - break; - case 479: - ChipLogProgress(chipTool, " ***** Test Step 479 : Write max valid value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMaxValidValueToANullableRangeRestrictedSigned16BitInteger_479(); - break; - case 480: - ChipLogProgress(chipTool, " ***** Test Step 480 : Verify nullable range-restricted signed 16-bit integer value is at max valid\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_480(); - break; - case 481: - ChipLogProgress(chipTool, " ***** Test Step 481 : Write middle valid value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMiddleValidValueToANullableRangeRestrictedSigned16BitInteger_481(); - break; - case 482: - ChipLogProgress(chipTool, " ***** Test Step 482 : Verify nullable range-restricted signed 16-bit integer value is at mid valid\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMidValid_482(); - break; - case 483: - ChipLogProgress(chipTool, " ***** Test Step 483 : Write null value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteNullValueToANullableRangeRestrictedSigned16BitInteger_483(); - break; - case 484: - ChipLogProgress(chipTool, " ***** Test Step 484 : Verify nullable range-restricted signed 16-bit integer value is null\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsNull_484(); - break; - case 485: - ChipLogProgress(chipTool, " ***** Test Step 485 : Write attribute that returns general status on write\n"); - err = TestWriteAttributeThatReturnsGeneralStatusOnWrite_485(); - break; - case 486: - ChipLogProgress(chipTool, " ***** Test Step 486 : Write attribute that returns cluster-specific status on write\n"); - err = TestWriteAttributeThatReturnsClusterSpecificStatusOnWrite_486(); - break; - case 487: - ChipLogProgress(chipTool, " ***** Test Step 487 : Read attribute that returns general status on read\n"); - err = TestReadAttributeThatReturnsGeneralStatusOnRead_487(); - break; - case 488: - ChipLogProgress(chipTool, " ***** Test Step 488 : read attribute that returns cluster-specific status on read\n"); - err = TestReadAttributeThatReturnsClusterSpecificStatusOnRead_488(); - break; - case 489: - ChipLogProgress(chipTool, " ***** Test Step 489 : Write different vendor MEI attribute\n"); - err = TestWriteDifferentVendorMeiAttribute_489(); - break; - case 490: - ChipLogProgress(chipTool, " ***** Test Step 490 : Verify different vendor MEI attribute\n"); - err = TestVerifyDifferentVendorMeiAttribute_490(); - break; - case 491: - ChipLogProgress(chipTool, " ***** Test Step 491 : Validate AcceptedCommandList attribute\n"); - err = TestValidateAcceptedCommandListAttribute_491(); - break; - case 492: - ChipLogProgress(chipTool, " ***** Test Step 492 : Validate GeneratedCommandList attribute\n"); - err = TestValidateGeneratedCommandListAttribute_492(); - break; - case 493: - ChipLogProgress(chipTool, " ***** Test Step 493 : Validate presence of MEI attribute\n"); - err = TestValidatePresenceOfMeiAttribute_493(); - break; - case 494: - ChipLogProgress(chipTool, " ***** Test Step 494 : Write struct-typed attribute\n"); - err = TestWriteStructTypedAttribute_494(); - break; - case 495: - ChipLogProgress(chipTool, " ***** Test Step 495 : Read struct-typed attribute\n"); - err = TestReadStructTypedAttribute_495(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 78: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 79: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 80: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 81: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 82: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 83: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 84: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 85: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 86: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 87: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 88: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 89: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 90: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 91: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 92: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 93: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 94: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 95: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 96: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 97: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 98: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 99: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 100: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 101: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 102: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 103: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 104: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 105: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 106: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 107: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 108: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 109: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 110: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 111: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 112: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 113: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 114: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 115: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 116: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 117: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 118: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 119: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 120: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 121: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 122: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 123: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 124: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 125: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 126: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 127: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 128: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 129: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 130: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 131: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 132: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 133: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 134: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 135: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 136: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 137: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 138: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 139: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 140: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 141: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 142: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 143: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 144: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 145: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 146: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 147: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); - break; - case 148: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); - break; - case 149: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); - break; - case 150: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); - break; - case 151: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 152: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 153: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 154: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 155: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 156: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 157: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 158: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 159: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 160: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 161: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 162: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 163: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 164: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 165: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 166: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 167: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 168: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 169: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 170: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 171: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 172: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 173: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 174: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 175: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 176: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 177: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 178: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 179: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 180: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 181: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 182: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 183: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 184: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 185: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 186: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 187: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 188: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 189: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 190: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 191: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 192: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 193: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 194: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 195: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 196: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 197: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 198: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 199: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 200: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 201: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 202: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 203: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 204: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 205: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 206: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 207: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 208: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 209: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 210: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 211: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 212: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 213: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 214: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 215: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 216: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 217: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 218: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 219: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 220: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 221: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 222: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 223: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 224: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 225: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 226: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 227: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 228: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 229: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 230: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 231: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 232: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 233: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 234: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 235: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 236: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 237: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 238: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 239: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 240: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 241: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 242: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 243: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 244: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 245: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 246: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 247: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 248: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 249: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 250: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 251: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 252: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 253: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 254: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 255: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 256: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 257: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 258: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 259: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 260: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 261: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 262: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 263: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 264: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 265: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 266: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 267: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 268: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 269: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 270: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 271: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 272: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 273: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 274: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 275: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 276: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 277: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 278: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 279: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 280: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 281: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 282: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 283: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 284: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 285: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 286: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 287: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 288: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 289: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 290: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 291: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 292: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 293: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 294: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 295: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 296: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 297: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 298: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 299: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 300: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 301: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 302: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 303: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 304: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 305: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 306: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 307: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 308: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 309: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 310: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 311: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 312: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 313: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 314: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 315: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 316: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 317: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 318: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 319: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 320: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 321: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 322: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 323: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 324: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 325: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 326: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 327: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 328: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 329: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 330: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 331: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 332: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 333: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 334: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 335: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 336: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 337: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 338: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 339: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 340: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 341: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 342: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 343: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 344: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 345: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 346: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 347: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 348: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 349: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 350: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 351: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 352: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 353: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 354: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 355: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 356: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 357: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 358: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 359: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 360: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 361: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 362: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 363: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 364: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 365: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 366: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 367: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 368: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 369: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 370: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 371: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 372: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 373: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); - break; - case 374: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); - break; - case 375: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 376: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 377: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 378: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 379: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 380: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 381: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 382: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 383: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 384: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 385: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 386: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 387: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 388: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 389: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 390: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 391: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 392: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 393: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 394: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 395: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 396: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 397: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 398: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 399: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 400: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 401: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 402: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 403: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 404: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 405: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 406: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 407: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 408: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 409: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 410: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 411: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 412: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 413: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 414: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 415: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 416: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 417: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 418: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 419: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 420: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 421: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 422: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 423: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 424: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 425: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 426: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 427: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 428: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 429: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 430: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 431: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 432: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 433: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 434: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 435: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 436: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 437: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 438: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 439: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 440: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 441: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 442: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 443: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 444: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 445: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 446: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 447: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 448: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 449: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 450: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 451: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 452: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 453: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 454: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 455: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 456: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 457: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 458: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 459: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 460: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 461: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 462: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 463: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 464: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 465: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 466: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 467: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 468: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 469: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 470: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 471: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 472: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 473: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 474: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 475: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 476: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 477: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 478: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 479: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 480: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 481: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 482: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 483: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 484: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 485: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); - break; - case 486: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 487: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); - break; - case 488: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 489: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 490: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 491: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 492: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 493: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 494: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 495: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 496; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendTestCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command: Error: %@", err); - } else { - NSLog(@"Send Test Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestNotHandledCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testNotHandledWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Not Handled Command: Error: %@", err); - } else { - NSLog(@"Send Test Not Handled Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestSpecificCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testSpecificWithCompletion: - ^(MTRUnitTestingClusterTestSpecificResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Specific Command: Error: %@", err); - } else { - NSLog(@"Send Test Specific Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestAddArgumentsCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:17U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, 20U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendFailingTestAddArgumentsCommand_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:250U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:6U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send failing Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send failing Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanDefaultValue_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBooleanTrue_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id booleanArgument; - booleanArgument = - [NSNumber numberWithBool:1]; - [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BOOLEAN True: Error: %@", err); - } else { - NSLog(@"Write attribute BOOLEAN True: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanTrue_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN True: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN True: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBooleanFalse_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id booleanArgument; - booleanArgument = - [NSNumber numberWithBool:0]; - [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BOOLEAN False: Error: %@", err); - } else { - NSLog(@"Write attribute BOOLEAN False: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanFalse_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN False: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN False: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8DefaultValue_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap8MaxValue_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap8Argument; - bitmap8Argument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP8 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8MaxValue_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap8MinValue_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap8Argument; - bitmap8Argument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP8 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8MinValue_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16DefaultValue_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap16MaxValue_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap16Argument; - bitmap16Argument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP16 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16MaxValue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap16MinValue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap16Argument; - bitmap16Argument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP16 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16MinValue_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32DefaultValue_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32MaxValue_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32MaxValue_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32MinValue_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32MinValue_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64DefaultValue_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap64MaxValue_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap64Argument; - bitmap64Argument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP64 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP64 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64MaxValue_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap64MinValue_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap64Argument; - bitmap64Argument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP64 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP64 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64MinValue_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uDefaultValue_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8uMaxValue_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8uArgument; - int8uArgument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uMaxValue_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8uMinValue_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8uArgument; - int8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uMinValue_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uDefaultValue_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16uMaxValue_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16uArgument; - int16uArgument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uMaxValue_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16uMinValue_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16uArgument; - int16uArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uMinValue_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uDefaultValue_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uMaxValue_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uMaxValue_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uMinValue_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uMinValue_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uDefaultValue_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64uMaxValue_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64uArgument; - int64uArgument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uMaxValue_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64uMinValue_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64uArgument; - int64uArgument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uMinValue_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sDefaultValue_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sMaxValue_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [NSNumber numberWithChar:127]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sMaxValue_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, 127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sMinValue_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [NSNumber numberWithChar:-128]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sMinValue_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, -128)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sDefaultValue_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [NSNumber numberWithChar:0]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sDefaultValue_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sDefaultValue_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sMaxValue_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [NSNumber numberWithShort:32767]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sMaxValue_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sMinValue_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [NSNumber numberWithShort:-32768]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sMinValue_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, -32768)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sDefaultValue_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [NSNumber numberWithShort:0]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sDefaultValue_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sDefaultValue_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, 0L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sMaxValue_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [NSNumber numberWithInt:2147483647L]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sMaxValue_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, 2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sMinValue_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [NSNumber numberWithInt:-2147483648L]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sMinValue_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, -2147483648L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sDefaultValue_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [NSNumber numberWithInt:0L]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sDefaultValue_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, 0L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sDefaultValue_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, 0LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64sMaxValue_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [NSNumber numberWithLongLong:9223372036854775807LL]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sMaxValue_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, 9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64sMinValue_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [NSNumber numberWithLongLong:-9223372036854775807LL]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sMinValue_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, -9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64sDefaultValue_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [NSNumber numberWithLongLong:0LL]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sDefaultValue_78() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, 0LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleDefaultValue_79() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeSingleMediumValue_80() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatSingleArgument; - floatSingleArgument = - [NSNumber numberWithFloat:0.1f]; - [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute SINGLE medium Value: Error: %@", err); - } else { - NSLog(@"Write attribute SINGLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleMediumValue_81() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE medium Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 0.1f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeSingleLargeValue_82() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatSingleArgument; - floatSingleArgument = - [NSNumber numberWithFloat:17000000000.0f]; - [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute SINGLE large Value: Error: %@", err); - } else { - NSLog(@"Write attribute SINGLE large Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleLargeValue_83() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE large Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE large Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 17000000000.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeSingleSmallValue_84() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatSingleArgument; - floatSingleArgument = - [NSNumber numberWithFloat:1.7e-10f]; - [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute SINGLE small Value: Error: %@", err); - } else { - NSLog(@"Write attribute SINGLE small Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleSmallValue_85() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE small Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE small Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 1.7e-10f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeSingleDefaultValue_86() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatSingleArgument; - floatSingleArgument = - [NSNumber numberWithFloat:0.0f]; - [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute SINGLE Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute SINGLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleDefaultValue_87() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleDefaultValue_88() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeDoubleMediumValue_89() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatDoubleArgument; - floatDoubleArgument = - [NSNumber numberWithDouble:0.1234567890123]; - [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute DOUBLE medium Value: Error: %@", err); - } else { - NSLog(@"Write attribute DOUBLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleMediumValue_90() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE medium Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 0.1234567890123)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeDoubleLargeValue_91() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatDoubleArgument; - floatDoubleArgument = - [NSNumber numberWithDouble:1.7e+200]; - [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute DOUBLE large Value: Error: %@", err); - } else { - NSLog(@"Write attribute DOUBLE large Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleLargeValue_92() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE large Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE large Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 1.7e+200)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeDoubleSmallValue_93() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatDoubleArgument; - floatDoubleArgument = - [NSNumber numberWithDouble:1.7e-200]; - [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute DOUBLE small Value: Error: %@", err); - } else { - NSLog(@"Write attribute DOUBLE small Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleSmallValue_94() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE small Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE small Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 1.7e-200)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeDoubleDefaultValue_95() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatDoubleArgument; - floatDoubleArgument = - [NSNumber numberWithDouble:0]; - [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute DOUBLE Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute DOUBLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleDefaultValue_96() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8DefaultValue_97() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum8MaxValue_98() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum8Argument; - enum8Argument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM8 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8MaxValue_99() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum8MinValue_100() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum8Argument; - enum8Argument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM8 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8MinValue_101() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16DefaultValue_102() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum16MaxValue_103() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum16Argument; - enum16Argument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM16 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16MaxValue_104() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum16MinValue_105() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum16Argument; - enum16Argument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM16 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16MinValue_106() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringDefaultValue_107() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringWithEmbeddedNull_108() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"Tes\000ti\000ng" length:9]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING with embedded null: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING with embedded null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringWithEmbeddedNull_109() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING with embedded null: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING with embedded null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"Tes\000ti\000ng" length:9])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringWithHexFormat_110() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"\x00\x01\x02\x03\x04\x05" length:6]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING with hex: format: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING with hex: format: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringWithHexFormat_111() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING with hex: format: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING with hex: format: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"\x00\x01\x02\x03\x04\x05" length:6])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringWithWeirdChars_112() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"\015\012\377\042\240" length:5]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING with weird chars: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING with weird chars: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringWithWeirdChars_113() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING with weird chars: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING with weird chars: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"\x0d\x0a\xff\x22\xa0" length:5])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetString_114() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"TestValue" length:9]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetString_115() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"TestValue" length:9])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetString_116() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"TestValueLongerThan10" length:21]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetString_117() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"TestValue" length:9])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetString_118() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"" length:0]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeLongOctetStringDefaultValue_119() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLongOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LONG_OCTET_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute LONG_OCTET_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("long_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeLongOctetString_120() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id longOctetStringArgument; - longOctetStringArgument = - [[NSData alloc] initWithBytes:"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" length:300]; - [cluster writeAttributeLongOctetStringWithValue:longOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LONG_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LONG_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeLongOctetString_121() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLongOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LONG_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute LONG_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("long_octet_string", actualValue, [[NSData alloc] initWithBytes:"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" length:300])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeLongOctetString_122() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id longOctetStringArgument; - longOctetStringArgument = - [[NSData alloc] initWithBytes:"" length:0]; - [cluster writeAttributeLongOctetStringWithValue:longOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LONG_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LONG_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringDefaultValue_123() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharString_124() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"☉T☉"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharString_125() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"☉T☉")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueTooLong_126() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"☉TestValueLongerThan10☉"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING - Value too long: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING - Value too long: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharString_127() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"☉T☉")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringEmpty_128() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @""; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING - Empty: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING - Empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeLongCharStringDefaultValue_129() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLongCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LONG_CHAR_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute LONG_CHAR_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("long_char_string", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeLongCharString_130() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id longCharStringArgument; - longCharStringArgument = @"☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉"; - [cluster writeAttributeLongCharStringWithValue:longCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LONG_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LONG_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeLongCharString_131() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLongCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LONG_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute LONG_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("long_char_string", actualValue, @"☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeLongCharString_132() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id longCharStringArgument; - longCharStringArgument = @""; - [cluster writeAttributeLongCharStringWithValue:longCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LONG_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LONG_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListLongOctetStringForChunkedRead_133() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListLongOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Error: %@", err); - } else { - NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_long_octet_string", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[1], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[2], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[3], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListLongOctetStringForChunkedWrite_134() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listLongOctetStringArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[1] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[2] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[3] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[4] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - listLongOctetStringArgument = temp_0; - } - [cluster writeAttributeListLongOctetStringWithValue:listLongOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Error: %@", err); - } else { - NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListLongOctetStringForChunkedRead_135() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListLongOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Error: %@", err); - } else { - NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_long_octet_string", [actualValue count], static_cast(5))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[1], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[2], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[3], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[4], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListLongOctetStringForChunkedWrite_136() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listLongOctetStringArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[1] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[2] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[3] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - listLongOctetStringArgument = temp_0; - } - [cluster writeAttributeListLongOctetStringWithValue:listLongOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Error: %@", err); - } else { - NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsDefaultValue_137() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochUsMaxValue_138() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochUsArgument; - epochUsArgument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_US Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_US Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsMaxValue_139() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochUsMinValue_140() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochUsArgument; - epochUsArgument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_US Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_US Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsMinValue_141() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSDefaultValue_142() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochSMaxValue_143() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochSArgument; - epochSArgument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSMaxValue_144() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochSMinValue_145() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochSArgument; - epochSArgument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSMinValue_146() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeUnsupported_147() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUnsupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute UNSUPPORTED: Error: %@", err); - } else { - NSLog(@"Read attribute UNSUPPORTED: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteattributeUnsupported_148() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id unsupportedArgument; - unsupportedArgument = - [NSNumber numberWithBool:0]; - [cluster writeAttributeUnsupportedWithValue:unsupportedArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Writeattribute UNSUPPORTED: Error: %@", err); - } else { - NSLog(@"Writeattribute UNSUPPORTED: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandToUnsupportedEndpoint_149() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(200) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command to unsupported endpoint: Error: %@", err); - } else { - NSLog(@"Send Test Command to unsupported endpoint: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandToUnsupportedCluster_150() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command to unsupported cluster: Error: %@", err); - } else { - NSLog(@"Send Test Command to unsupported cluster: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorIdDefaultValue_151() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("vendor_id", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeVendorId_152() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id vendorIdArgument; - vendorIdArgument = - [NSNumber numberWithUnsignedShort:17U]; - [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute vendor_id: Error: %@", err); - } else { - NSLog(@"Write attribute vendor_id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorId_153() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("vendor_id", actualValue, 17U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRestoreAttributeVendorId_154() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id vendorIdArgument; - vendorIdArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Restore attribute vendor_id: Error: %@", err); - } else { - NSLog(@"Restore attribute vendor_id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendACommandWithAVendorIdAndEnum_155() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestEnumsRequestParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedShort:20003U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:1U]; - [cluster testEnumsRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestEnumsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send a command with a vendor_id and enum: Error: %@", err); - } else { - NSLog(@"Send a command with a vendor_id and enum: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.arg1; - VerifyOrReturn(CheckValue("arg1", actualValue, 20003U)); - } - - { - id actualValue = values.arg2; - VerifyOrReturn(CheckValue("arg2", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendACommandWithAVendorIdAndInvalidEnum_156() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestEnumsRequestParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedShort:20003U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:101U]; - [cluster testEnumsRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestEnumsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send a command with a vendor_id and invalid enum: Error: %@", err); - } else { - NSLog(@"Send a command with a vendor_id and invalid enum: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithStructArgumentAndArg1bIsTrue_157() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestStructArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).h = - [NSNumber numberWithDouble:0]; - - [cluster testStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Struct Argument and arg1.b is true: Error: %@", err); - } else { - NSLog(@"Send Test Command With Struct Argument and arg1.b is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithStructArgumentAndArg1bIsFalse_158() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestStructArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).h = - [NSNumber numberWithDouble:0]; - - [cluster testStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Struct Argument and arg1.b is false: Error: %@", err); - } else { - NSLog(@"Send Test Command With Struct Argument and arg1.b is false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructArgumentAndArg1cbIsTrue_159() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNestedStructArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterNestedStruct alloc] init]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).h = - [NSNumber numberWithDouble:0]; - - [cluster testNestedStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct Argument and arg1.c.b is true: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct Argument and arg1.c.b is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructArgumentArg1cbIsFalse_160() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNestedStructArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterNestedStruct alloc] init]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).h = - [NSNumber numberWithDouble:0]; - - [cluster testNestedStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct Argument arg1.c.b is false: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct Argument arg1.c.b is false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructListArgumentAndAllFieldsBOfArg1dAreTrue_161() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNestedStructListArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterNestedStructList alloc] init]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).h = - [NSNumber numberWithDouble:0]; - - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).h = - [NSNumber numberWithDouble:0]; - - temp_1[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).a = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).h = - [NSNumber numberWithDouble:0]; - - ((MTRUnitTestingClusterNestedStructList *) params.arg1).d = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [NSNumber numberWithUnsignedInt:1UL]; - temp_1[1] = - [NSNumber numberWithUnsignedInt:2UL]; - temp_1[2] = - [NSNumber numberWithUnsignedInt:3UL]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).e = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [[NSData alloc] initWithBytes:"octet_string_1" length:14]; - temp_1[1] = - [[NSData alloc] initWithBytes:"octect_string_2" length:15]; - temp_1[2] = - [[NSData alloc] initWithBytes:"octet_string_3" length:14]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).f = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [NSNumber numberWithUnsignedChar:0U]; - temp_1[1] = - [NSNumber numberWithUnsignedChar:255U]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).g = temp_1; - } - - [cluster testNestedStructListArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct List Argument and all fields b of arg1.d are true: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct List Argument and all fields b of arg1.d are true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfArg1dAreFalse_162() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNestedStructListArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterNestedStructList alloc] init]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).h = - [NSNumber numberWithDouble:0]; - - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).h = - [NSNumber numberWithDouble:0]; - - temp_1[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).a = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).h = - [NSNumber numberWithDouble:0]; - - ((MTRUnitTestingClusterNestedStructList *) params.arg1).d = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [NSNumber numberWithUnsignedInt:1UL]; - temp_1[1] = - [NSNumber numberWithUnsignedInt:2UL]; - temp_1[2] = - [NSNumber numberWithUnsignedInt:3UL]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).e = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [[NSData alloc] initWithBytes:"octet_string_1" length:14]; - temp_1[1] = - [[NSData alloc] initWithBytes:"octect_string_2" length:15]; - temp_1[2] = - [[NSData alloc] initWithBytes:"octet_string_3" length:14]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).f = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [NSNumber numberWithUnsignedChar:0U]; - temp_1[1] = - [NSNumber numberWithUnsignedChar:255U]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).g = temp_1; - } - - [cluster testNestedStructListArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of arg1.d are false: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of arg1.d are false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithStructArgumentAndSeeWhatWeGetBack_163() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterSimpleStructEchoRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:17U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).g = - [NSNumber numberWithFloat:0.1f]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).h = - [NSNumber numberWithDouble:0.1]; - - [cluster simpleStructEchoRequestWithParams:params completion: - ^(MTRUnitTestingClusterSimpleStructResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Struct Argument and see what we get back: Error: %@", err); - } else { - NSLog(@"Send Test Command With Struct Argument and see what we get back: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.arg1; - VerifyOrReturn(CheckValue("a", ((MTRUnitTestingClusterSimpleStruct *) actualValue).a, 17U)); - VerifyOrReturn(CheckValue("b", ((MTRUnitTestingClusterSimpleStruct *) actualValue).b, false)); - VerifyOrReturn(CheckValue("c", ((MTRUnitTestingClusterSimpleStruct *) actualValue).c, 2U)); - VerifyOrReturn(CheckValueAsString("d", ((MTRUnitTestingClusterSimpleStruct *) actualValue).d, [[NSData alloc] initWithBytes:"octet_string" length:12])); - VerifyOrReturn(CheckValueAsString("e", ((MTRUnitTestingClusterSimpleStruct *) actualValue).e, @"char_string")); - VerifyOrReturn(CheckValue("f", ((MTRUnitTestingClusterSimpleStruct *) actualValue).f, 1U)); - VerifyOrReturn(CheckValue("g", ((MTRUnitTestingClusterSimpleStruct *) actualValue).g, 0.1f)); - VerifyOrReturn(CheckValue("h", ((MTRUnitTestingClusterSimpleStruct *) actualValue).h, 0.1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendMeiCommandInCluster_164() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestDifferentVendorMeiRequestParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:76U]; - [cluster testDifferentVendorMeiRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestDifferentVendorMeiResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send MEI command in cluster: Error: %@", err); - } else { - NSLog(@"Send MEI command in cluster: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.arg1; - VerifyOrReturn(CheckValue("arg1", actualValue, 76U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfInt8uAndNoneOfThemIsSetTo0_165() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListInt8UArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - temp_0[4] = - [NSNumber numberWithUnsignedChar:5U]; - temp_0[5] = - [NSNumber numberWithUnsignedChar:6U]; - temp_0[6] = - [NSNumber numberWithUnsignedChar:7U]; - temp_0[7] = - [NSNumber numberWithUnsignedChar:8U]; - temp_0[8] = - [NSNumber numberWithUnsignedChar:9U]; - params.arg1 = temp_0; - } - [cluster testListInt8UArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of INT8U and none of them is set to 0: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of INT8U and none of them is set to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfInt8uAndOneOfThemIsSetTo0_166() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListInt8UArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - temp_0[4] = - [NSNumber numberWithUnsignedChar:5U]; - temp_0[5] = - [NSNumber numberWithUnsignedChar:6U]; - temp_0[6] = - [NSNumber numberWithUnsignedChar:7U]; - temp_0[7] = - [NSNumber numberWithUnsignedChar:8U]; - temp_0[8] = - [NSNumber numberWithUnsignedChar:9U]; - temp_0[9] = - [NSNumber numberWithUnsignedChar:0U]; - params.arg1 = temp_0; - } - [cluster testListInt8UArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of INT8U and one of them is set to 0: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of INT8U and one of them is set to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfInt8uAndGetItReversed_167() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListInt8UReverseRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - temp_0[4] = - [NSNumber numberWithUnsignedChar:5U]; - temp_0[5] = - [NSNumber numberWithUnsignedChar:6U]; - temp_0[6] = - [NSNumber numberWithUnsignedChar:7U]; - temp_0[7] = - [NSNumber numberWithUnsignedChar:8U]; - temp_0[8] = - [NSNumber numberWithUnsignedChar:9U]; - params.arg1 = temp_0; - } - [cluster testListInt8UReverseRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestListInt8UReverseResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of INT8U and get it reversed: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of INT8U and get it reversed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.arg1; - VerifyOrReturn(CheckValue("arg1", [actualValue count], static_cast(9))); - VerifyOrReturn(CheckValue("", actualValue[0], 9U)); - VerifyOrReturn(CheckValue("", actualValue[1], 8U)); - VerifyOrReturn(CheckValue("", actualValue[2], 7U)); - VerifyOrReturn(CheckValue("", actualValue[3], 6U)); - VerifyOrReturn(CheckValue("", actualValue[4], 5U)); - VerifyOrReturn(CheckValue("", actualValue[5], 4U)); - VerifyOrReturn(CheckValue("", actualValue[6], 3U)); - VerifyOrReturn(CheckValue("", actualValue[7], 2U)); - VerifyOrReturn(CheckValue("", actualValue[8], 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithEmptyListOfInt8uAndGetAnEmptyListBack_168() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListInt8UReverseRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.arg1 = temp_0; - } - [cluster testListInt8UReverseRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestListInt8UReverseResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With empty List of INT8U and get an empty list back: Error: %@", err); - } else { - NSLog(@"Send Test Command With empty List of INT8U and get an empty list back: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.arg1; - VerifyOrReturn(CheckValue("arg1", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsTrue_169() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListStructArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).d = - [[NSData alloc] initWithBytes:"first_octet_string" length:18]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).e = @"first_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).h = - [NSNumber numberWithDouble:0]; - - temp_0[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).d = - [[NSData alloc] initWithBytes:"second_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).e = @"second_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).h = - [NSNumber numberWithDouble:0]; - - params.arg1 = temp_0; - } - [cluster testListStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is true: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsFalse_170() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListStructArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).d = - [[NSData alloc] initWithBytes:"second_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).e = @"second_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).h = - [NSNumber numberWithDouble:0]; - - temp_0[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).d = - [[NSData alloc] initWithBytes:"first_octet_string" length:18]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).e = @"first_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).h = - [NSNumber numberWithDouble:0]; - - params.arg1 = temp_0; - } - [cluster testListStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is false: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfNestedStructListArgumentAndAllFieldsBOfElementsOfArg1dAreTrue_171() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListNestedStructListArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterNestedStructList alloc] init]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).h = - [NSNumber numberWithDouble:0]; - - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).h = - [NSNumber numberWithDouble:0]; - - temp_2[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).a = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).h = - [NSNumber numberWithDouble:0]; - - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).d = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [NSNumber numberWithUnsignedInt:1UL]; - temp_2[1] = - [NSNumber numberWithUnsignedInt:2UL]; - temp_2[2] = - [NSNumber numberWithUnsignedInt:3UL]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).e = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [[NSData alloc] initWithBytes:"octet_string_1" length:14]; - temp_2[1] = - [[NSData alloc] initWithBytes:"octect_string_2" length:15]; - temp_2[2] = - [[NSData alloc] initWithBytes:"octet_string_3" length:14]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).f = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [NSNumber numberWithUnsignedChar:0U]; - temp_2[1] = - [NSNumber numberWithUnsignedChar:255U]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).g = temp_2; - } - - params.arg1 = temp_0; - } - [cluster testListNestedStructListArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of Nested Struct List Argument and all fields b of elements of arg1.d are true: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of Nested Struct List Argument and all fields b of elements of arg1.d are true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfElementsOfArg1dAreFalse_172() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListNestedStructListArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterNestedStructList alloc] init]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).h = - [NSNumber numberWithDouble:0]; - - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).h = - [NSNumber numberWithDouble:0]; - - temp_2[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).a = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).h = - [NSNumber numberWithDouble:0]; - - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).d = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [NSNumber numberWithUnsignedInt:1UL]; - temp_2[1] = - [NSNumber numberWithUnsignedInt:2UL]; - temp_2[2] = - [NSNumber numberWithUnsignedInt:3UL]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).e = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [[NSData alloc] initWithBytes:"octet_string_1" length:14]; - temp_2[1] = - [[NSData alloc] initWithBytes:"octect_string_2" length:15]; - temp_2[2] = - [[NSData alloc] initWithBytes:"octet_string_3" length:14]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).f = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [NSNumber numberWithUnsignedChar:0U]; - temp_2[1] = - [NSNumber numberWithUnsignedChar:255U]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).g = temp_2; - } - - params.arg1 = temp_0; - } - [cluster testListNestedStructListArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of elements of arg1.d are false: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of elements of arg1.d are false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListWithListOfInt8uAndNoneOfThemIsSetTo0_173() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listInt8uArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - listInt8uArgument = temp_0; - } - [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST With List of INT8U and none of them is set to 0: Error: %@", err); - } else { - NSLog(@"Write attribute LIST With List of INT8U and none of them is set to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithListOfInt8u_174() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With List of INT8U: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With List of INT8U: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_int8u", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - VerifyOrReturn(CheckValue("", actualValue[2], 3U)); - VerifyOrReturn(CheckValue("", actualValue[3], 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListWithListOfOctetString_175() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listOctetStringArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [[NSData alloc] initWithBytes:"Test0" length:5]; - temp_0[1] = - [[NSData alloc] initWithBytes:"Test1" length:5]; - temp_0[2] = - [[NSData alloc] initWithBytes:"Test2" length:5]; - temp_0[3] = - [[NSData alloc] initWithBytes:"Test3" length:5]; - listOctetStringArgument = temp_0; - } - [cluster writeAttributeListOctetStringWithValue:listOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST With List of OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LIST With List of OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithListOfOctetString_176() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With List of OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With List of OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_octet_string", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], [[NSData alloc] initWithBytes:"Test0" length:5])); - VerifyOrReturn(CheckValueAsString("", actualValue[1], [[NSData alloc] initWithBytes:"Test1" length:5])); - VerifyOrReturn(CheckValueAsString("", actualValue[2], [[NSData alloc] initWithBytes:"Test2" length:5])); - VerifyOrReturn(CheckValueAsString("", actualValue[3], [[NSData alloc] initWithBytes:"Test3" length:5])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListWithListOfListStructOctetString_177() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listStructOctetStringArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[0]).member1 = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[0]).member2 = - [[NSData alloc] initWithBytes:"Test0" length:5]; - - temp_0[1] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[1]).member1 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[1]).member2 = - [[NSData alloc] initWithBytes:"Test1" length:5]; - - temp_0[2] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[2]).member1 = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[2]).member2 = - [[NSData alloc] initWithBytes:"Test2" length:5]; - - temp_0[3] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[3]).member1 = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[3]).member2 = - [[NSData alloc] initWithBytes:"Test3" length:5]; - - listStructOctetStringArgument = temp_0; - } - [cluster writeAttributeListStructOctetStringWithValue:listStructOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST With List of LIST_STRUCT_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LIST With List of LIST_STRUCT_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithListOfListStructOctetString_178() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListStructOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With List of LIST_STRUCT_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With List of LIST_STRUCT_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_struct_octet_string", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[0]).member1, 0ULL)); - VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[0]).member2, [[NSData alloc] initWithBytes:"Test0" length:5])); - VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[1]).member1, 1ULL)); - VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[1]).member2, [[NSData alloc] initWithBytes:"Test1" length:5])); - VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[2]).member1, 2ULL)); - VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[2]).member2, [[NSData alloc] initWithBytes:"Test2" length:5])); - VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[3]).member1, 3ULL)); - VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[3]).member2, [[NSData alloc] initWithBytes:"Test3" length:5])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithOptionalArgSet_179() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNullableOptionalRequestParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:5U]; - [cluster testNullableOptionalRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestNullableOptionalResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command with optional arg set.: Error: %@", err); - } else { - NSLog(@"Send Test Command with optional arg set.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.wasPresent; - VerifyOrReturn(CheckValue("wasPresent", actualValue, true)); - } - - { - id actualValue = values.wasNull; - VerifyOrReturn(CheckValue("wasNull", actualValue, false)); - } - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, 5U)); - } - - { - id actualValue = values.originalValue; - VerifyOrReturn(CheckValueNonNull("originalValue", actualValue)); - VerifyOrReturn(CheckValue("originalValue", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithoutItsOptionalArg_180() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNullableOptionalRequestParams alloc] init]; - [cluster testNullableOptionalRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestNullableOptionalResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command without its optional arg.: Error: %@", err); - } else { - NSLog(@"Send Test Command without its optional arg.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.wasPresent; - VerifyOrReturn(CheckValue("wasPresent", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadListOfStructsContainingNullablesAndOptionals_181() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListNullablesAndOptionalsStructWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read list of structs containing nullables and optionals: Error: %@", err); - } else { - NSLog(@"Read list of structs containing nullables and optionals: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_nullables_and_optionals_struct", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueNull("NullableInt", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableInt)); - VerifyOrReturn(CheckValueNull("NullableString", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableString)); - VerifyOrReturn(CheckValueNull("NullableStruct", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableStruct)); - VerifyOrReturn(CheckValueNull("NullableList", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteListOfStructsContainingNullablesAndOptionals_182() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listNullablesAndOptionalsStructArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterNullablesAndOptionalsStruct alloc] init]; - ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableInt = nil; - ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableString = nil; - ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableStruct = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_3[1] = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableList = temp_3; - } - - listNullablesAndOptionalsStructArgument = temp_0; - } - [cluster writeAttributeListNullablesAndOptionalsStructWithValue:listNullablesAndOptionalsStructArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write list of structs containing nullables and optionals: Error: %@", err); - } else { - NSLog(@"Write list of structs containing nullables and optionals: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadListOfStructsContainingNullablesAndOptionalsAfterWriting_183() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListNullablesAndOptionalsStructWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read list of structs containing nullables and optionals after writing: Error: %@", err); - } else { - NSLog(@"Read list of structs containing nullables and optionals after writing: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_nullables_and_optionals_struct", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueNull("NullableInt", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableInt)); - VerifyOrReturn(CheckValueNull("NullableString", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableString)); - VerifyOrReturn(CheckValueNull("NullableStruct", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableStruct)); - VerifyOrReturn(CheckValueNonNull("NullableList", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList)); - VerifyOrReturn(CheckValue("NullableList", [((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList count], static_cast(2))); - VerifyOrReturn(CheckValue("", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList[0], 1U)); - VerifyOrReturn(CheckValue("", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBooleanNull_184() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBooleanArgument; - nullableBooleanArgument = nil; - [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BOOLEAN null: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BOOLEAN null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable booValueNull; - - CHIP_ERROR TestReadAttributeNullableBooleanNull_185() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BOOLEAN null: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BOOLEAN null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_boolean", actualValue)); - } - { - booValueNull = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBooleanTrue_186() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBooleanArgument; - nullableBooleanArgument = - [NSNumber numberWithBool:true]; - [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BOOLEAN True: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BOOLEAN True: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBooleanTrue_187() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BOOLEAN True: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BOOLEAN True: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_boolean", actualValue)); - VerifyOrReturn(CheckValue("nullable_boolean", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBooleanNotNull_188() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BOOLEAN not null: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BOOLEAN not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableBoolean", value, booValueNull)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap8MaxValue_189() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap8Argument; - nullableBitmap8Argument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeNullableBitmap8WithValue:nullableBitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP8 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap8MaxValue_190() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP8 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap8", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap8", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap8InvalidValue_191() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap8Argument; - nullableBitmap8Argument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeNullableBitmap8WithValue:nullableBitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP8 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP8 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable nullableValue254; - - CHIP_ERROR TestReadAttributeNullableBitmap8UnchangedValue_192() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP8 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP8 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap8", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap8", actualValue, 254U)); - } - { - nullableValue254 = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap8NullValue_193() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap8Argument; - nullableBitmap8Argument = nil; - [cluster writeAttributeNullableBitmap8WithValue:nullableBitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP8 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP8 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap8NullValue_194() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP8 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP8 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_bitmap8", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap8Not254Value_195() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP8 not 254 Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP8 not 254 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableBitmap8", value, nullableValue254)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap16MaxValue_196() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap16Argument; - nullableBitmap16Argument = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster writeAttributeNullableBitmap16WithValue:nullableBitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP16 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap16MaxValue_197() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP16 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap16", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap16", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap16InvalidValue_198() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap16Argument; - nullableBitmap16Argument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeNullableBitmap16WithValue:nullableBitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP16 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP16 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap16UnchangedValue_199() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP16 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP16 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap16", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap16", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap16NullValue_200() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap16Argument; - nullableBitmap16Argument = nil; - [cluster writeAttributeNullableBitmap16WithValue:nullableBitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP16 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP16 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap16NullValue_201() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP16 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP16 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_bitmap16", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap32MaxValue_202() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap32Argument; - nullableBitmap32Argument = - [NSNumber numberWithUnsignedInt:4294967294UL]; - [cluster writeAttributeNullableBitmap32WithValue:nullableBitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP32 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP32 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap32MaxValue_203() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP32 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP32 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap32", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap32", actualValue, 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap32InvalidValue_204() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap32Argument; - nullableBitmap32Argument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeNullableBitmap32WithValue:nullableBitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP32 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP32 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap32UnchangedValue_205() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP32 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP32 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap32", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap32", actualValue, 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap32NullValue_206() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap32Argument; - nullableBitmap32Argument = nil; - [cluster writeAttributeNullableBitmap32WithValue:nullableBitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP32 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP32 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap32NullValue_207() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP32 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP32 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_bitmap32", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap64MaxValue_208() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap64Argument; - nullableBitmap64Argument = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - [cluster writeAttributeNullableBitmap64WithValue:nullableBitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP64 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP64 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap64MaxValue_209() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP64 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP64 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap64", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap64", actualValue, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap64InvalidValue_210() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap64Argument; - nullableBitmap64Argument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeNullableBitmap64WithValue:nullableBitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP64 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP64 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap64UnchangedValue_211() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP64 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP64 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap64", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap64", actualValue, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap64NullValue_212() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap64Argument; - nullableBitmap64Argument = nil; - [cluster writeAttributeNullableBitmap64WithValue:nullableBitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP64 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP64 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap64NullValue_213() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP64 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP64 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_bitmap64", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uMinValue_214() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uMinValue_215() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uMaxValue_216() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uMaxValue_217() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uInvalidValue_218() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uUnchangedValue_219() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uUnchangedValueWithConstraint_220() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U unchanged Value with constraint: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U unchanged Value with constraint: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckValueNonNull("nullableInt8u", value)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uNullValue_221() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = nil; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uNullValue_222() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int8u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uNullValueRange_223() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt8u", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt8u", [value unsignedCharValue], 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uNullValueNot_224() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt8u", value, 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uValue_225() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:128U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uValueInRange_226() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt8u", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt8u", [value unsignedCharValue], 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uNotValueOk_227() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt8u", value, 129U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uMinValue_228() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uMinValue_229() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uMaxValue_230() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uMaxValue_231() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16u", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uInvalidValue_232() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uUnchangedValue_233() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16u", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uNullValue_234() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = nil; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uNullValue_235() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int16u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uNullValueRange_236() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt16u", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt16u", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uNullValueNot_237() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt16u", value, 65534U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uValue_238() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = - [NSNumber numberWithUnsignedShort:32000U]; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uValueInRange_239() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt16u", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt16u", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uNotValueOk_240() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt16u", value, 32001U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uMinValue_241() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uMinValue_242() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32u", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uMaxValue_243() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = - [NSNumber numberWithUnsignedInt:4294967294UL]; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uMaxValue_244() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32u", actualValue, 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uInvalidValue_245() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uUnchangedValue_246() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32u", actualValue, 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uNullValue_247() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = nil; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uNullValue_248() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int32u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uNullValueRange_249() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt32u", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt32u", [value unsignedIntValue], 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uNullValueNot_250() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt32u", value, 4294967294UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uValue_251() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = - [NSNumber numberWithUnsignedInt:2147483647UL]; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uValueInRange_252() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt32u", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt32u", [value unsignedIntValue], 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uNotValueOk_253() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt32u", value, 2147483648UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uMinValue_254() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uMinValue_255() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64u", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uMaxValue_256() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uMaxValue_257() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64u", actualValue, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uInvalidValue_258() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uUnchangedValue_259() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64u", actualValue, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uNullValue_260() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = nil; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uNullValue_261() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int64u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uNullValueRange_262() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt64u", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt64u", [value unsignedLongLongValue], 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uNullValueNot_263() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt64u", value, 18446744073709551614ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uValue_264() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = - [NSNumber numberWithUnsignedLongLong:18000000000000000000ULL]; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uValueInRange_265() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt64u", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt64u", [value unsignedLongLongValue], 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uNotValueOk_266() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt64u", value, 18000000000000000001ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8sMinValue_267() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8sArgument; - nullableInt8sArgument = - [NSNumber numberWithChar:-127]; - [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sMinValue_268() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8s", actualValue, -127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8sInvalidValue_269() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8sArgument; - nullableInt8sArgument = - [NSNumber numberWithChar:-128]; - [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8S Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8S Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sUnchangedValue_270() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8s", actualValue, -127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8sNullValue_271() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8sArgument; - nullableInt8sArgument = nil; - [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8S null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sNullValue_272() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int8s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sNullValueRange_273() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt8s", [value charValue], -127)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt8s", [value charValue], 127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sNullValueNot_274() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt8s", value, -127)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8sValue_275() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8sArgument; - nullableInt8sArgument = - [NSNumber numberWithChar:-127]; - [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8S Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8S Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sValueInRange_276() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt8s", [value charValue], -127)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt8s", [value charValue], 127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sNotValueOk_277() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt8s", value, -126)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16sMinValue_278() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16sArgument; - nullableInt16sArgument = - [NSNumber numberWithShort:-32767]; - [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sMinValue_279() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16s", actualValue, -32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16sInvalidValue_280() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16sArgument; - nullableInt16sArgument = - [NSNumber numberWithShort:-32768]; - [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16S Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16S Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sUnchangedValue_281() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16s", actualValue, -32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16sNullValue_282() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16sArgument; - nullableInt16sArgument = nil; - [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16S null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sNullValue_283() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int16s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sNullValueRange_284() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt16s", [value shortValue], -32767)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt16s", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sNullValueNot_285() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt16s", value, -32767)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16sValue_286() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16sArgument; - nullableInt16sArgument = - [NSNumber numberWithShort:-32767]; - [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16S Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16S Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sValueInRange_287() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt16s", [value shortValue], -32767)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt16s", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sNotValueOk_288() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt16s", value, -32766)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32sMinValue_289() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32sArgument; - nullableInt32sArgument = - [NSNumber numberWithInt:-2147483647L]; - [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sMinValue_290() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32s", actualValue, -2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32sInvalidValue_291() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32sArgument; - nullableInt32sArgument = - [NSNumber numberWithInt:-2147483648L]; - [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32S Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32S Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sUnchangedValue_292() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32s", actualValue, -2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32sNullValue_293() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32sArgument; - nullableInt32sArgument = nil; - [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32S null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sNullValue_294() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int32s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sNullValueRange_295() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt32s", [value intValue], -2147483647L)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt32s", [value intValue], 2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sNullValueNot_296() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt32s", value, -2147483647L)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32sValue_297() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32sArgument; - nullableInt32sArgument = - [NSNumber numberWithInt:-2147483647L]; - [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32S Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32S Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sValueInRange_298() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt32s", [value intValue], -2147483647L)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt32s", [value intValue], 2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sNotValueOk_299() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt32s", value, -2147483646L)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64sMinValue_300() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64sArgument; - nullableInt64sArgument = - [NSNumber numberWithLongLong:-9223372036854775807LL]; - [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sMinValue_301() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64s", actualValue, -9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64sInvalidValue_302() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64sArgument; - nullableInt64sArgument = - [NSNumber numberWithLongLong:-9223372036854775807LL - 1LL]; - [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64S Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64S Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sUnchangedValue_303() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64s", actualValue, -9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64sNullValue_304() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64sArgument; - nullableInt64sArgument = nil; - [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64S null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sNullValue_305() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int64s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sNullValueRange_306() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt64s", [value longLongValue], -9223372036854775807LL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt64s", [value longLongValue], 9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sNullValueNot_307() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt64s", value, -9223372036854775807LL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64sValue_308() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64sArgument; - nullableInt64sArgument = - [NSNumber numberWithLongLong:-9223372036854775807LL]; - [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64S Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64S Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sValueInRange_309() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt64s", [value longLongValue], -9223372036854775807LL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt64s", [value longLongValue], 9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sNotValueOk_310() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt64s", value, -9223372036854775806LL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingleMediumValue_311() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = - [NSNumber numberWithFloat:0.1f]; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE medium Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingleMediumValue_312() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE medium Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_single", actualValue, 0.1f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingleLargestValue_313() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = - [NSNumber numberWithFloat:INFINITY]; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE largest Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE largest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingleLargestValue_314() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE largest Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE largest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_single", actualValue, INFINITY)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingleSmallestValue_315() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = - [NSNumber numberWithFloat:-INFINITY]; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE smallest Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE smallest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingleSmallestValue_316() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE smallest Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE smallest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_single", actualValue, -INFINITY)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingleNullValue_317() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = nil; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingleNullValue_318() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_float_single", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingle0Value_319() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = - [NSNumber numberWithFloat:0.0f]; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE 0 Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE 0 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingle0Value_320() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE 0 Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE 0 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_single", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDoubleMediumValue_321() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = - [NSNumber numberWithDouble:0.1234567890123]; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE medium Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDoubleMediumValue_322() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE medium Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_double", actualValue, 0.1234567890123)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDoubleLargestValue_323() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = - [NSNumber numberWithDouble:INFINITY]; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE largest Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE largest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDoubleLargestValue_324() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE largest Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE largest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_double", actualValue, INFINITY)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDoubleSmallestValue_325() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = - [NSNumber numberWithDouble:-INFINITY]; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE smallest Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE smallest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDoubleSmallestValue_326() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE smallest Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE smallest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_double", actualValue, -INFINITY)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDoubleNullValue_327() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = nil; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDoubleNullValue_328() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_float_double", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDouble0Value_329() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = - [NSNumber numberWithDouble:0]; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE 0 Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE 0 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDouble0Value_330() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE 0 Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE 0 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_double", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum8MinValue_331() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum8Argument; - nullableEnum8Argument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM8 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum8MinValue_332() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM8 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum8", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum8MaxValue_333() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum8Argument; - nullableEnum8Argument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM8 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum8MaxValue_334() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM8 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum8", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum8", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum8InvalidValue_335() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum8Argument; - nullableEnum8Argument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM8 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM8 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum8UnchangedValue_336() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM8 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM8 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum8", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum8", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum8NullValue_337() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum8Argument; - nullableEnum8Argument = nil; - [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM8 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM8 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum8NullValue_338() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM8 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM8 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_enum8", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum16MinValue_339() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum16Argument; - nullableEnum16Argument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM16 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum16MinValue_340() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM16 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum16", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum16MaxValue_341() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum16Argument; - nullableEnum16Argument = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM16 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum16MaxValue_342() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM16 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum16", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum16", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum16InvalidValue_343() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum16Argument; - nullableEnum16Argument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM16 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM16 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum16UnchangedValue_344() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM16 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM16 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum16", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum16", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum16NullValue_345() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum16Argument; - nullableEnum16Argument = nil; - [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM16 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM16 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum16NullValue_346() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM16 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM16 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_enum16", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSimpleEnumMinValue_347() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnumAttrArgument; - nullableEnumAttrArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSimpleEnumMinValue_348() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum_attr", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum_attr", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSimpleEnumMaxValue_349() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnumAttrArgument; - nullableEnumAttrArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSimpleEnumMaxValue_350() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum_attr", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum_attr", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSimpleEnumInvalidValue_351() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnumAttrArgument; - nullableEnumAttrArgument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable nullableEnumAttr3; - - CHIP_ERROR TestReadAttributeNullableSimpleEnumUnchangedValue_352() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum_attr", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum_attr", actualValue, 3U)); - } - { - nullableEnumAttr3 = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSimpleEnumNullValue_353() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnumAttrArgument; - nullableEnumAttrArgument = nil; - [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSimpleEnumNullValue_354() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_enum_attr", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSimpleEnumNot3Value_355() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM not 3 Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM not 3 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableEnumAttr", value, nullableEnumAttr3)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetStringDefaultValue_356() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_357() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = - [[NSData alloc] initWithBytes:"TestValue" length:9]; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSData * _Nullable nullableOctetStrTestValue; - - CHIP_ERROR TestReadAttributeNullableOctetString_358() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"TestValue" length:9])); - } - { - nullableOctetStrTestValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_359() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = nil; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetString_360() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_octet_string", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_361() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = - [[NSData alloc] initWithBytes:"" length:0]; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetString_362() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetStringNotTestValue_363() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING not TestValue: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING not TestValue: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableOctetString", value, nullableOctetStrTestValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharStringDefaultValue_364() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharString_365() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = @"☉T☉"; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nullable nullableCharStringSave; - - CHIP_ERROR TestReadAttributeNullableCharString_366() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, @"☉T☉")); - } - { - nullableCharStringSave = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharString_367() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (nullableCharStringSave == nil) { - VerifyOrReturn(CheckValueNull("nullable_char_string", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, nullableCharStringSave)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharStringValueTooLong_368() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = nil; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING - Value too long: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING - Value too long: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharString_369() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_char_string", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharStringEmpty_370() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = @""; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING - Empty: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING - Empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharString_371() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharStringNott_372() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING not ☉T☉: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING not ☉T☉: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableCharString", value, nullableCharStringSave)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeFromNonexistentEndpoint_373() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(200) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute from nonexistent endpoint.: Error: %@", err); - } else { - NSLog(@"Read attribute from nonexistent endpoint.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeFromNonexistentCluster_374() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute from nonexistent cluster.: Error: %@", err); - } else { - NSLog(@"Read attribute from nonexistent cluster.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_375() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestSimpleOptionalArgumentRequestParams alloc] init]; - [cluster testSimpleOptionalArgumentRequestWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send a command that takes an optional parameter but do not set it.: Error: %@", err); - } else { - NSLog(@"Send a command that takes an optional parameter but do not set it.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_376() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestSimpleOptionalArgumentRequestParams alloc] init]; - params.arg1 = - [NSNumber numberWithBool:1]; - [cluster testSimpleOptionalArgumentRequestWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send a command that takes an optional parameter but do not set it.: Error: %@", err); - } else { - NSLog(@"Send a command that takes an optional parameter but do not set it.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestCluster_377_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestCluster_list_int8u_Reported - = nil; - - CHIP_ERROR TestReportSubscribeToListAttribute_377() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestCluster_list_int8u_Reported - = ^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe to list attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe to list attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_int8u", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - VerifyOrReturn(CheckValue("", actualValue[2], 3U)); - VerifyOrReturn(CheckValue("", actualValue[3], 4U)); - } - - testSendClusterTestCluster_377_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeToListAttribute_378() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 5U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeListInt8uWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestCluster_377_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe to list attribute: Error: %@", err); - } else { - NSLog(@"Subscribe to list attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestCluster_list_int8u_Reported - != nil) { - ResponseHandler callback = test_TestCluster_list_int8u_Reported; - test_TestCluster_list_int8u_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteSubscribedToListAttribute_379() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listInt8uArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:5U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:6U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:7U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:8U]; - listInt8uArgument = temp_0; - } - [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write subscribed-to list attribute: Error: %@", err); - } else { - NSLog(@"Write subscribed-to list attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForListAttributeReport_380() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestCluster_list_int8u_Reported - = ^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for list attribute report: Error: %@", err); - } else { - NSLog(@"Check for list attribute report: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_int8u", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("", actualValue[0], 5U)); - VerifyOrReturn(CheckValue("", actualValue[1], 6U)); - VerifyOrReturn(CheckValue("", actualValue[2], 7U)); - VerifyOrReturn(CheckValue("", actualValue[3], 8U)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadRangeRestrictedUnsigned8BitInteger_381() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Read range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 70U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToARangeRestrictedUnsigned8BitInteger_382() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedUnsigned8BitInteger_383() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:19U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedUnsigned8BitInteger_384() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:101U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToARangeRestrictedUnsigned8BitInteger_385() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_386() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 8-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 8-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 70U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToARangeRestrictedUnsigned8BitInteger_387() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:20U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_388() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 20U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedUnsigned8BitInteger_389() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:100U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_390() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedUnsigned8BitInteger_391() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:50U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_392() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadRangeRestrictedUnsigned16BitInteger_393() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Read range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToARangeRestrictedUnsigned16BitInteger_394() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedUnsigned16BitInteger_395() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:99U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedUnsigned16BitInteger_396() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:1001U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToARangeRestrictedUnsigned16BitInteger_397() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_398() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 16-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 16-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToARangeRestrictedUnsigned16BitInteger_399() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:100U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_400() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedUnsigned16BitInteger_401() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:1000U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_402() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 1000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedUnsigned16BitInteger_403() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:500U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_404() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 500U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadRangeRestrictedSigned8BitInteger_405() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Read range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, -20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToARangeRestrictedSigned8BitInteger_406() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-128]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedSigned8BitInteger_407() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-41]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedSigned8BitInteger_408() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:51]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToARangeRestrictedSigned8BitInteger_409() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:127]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueHasNotChanged_410() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 8-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 8-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, -20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToARangeRestrictedSigned8BitInteger_411() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-40]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMinValid_412() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 8-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 8-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, -40)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedSigned8BitInteger_413() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:50]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_414() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 8-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 8-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, 50)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedSigned8BitInteger_415() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:6]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMidValid_416() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 8-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 8-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, 6)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadRangeRestrictedSigned16BitInteger_417() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Read range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, -100)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToARangeRestrictedSigned16BitInteger_418() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-32768]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedSigned16BitInteger_419() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-151]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedSigned16BitInteger_420() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:201]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToARangeRestrictedSigned16BitInteger_421() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:32767]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueHasNotChanged_422() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 16-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 16-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, -100)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToARangeRestrictedSigned16BitInteger_423() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-150]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMinValid_424() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 16-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 16-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, -150)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedSigned16BitInteger_425() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:200]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_426() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 16-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 16-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, 200)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedSigned16BitInteger_427() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:7]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMidValid_428() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 16-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 16-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, 7)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNullableRangeRestrictedUnsigned8BitInteger_429() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Read nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 70U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedUnsigned8BitInteger_430() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned8BitInteger_431() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:19U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned8BitInteger_432() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:101U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedUnsigned8BitInteger_433() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_434() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 70U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedUnsigned8BitInteger_435() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:20U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_436() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 20U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedUnsigned8BitInteger_437() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:100U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_438() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned8BitInteger_439() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:50U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_440() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedUnsigned8BitInteger_441() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = nil; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write null value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write null value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsNull_442() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is null: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_range_restricted_int8u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNullableRangeRestrictedUnsigned16BitInteger_443() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Read nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedUnsigned16BitInteger_444() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned16BitInteger_445() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:99U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned16BitInteger_446() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:1001U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedUnsigned16BitInteger_447() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_448() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedUnsigned16BitInteger_449() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:100U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_450() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedUnsigned16BitInteger_451() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:1000U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_452() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 1000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned16BitInteger_453() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:500U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_454() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 500U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedUnsigned16BitInteger_455() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = nil; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write null value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write null value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsNull_456() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is null: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_range_restricted_int16u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNullableRangeRestrictedSigned8BitInteger_457() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Read nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, -20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedSigned8BitInteger_458() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-127]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned8BitInteger_459() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-41]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned8BitInteger_460() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:51]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedSigned8BitInteger_461() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:127]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueHasNotChanged_462() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, -20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedSigned8BitInteger_463() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-40]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMinValid_464() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, -40)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedSigned8BitInteger_465() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:50]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_466() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, 50)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedSigned8BitInteger_467() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:6]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMidValid_468() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, 6)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedSigned8BitInteger_469() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = nil; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write null value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write null value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtNull_470() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at null: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_range_restricted_int8s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNullableRangeRestrictedSigned16BitInteger_471() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Read nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, -100)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedSigned16BitInteger_472() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-32767]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned16BitInteger_473() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-151]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned16BitInteger_474() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:201]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedSigned16BitInteger_475() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:32767]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueHasNotChanged_476() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, -100)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedSigned16BitInteger_477() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-150]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMinValid_478() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, -150)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedSigned16BitInteger_479() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:200]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_480() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, 200)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedSigned16BitInteger_481() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:7]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMidValid_482() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, 7)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedSigned16BitInteger_483() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = nil; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write null value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write null value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsNull_484() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is null: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_range_restricted_int16s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeThatReturnsGeneralStatusOnWrite_485() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id generalErrorBooleanArgument; - generalErrorBooleanArgument = - [NSNumber numberWithBool:false]; - [cluster writeAttributeGeneralErrorBooleanWithValue:generalErrorBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute that returns general status on write: Error: %@", err); - } else { - NSLog(@"Write attribute that returns general status on write: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeThatReturnsClusterSpecificStatusOnWrite_486() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id clusterErrorBooleanArgument; - clusterErrorBooleanArgument = - [NSNumber numberWithBool:false]; - [cluster writeAttributeClusterErrorBooleanWithValue:clusterErrorBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute that returns cluster-specific status on write: Error: %@", err); - } else { - NSLog(@"Write attribute that returns cluster-specific status on write: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeThatReturnsGeneralStatusOnRead_487() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneralErrorBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute that returns general status on read: Error: %@", err); - } else { - NSLog(@"Read attribute that returns general status on read: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeThatReturnsClusterSpecificStatusOnRead_488() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterErrorBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"read attribute that returns cluster-specific status on read: Error: %@", err); - } else { - NSLog(@"read attribute that returns cluster-specific status on read: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteDifferentVendorMeiAttribute_489() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id meiInt8uArgument; - meiInt8uArgument = - [NSNumber numberWithUnsignedChar:201U]; - [cluster writeAttributeMeiInt8uWithValue:meiInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write different vendor MEI attribute: Error: %@", err); - } else { - NSLog(@"Write different vendor MEI attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDifferentVendorMeiAttribute_490() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeiInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify different vendor MEI attribute: Error: %@", err); - } else { - NSLog(@"Verify different vendor MEI attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("mei_int8u", actualValue, 201U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidateAcceptedCommandListAttribute_491() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Validate AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(21))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 1UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 2UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 4UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 7UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 8UL)); - VerifyOrReturn(CheckValue("", actualValue[6], 9UL)); - VerifyOrReturn(CheckValue("", actualValue[7], 10UL)); - VerifyOrReturn(CheckValue("", actualValue[8], 11UL)); - VerifyOrReturn(CheckValue("", actualValue[9], 12UL)); - VerifyOrReturn(CheckValue("", actualValue[10], 13UL)); - VerifyOrReturn(CheckValue("", actualValue[11], 14UL)); - VerifyOrReturn(CheckValue("", actualValue[12], 15UL)); - VerifyOrReturn(CheckValue("", actualValue[13], 17UL)); - VerifyOrReturn(CheckValue("", actualValue[14], 18UL)); - VerifyOrReturn(CheckValue("", actualValue[15], 19UL)); - VerifyOrReturn(CheckValue("", actualValue[16], 20UL)); - VerifyOrReturn(CheckValue("", actualValue[17], 21UL)); - VerifyOrReturn(CheckValue("", actualValue[18], 22UL)); - VerifyOrReturn(CheckValue("", actualValue[19], 23UL)); - VerifyOrReturn(CheckValue("", actualValue[20], 4294049962UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidateGeneratedCommandListAttribute_492() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Validate GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(11))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 1UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 4UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 5UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 6UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 8UL)); - VerifyOrReturn(CheckValue("", actualValue[6], 9UL)); - VerifyOrReturn(CheckValue("", actualValue[7], 10UL)); - VerifyOrReturn(CheckValue("", actualValue[8], 11UL)); - VerifyOrReturn(CheckValue("", actualValue[9], 12UL)); - VerifyOrReturn(CheckValue("", actualValue[10], 4294049979UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidatePresenceOfMeiAttribute_493() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate presence of MEI attribute: Error: %@", err); - } else { - NSLog(@"Validate presence of MEI attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4294070017UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteStructTypedAttribute_494() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id structAttrArgument; - structAttrArgument = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).a = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).d = - [[NSData alloc] initWithBytes:"abc" length:3]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).e = @""; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).f = - [NSNumber numberWithUnsignedChar:17U]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).g = - [NSNumber numberWithFloat:1.5f]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).h = - [NSNumber numberWithDouble:3.14159265358979]; - - [cluster writeAttributeStructAttrWithValue:structAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write struct-typed attribute: Error: %@", err); - } else { - NSLog(@"Write struct-typed attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStructTypedAttribute_495() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStructAttrWithCompletion:^(MTRUnitTestingClusterSimpleStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read struct-typed attribute: Error: %@", err); - } else { - NSLog(@"Read struct-typed attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("a", ((MTRUnitTestingClusterSimpleStruct *) actualValue).a, 5U)); - VerifyOrReturn(CheckValue("b", ((MTRUnitTestingClusterSimpleStruct *) actualValue).b, true)); - VerifyOrReturn(CheckValue("c", ((MTRUnitTestingClusterSimpleStruct *) actualValue).c, 2U)); - VerifyOrReturn(CheckValueAsString("d", ((MTRUnitTestingClusterSimpleStruct *) actualValue).d, [[NSData alloc] initWithBytes:"abc" length:3])); - VerifyOrReturn(CheckValueAsString("e", ((MTRUnitTestingClusterSimpleStruct *) actualValue).e, @"")); - VerifyOrReturn(CheckValue("f", ((MTRUnitTestingClusterSimpleStruct *) actualValue).f, 17U)); - VerifyOrReturn(CheckValue("g", ((MTRUnitTestingClusterSimpleStruct *) actualValue).g, 1.5f)); - VerifyOrReturn(CheckValue("h", ((MTRUnitTestingClusterSimpleStruct *) actualValue).h, 3.14159265358979)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestConstraints : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestConstraints() - : TestCommandBridge("TestConstraints") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestConstraints() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestConstraints\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestConstraints\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write attribute LIST With List of INT8U\n"); - err = TestWriteAttributeListWithListOfInt8u_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute LIST With Partial List of INT8U that should be in it\n"); - err = TestReadAttributeListWithPartialListOfInt8uThatShouldBeInIt_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute LIST With Partial List of INT8U that should not be included\n"); - err = TestReadAttributeListWithPartialListOfInt8uThatShouldNotBeIncluded_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Write attribute LIST Back to Default Value\n"); - err = TestWriteAttributeListBackToDefaultValue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute BITMAP32 Default Value\n"); - err = TestReadAttributeBitmap32DefaultValue_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Write attribute BITMAP32 with MaskVal1 and MaskVal3\n"); - err = TestWriteAttributeBitmap32WithMaskVal1AndMaskVal3_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal2 is not set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal2IsNotSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal1 is set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal1IsSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal3 is set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal3IsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure Maskval1 and MaskVal3 are set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskval1AndMaskVal3AreSet_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Write attribute BITMAP32 with MaskVal1\n"); - err = TestWriteAttributeBitmap32WithMaskVal1_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read attribute BITMAP32 with MaskVal1 and ensure Maskval1 or MaskVal3 are set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndEnsureMaskval1OrMaskVal3AreSet_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Write attribute BITMAP32 Back to Default Value\n"); - err = TestWriteAttributeBitmap32BackToDefaultValue_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Write attribute INT32U Value\n"); - err = TestWriteAttributeInt32uValue_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read attribute INT32U Value MinValue Constraints\n"); - err = TestReadAttributeInt32uValueMinValueConstraints_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read attribute INT32U Value MaxValue Constraints\n"); - err = TestReadAttributeInt32uValueMaxValueConstraints_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read attribute INT32U Value NotValue Constraints\n"); - err = TestReadAttributeInt32uValueNotValueConstraints_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Write attribute INT32U Value Back to Default Value\n"); - err = TestWriteAttributeInt32uValueBackToDefaultValue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Read attribute CHAR_STRING Value MinLength Constraints\n"); - err = TestReadAttributeCharStringValueMinLengthConstraints_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute CHAR_STRING Value MaxLength Constraints\n"); - err = TestReadAttributeCharStringValueMaxLengthConstraints_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Read attribute CHAR_STRING Value StartsWith Constraints\n"); - err = TestReadAttributeCharStringValueStartsWithConstraints_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Read attribute CHAR_STRING Value EndsWith Constraints\n"); - err = TestReadAttributeCharStringValueEndsWithConstraints_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Write attribute CHAR_STRING Value with only digits\n"); - err = TestWriteAttributeCharStringValueWithOnlyDigits_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Write attribute CHAR_STRING Value with only non-letters\n"); - err = TestWriteAttributeCharStringValueWithOnlyNonLetters_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Write attribute CHAR_STRING Value with uppercase letters and symbols\n"); - err = TestWriteAttributeCharStringValueWithUppercaseLettersAndSymbols_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Write attribute CHAR_STRING Value with lowercase letters and symbols\n"); - err = TestWriteAttributeCharStringValueWithLowercaseLettersAndSymbols_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Write attribute CHAR_STRING Value which is empty\n"); - err = TestWriteAttributeCharStringValueWhichIsEmpty_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Read attribute CHAR_STRING Value isHexString Constraints\n"); - err = TestReadAttributeCharStringValueIsHexStringConstraints_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Read attribute CHAR_STRING Value isHexString Constraints\n"); - err = TestReadAttributeCharStringValueIsHexStringConstraints_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Write attribute CHAR_STRING Value Back to Default Value\n"); - err = TestWriteAttributeCharStringValueBackToDefaultValue_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Write attribute NULLABLE_CHAR_STRING Value\n"); - err = TestWriteAttributeNullableCharStringValue_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Read attribute NULLABLE_CHAR_STRING Value MinLength Constraints\n"); - err = TestReadAttributeNullableCharStringValueMinLengthConstraints_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Read attribute NULLABLE_CHAR_STRING Value MaxLength Constraints\n"); - err = TestReadAttributeNullableCharStringValueMaxLengthConstraints_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Write attribute NULLABLE_CHAR_STRING Value Back to Default Value\n"); - err = TestWriteAttributeNullableCharStringValueBackToDefaultValue_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Read attribute NULLABLE_INT8U Default Value\n"); - err = TestReadAttributeNullableInt8uDefaultValue_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Write attribute NULLABLE_INT8U with a value\n"); - err = TestWriteAttributeNullableInt8uWithAValue_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Read attribute NULLABLE_INT8U with a value\n"); - err = TestReadAttributeNullableInt8uWithAValue_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Write attribute NULLABLE_INT8U without a value\n"); - err = TestWriteAttributeNullableInt8uWithoutAValue_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Read attribute NULLABLE_INT8U with a value\n"); - err = TestReadAttributeNullableInt8uWithAValue_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Write attribute NULLABLE_INT8U back to Default Value\n"); - err = TestWriteAttributeNullableInt8uBackToDefaultValue_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Read attribute NULLABLE_OCTET_STRING Default Value\n"); - err = TestReadAttributeNullableOctetStringDefaultValue_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Write attribute NULLABLE_OCTET_STRING back to Default Value\n"); - err = TestWriteAttributeNullableOctetStringBackToDefaultValue_60(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 61; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteAttributeListWithListOfInt8u_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listInt8uArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - listInt8uArgument = temp_0; - } - [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST With List of INT8U: Error: %@", err); - } else { - NSLog(@"Write attribute LIST With List of INT8U: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithPartialListOfInt8uThatShouldBeInIt_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With Partial List of INT8U that should be in it: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With Partial List of INT8U that should be in it: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("listInt8u", value, 2U)); - VerifyOrReturn(CheckConstraintContains("listInt8u", value, 3U)); - VerifyOrReturn(CheckConstraintContains("listInt8u", value, 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithPartialListOfInt8uThatShouldNotBeIncluded_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With Partial List of INT8U that should not be included: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With Partial List of INT8U that should not be included: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("listInt8u", value, 0U)); - VerifyOrReturn(CheckConstraintExcludes("listInt8u", value, 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListBackToDefaultValue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listInt8uArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - listInt8uArgument = temp_0; - } - [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute LIST Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32DefaultValue_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32WithMaskVal1AndMaskVal3_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:5UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 with MaskVal1 and MaskVal3: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 with MaskVal1 and MaskVal3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal2IsNotSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal2 is not set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal2 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal1IsSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal1 is set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal1 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal3IsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal3 is set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal3 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskval1AndMaskVal3AreSet_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure Maskval1 and MaskVal3 are set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure Maskval1 and MaskVal3 are set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32WithMaskVal1_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 with MaskVal1: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 with MaskVal1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndEnsureMaskval1OrMaskVal3AreSet_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and ensure Maskval1 or MaskVal3 are set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and ensure Maskval1 or MaskVal3 are set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32BackToDefaultValue_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uValue_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:5UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uValueMinValueConstraints_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Value MinValue Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Value MinValue Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("int32u", [value unsignedIntValue], 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uValueMaxValueConstraints_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Value MaxValue Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Value MaxValue Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxValue("int32u", [value unsignedIntValue], 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uValueNotValueConstraints_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Value NotValue Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Value NotValue Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int32u", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uValueBackToDefaultValue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Value Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Value Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"** Test **"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueMinLengthConstraints_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value MinLength Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value MinLength Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("charString", value, 5)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueMaxLengthConstraints_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value MaxLength Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value MaxLength Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxLength("charString", value, 20)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueStartsWithConstraints_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value StartsWith Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value StartsWith Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintStartsWith("charString", value, "**")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueEndsWithConstraints_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value EndsWith Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value EndsWith Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintEndsWith("charString", value, "**")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"lowercase"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, false)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"UPPERCASE"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, false)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"lowUPPER"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, false)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, false)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWithOnlyDigits_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"1234567890"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value with only digits: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value with only digits: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWithOnlyNonLetters_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"12.4,76:"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value with only non-letters: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value with only non-letters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWithUppercaseLettersAndSymbols_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"ABC;.* "; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value with uppercase letters and symbols: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value with uppercase letters and symbols: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, false)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWithLowercaseLettersAndSymbols_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"abc;.* "; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value with lowercase letters and symbols: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value with lowercase letters and symbols: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, false)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWhichIsEmpty_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @""; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value which is empty: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value which is empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"ABCDEF012V"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsHexStringConstraints_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsHexString("charString", value, false)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"ABCDEF0123"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsHexStringConstraints_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsHexString("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueBackToDefaultValue_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @""; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharStringValue_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = nil; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharStringValueMinLengthConstraints_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MinLength Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MinLength Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinLength("nullableCharString", value, 5)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharStringValueMaxLengthConstraints_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MaxLength Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MaxLength Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMaxLength("nullableCharString", value, 20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharStringValueBackToDefaultValue_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = @""; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING Value Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING Value Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uDefaultValue_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uWithAValue_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U with a value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U with a value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uWithAValue_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U with a value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U with a value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uWithoutAValue_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = nil; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U without a value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U without a value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uWithAValue_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U with a value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U with a value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uBackToDefaultValue_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetStringDefaultValue_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = - [[NSData alloc] initWithBytes:"TestValue" length:9]; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetString_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = nil; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetString_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetStringBackToDefaultValue_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = - [[NSData alloc] initWithBytes:"" length:0]; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestDelayCommands : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestDelayCommands() - : TestCommandBridge("TestDelayCommands") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestDelayCommands() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestDelayCommands\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestDelayCommands\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Wait 100ms\n"); - err = TestWait100ms_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWait100ms_1() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } -}; - -class TestLogCommands : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestLogCommands() - : TestCommandBridge("TestLogCommands") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestLogCommands() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestLogCommands\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestLogCommands\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Log a simple message\n"); - err = TestLogASimpleMessage_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Do a simple user prompt message\n"); - err = TestDoASimpleUserPromptMessage_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestLogASimpleMessage_1() - { - - chip::app::Clusters::LogCommands::Commands::Log::Type value; - value.message = chip::Span("This is a simple messagegarbage: not in length on purpose", 24); - return Log("alpha", value); - } - - CHIP_ERROR TestDoASimpleUserPromptMessage_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("This is a simple messagegarbage: not in length on purpose", 24); - return UserPrompt("alpha", value); - } -}; - -class TestSaveAs : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSaveAs() - : TestCommandBridge("TestSaveAs") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSaveAs() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSaveAs\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSaveAs\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute BOOLEAN Default Value\n"); - err = TestReadAttributeBooleanDefaultValue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Write attribute BOOLEAN Not Default Value\n"); - err = TestWriteAttributeBooleanNotDefaultValue_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute BOOLEAN Not Default Value\n"); - err = TestReadAttributeBooleanNotDefaultValue_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write attribute BOOLEAN DefaultValue\n"); - err = TestWriteAttributeBooleanDefaultValue_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute BOOLEAN False\n"); - err = TestReadAttributeBooleanFalse_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read attribute BITMAP8 Default Value\n"); - err = TestReadAttributeBitmap8DefaultValue_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Write attribute BITMAP8 Not Default Value\n"); - err = TestWriteAttributeBitmap8NotDefaultValue_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read attribute BITMAP8 Not Default Value\n"); - err = TestReadAttributeBitmap8NotDefaultValue_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Write attribute BITMAP8 Default Value\n"); - err = TestWriteAttributeBitmap8DefaultValue_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read attribute BITMAP8 Default Value\n"); - err = TestReadAttributeBitmap8DefaultValue_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read attribute BITMAP16 Default Value\n"); - err = TestReadAttributeBitmap16DefaultValue_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Write attribute BITMAP16 Not Default Value\n"); - err = TestWriteAttributeBitmap16NotDefaultValue_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read attribute BITMAP16 Not Default Value\n"); - err = TestReadAttributeBitmap16NotDefaultValue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Write attribute BITMAP16 Default Value\n"); - err = TestWriteAttributeBitmap16DefaultValue_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read attribute BITMAP16 Default Value\n"); - err = TestReadAttributeBitmap16DefaultValue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read attribute BITMAP32 Default Value\n"); - err = TestReadAttributeBitmap32DefaultValue_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Write attribute BITMAP32 Not Default Value\n"); - err = TestWriteAttributeBitmap32NotDefaultValue_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute BITMAP32 Not Default Value\n"); - err = TestReadAttributeBitmap32NotDefaultValue_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Write attribute BITMAP32 Default Value\n"); - err = TestWriteAttributeBitmap32DefaultValue_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Read attribute BITMAP32 Default Value\n"); - err = TestReadAttributeBitmap32DefaultValue_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Read attribute BITMAP64 Default Value\n"); - err = TestReadAttributeBitmap64DefaultValue_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Write attribute BITMAP64 Not Default Value\n"); - err = TestWriteAttributeBitmap64NotDefaultValue_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Read attribute BITMAP64 Default Value\n"); - err = TestReadAttributeBitmap64DefaultValue_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Write attribute BITMAP64 Default Value\n"); - err = TestWriteAttributeBitmap64DefaultValue_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Read attribute BITMAP64 Default Value\n"); - err = TestReadAttributeBitmap64DefaultValue_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Read attribute INT8U Default Value\n"); - err = TestReadAttributeInt8uDefaultValue_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Write attribute INT8U Not Default Value\n"); - err = TestWriteAttributeInt8uNotDefaultValue_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Read attribute INT8U Not Default Value\n"); - err = TestReadAttributeInt8uNotDefaultValue_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Write attribute INT8U Default Value\n"); - err = TestWriteAttributeInt8uDefaultValue_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Read attribute INT8U Default Value\n"); - err = TestReadAttributeInt8uDefaultValue_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Read attribute INT16U Default Value\n"); - err = TestReadAttributeInt16uDefaultValue_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Write attribute INT16U Not Default Value\n"); - err = TestWriteAttributeInt16uNotDefaultValue_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Read attribute INT16U Not Default Value\n"); - err = TestReadAttributeInt16uNotDefaultValue_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Write attribute INT16U Default Value\n"); - err = TestWriteAttributeInt16uDefaultValue_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Read attribute INT16U Default Value\n"); - err = TestReadAttributeInt16uDefaultValue_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Read attribute INT32U Default Value\n"); - err = TestReadAttributeInt32uDefaultValue_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Write attribute INT32U Not Default Value\n"); - err = TestWriteAttributeInt32uNotDefaultValue_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Read attribute INT32U Not Default Value\n"); - err = TestReadAttributeInt32uNotDefaultValue_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Write attribute INT32U Default Value\n"); - err = TestWriteAttributeInt32uDefaultValue_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Read attribute INT32U Default Value\n"); - err = TestReadAttributeInt32uDefaultValue_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Read attribute INT64U Default Value\n"); - err = TestReadAttributeInt64uDefaultValue_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Write attribute INT64U Not Default Value\n"); - err = TestWriteAttributeInt64uNotDefaultValue_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Read attribute INT64U Not Default Value\n"); - err = TestReadAttributeInt64uNotDefaultValue_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Write attribute INT64U Default Value\n"); - err = TestWriteAttributeInt64uDefaultValue_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Read attribute INT64U Default Value\n"); - err = TestReadAttributeInt64uDefaultValue_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Read attribute INT8S Default Value\n"); - err = TestReadAttributeInt8sDefaultValue_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Write attribute INT8S Not Default Value\n"); - err = TestWriteAttributeInt8sNotDefaultValue_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Read attribute INT8S Not Default Value\n"); - err = TestReadAttributeInt8sNotDefaultValue_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Write attribute INT8S Default Value\n"); - err = TestWriteAttributeInt8sDefaultValue_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Read attribute INT8S Default Value\n"); - err = TestReadAttributeInt8sDefaultValue_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Read attribute INT16S Default Value\n"); - err = TestReadAttributeInt16sDefaultValue_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Write attribute INT16S Not Default Value\n"); - err = TestWriteAttributeInt16sNotDefaultValue_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Read attribute INT16S Not Default Value\n"); - err = TestReadAttributeInt16sNotDefaultValue_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Write attribute INT16S Default Value\n"); - err = TestWriteAttributeInt16sDefaultValue_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Read attribute INT16S Default Value\n"); - err = TestReadAttributeInt16sDefaultValue_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Read attribute INT32S Default Value\n"); - err = TestReadAttributeInt32sDefaultValue_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Write attribute INT32S Not Default Value\n"); - err = TestWriteAttributeInt32sNotDefaultValue_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Read attribute INT32S Not Default Value\n"); - err = TestReadAttributeInt32sNotDefaultValue_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Write attribute INT32S Default Value\n"); - err = TestWriteAttributeInt32sDefaultValue_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Read attribute INT32S Default Value\n"); - err = TestReadAttributeInt32sDefaultValue_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Read attribute INT64S Default Value\n"); - err = TestReadAttributeInt64sDefaultValue_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Write attribute INTS Not Default Value\n"); - err = TestWriteAttributeIntsNotDefaultValue_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Read attribute INT64S Not Default Value\n"); - err = TestReadAttributeInt64sNotDefaultValue_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Write attribute INT64S Default Value\n"); - err = TestWriteAttributeInt64sDefaultValue_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Read attribute INT64S Default Value\n"); - err = TestReadAttributeInt64sDefaultValue_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Read attribute ENUM8 Default Value\n"); - err = TestReadAttributeEnum8DefaultValue_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Write attribute ENUM8 Not Default Value\n"); - err = TestWriteAttributeEnum8NotDefaultValue_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Read attribute ENUM8 Not Default Value\n"); - err = TestReadAttributeEnum8NotDefaultValue_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Write attribute ENUM8 Default Value\n"); - err = TestWriteAttributeEnum8DefaultValue_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Read attribute ENUM8 Default Value\n"); - err = TestReadAttributeEnum8DefaultValue_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Read attribute ENUM16 Default Value\n"); - err = TestReadAttributeEnum16DefaultValue_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Write attribute ENUM16 Not Default Value\n"); - err = TestWriteAttributeEnum16NotDefaultValue_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Read attribute ENUM16 Not Default Value\n"); - err = TestReadAttributeEnum16NotDefaultValue_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Write attribute ENUM16 Default Value\n"); - err = TestWriteAttributeEnum16DefaultValue_77(); - break; - case 78: - ChipLogProgress(chipTool, " ***** Test Step 78 : Read attribute ENUM16 Default Value\n"); - err = TestReadAttributeEnum16DefaultValue_78(); - break; - case 79: - ChipLogProgress(chipTool, " ***** Test Step 79 : Read attribute EPOCH_US Default Value\n"); - err = TestReadAttributeEpochUsDefaultValue_79(); - break; - case 80: - ChipLogProgress(chipTool, " ***** Test Step 80 : Write attribute EPOCH_US Not Default Value\n"); - err = TestWriteAttributeEpochUsNotDefaultValue_80(); - break; - case 81: - ChipLogProgress(chipTool, " ***** Test Step 81 : Read attribute EPOCH_US Not Default Value\n"); - err = TestReadAttributeEpochUsNotDefaultValue_81(); - break; - case 82: - ChipLogProgress(chipTool, " ***** Test Step 82 : Write attribute EPOCH_US Default Value\n"); - err = TestWriteAttributeEpochUsDefaultValue_82(); - break; - case 83: - ChipLogProgress(chipTool, " ***** Test Step 83 : Read attribute EPOCH_US Default Value\n"); - err = TestReadAttributeEpochUsDefaultValue_83(); - break; - case 84: - ChipLogProgress(chipTool, " ***** Test Step 84 : Read attribute EPOCH_S Default Value\n"); - err = TestReadAttributeEpochSDefaultValue_84(); - break; - case 85: - ChipLogProgress(chipTool, " ***** Test Step 85 : Write attribute EPOCH_S Not Default Value\n"); - err = TestWriteAttributeEpochSNotDefaultValue_85(); - break; - case 86: - ChipLogProgress(chipTool, " ***** Test Step 86 : Read attribute EPOCH_S Not Default Value\n"); - err = TestReadAttributeEpochSNotDefaultValue_86(); - break; - case 87: - ChipLogProgress(chipTool, " ***** Test Step 87 : Write attribute EPOCH_S Default Value\n"); - err = TestWriteAttributeEpochSDefaultValue_87(); - break; - case 88: - ChipLogProgress(chipTool, " ***** Test Step 88 : Read attribute EPOCH_S Default Value\n"); - err = TestReadAttributeEpochSDefaultValue_88(); - break; - case 89: - ChipLogProgress(chipTool, " ***** Test Step 89 : Read attribute vendor_id Default Value\n"); - err = TestReadAttributeVendorIdDefaultValue_89(); - break; - case 90: - ChipLogProgress(chipTool, " ***** Test Step 90 : Write attribute vendor_id Not Default Value\n"); - err = TestWriteAttributeVendorIdNotDefaultValue_90(); - break; - case 91: - ChipLogProgress(chipTool, " ***** Test Step 91 : Read attribute vendor_id Not Default Value\n"); - err = TestReadAttributeVendorIdNotDefaultValue_91(); - break; - case 92: - ChipLogProgress(chipTool, " ***** Test Step 92 : Write attribute vendor_id Default Value\n"); - err = TestWriteAttributeVendorIdDefaultValue_92(); - break; - case 93: - ChipLogProgress(chipTool, " ***** Test Step 93 : Read attribute vendor_id Default Value\n"); - err = TestReadAttributeVendorIdDefaultValue_93(); - break; - case 94: - ChipLogProgress(chipTool, " ***** Test Step 94 : Read attribute char_string Default Value\n"); - err = TestReadAttributeCharStringDefaultValue_94(); - break; - case 95: - ChipLogProgress(chipTool, " ***** Test Step 95 : Read attribute char_string Default Value and compare to saved value\n"); - err = TestReadAttributeCharStringDefaultValueAndCompareToSavedValue_95(); - break; - case 96: - ChipLogProgress(chipTool, " ***** Test Step 96 : Write attribute char_string Not Default Value\n"); - err = TestWriteAttributeCharStringNotDefaultValue_96(); - break; - case 97: - ChipLogProgress(chipTool, " ***** Test Step 97 : Read attribute char_string Not Default Value\n"); - err = TestReadAttributeCharStringNotDefaultValue_97(); - break; - case 98: - ChipLogProgress(chipTool, " ***** Test Step 98 : Read attribute char_string Not Default Value and compare to saved value\n"); - err = TestReadAttributeCharStringNotDefaultValueAndCompareToSavedValue_98(); - break; - case 99: - ChipLogProgress(chipTool, " ***** Test Step 99 : Write attribute char_string Not Default Value from saved value\n"); - err = TestWriteAttributeCharStringNotDefaultValueFromSavedValue_99(); - break; - case 100: - ChipLogProgress(chipTool, " ***** Test Step 100 : Read attribute char_string Not Default Value and compare to expected value\n"); - err = TestReadAttributeCharStringNotDefaultValueAndCompareToExpectedValue_100(); - break; - case 101: - ChipLogProgress(chipTool, " ***** Test Step 101 : Write attribute char_string Default Value\n"); - err = TestWriteAttributeCharStringDefaultValue_101(); - break; - case 102: - ChipLogProgress(chipTool, " ***** Test Step 102 : Read attribute octet_string Default Value\n"); - err = TestReadAttributeOctetStringDefaultValue_102(); - break; - case 103: - ChipLogProgress(chipTool, " ***** Test Step 103 : Read attribute octet_string Default Value and compare to saved value\n"); - err = TestReadAttributeOctetStringDefaultValueAndCompareToSavedValue_103(); - break; - case 104: - ChipLogProgress(chipTool, " ***** Test Step 104 : Write attribute octet_string Not Default Value\n"); - err = TestWriteAttributeOctetStringNotDefaultValue_104(); - break; - case 105: - ChipLogProgress(chipTool, " ***** Test Step 105 : Read attribute octet_string Not Default Value\n"); - err = TestReadAttributeOctetStringNotDefaultValue_105(); - break; - case 106: - ChipLogProgress(chipTool, " ***** Test Step 106 : Read attribute octet_string Not Default Value and compare to saved value\n"); - err = TestReadAttributeOctetStringNotDefaultValueAndCompareToSavedValue_106(); - break; - case 107: - ChipLogProgress(chipTool, " ***** Test Step 107 : Write attribute octet_string Not Default Value from saved value\n"); - err = TestWriteAttributeOctetStringNotDefaultValueFromSavedValue_107(); - break; - case 108: - ChipLogProgress(chipTool, " ***** Test Step 108 : Read attribute octet_string Not Default Value and compare to expected value\n"); - err = TestReadAttributeOctetStringNotDefaultValueAndCompareToExpectedValue_108(); - break; - case 109: - ChipLogProgress(chipTool, " ***** Test Step 109 : Write attribute octet_string Default Value\n"); - err = TestWriteAttributeOctetStringDefaultValue_109(); - break; - case 110: - ChipLogProgress(chipTool, " ***** Test Step 110 : Read attribute nullable_boolean Default Value\n"); - err = TestReadAttributeNullableBooleanDefaultValue_110(); - break; - case 111: - ChipLogProgress(chipTool, " ***** Test Step 111 : Write attribute nullable_boolean to null\n"); - err = TestWriteAttributeNullableBooleanToNull_111(); - break; - case 112: - ChipLogProgress(chipTool, " ***** Test Step 112 : Read attribute nullable_boolean null Value\n"); - err = TestReadAttributeNullableBooleanNullValue_112(); - break; - case 113: - ChipLogProgress(chipTool, " ***** Test Step 113 : Read attribute nullable_boolean null Value again and compare it to the previously saved value\n"); - err = TestReadAttributeNullableBooleanNullValueAgainAndCompareItToThePreviouslySavedValue_113(); - break; - case 114: - ChipLogProgress(chipTool, " ***** Test Step 114 : Write attribute nullable_boolean Default Value\n"); - err = TestWriteAttributeNullableBooleanDefaultValue_114(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 78: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 79: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 80: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 81: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 82: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 83: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 84: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 85: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 86: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 87: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 88: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 89: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 90: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 91: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 92: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 93: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 94: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 95: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 96: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 97: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 98: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 99: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 100: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 101: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 102: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 103: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 104: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 105: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 106: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 107: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 108: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 109: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 110: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 111: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 112: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 113: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 114: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 115; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull TestAddArgumentDefaultValue; - - CHIP_ERROR TestSendTestAddArgumentsCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:17U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, 20U)); - } - { - TestAddArgumentDefaultValue = values.returnValue; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestAddArgumentsCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:17U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, TestAddArgumentDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestAddArgumentsCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [TestAddArgumentDefaultValue copy]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("returnValue", values.returnValue, TestAddArgumentDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBooleanDefaultValue; - - CHIP_ERROR TestReadAttributeBooleanDefaultValue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, 0)); - } - { - readAttributeBooleanDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBooleanNotDefaultValue_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id booleanArgument; - booleanArgument = - [NSNumber numberWithBool:1]; - [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BOOLEAN Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BOOLEAN Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanNotDefaultValue_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("boolean", value, readAttributeBooleanDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBooleanDefaultValue_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id booleanArgument; - booleanArgument = - [readAttributeBooleanDefaultValue copy]; - [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BOOLEAN DefaultValue: Error: %@", err); - } else { - NSLog(@"Write attribute BOOLEAN DefaultValue: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanFalse_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN False: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN False: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, readAttributeBooleanDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBitmap8DefaultValue; - - CHIP_ERROR TestReadAttributeBitmap8DefaultValue_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, 0U)); - } - { - readAttributeBitmap8DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap8NotDefaultValue_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap8Argument; - bitmap8Argument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP8 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP8 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8NotDefaultValue_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("bitmap8", value, readAttributeBitmap8DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap8DefaultValue_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap8Argument; - bitmap8Argument = - [readAttributeBitmap8DefaultValue copy]; - [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP8 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8DefaultValue_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, readAttributeBitmap8DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBitmap16DefaultValue; - - CHIP_ERROR TestReadAttributeBitmap16DefaultValue_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, 0U)); - } - { - readAttributeBitmap16DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap16NotDefaultValue_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap16Argument; - bitmap16Argument = - [NSNumber numberWithUnsignedShort:1U]; - [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP16 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP16 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16NotDefaultValue_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("bitmap16", value, readAttributeBitmap16DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap16DefaultValue_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap16Argument; - bitmap16Argument = - [readAttributeBitmap16DefaultValue copy]; - [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP16 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16DefaultValue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, readAttributeBitmap16DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBitmap32DefaultValue; - - CHIP_ERROR TestReadAttributeBitmap32DefaultValue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); - } - { - readAttributeBitmap32DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32NotDefaultValue_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32NotDefaultValue_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("bitmap32", value, readAttributeBitmap32DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32DefaultValue_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [readAttributeBitmap32DefaultValue copy]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32DefaultValue_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, readAttributeBitmap32DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBitmap64DefaultValue; - - CHIP_ERROR TestReadAttributeBitmap64DefaultValue_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, 0ULL)); - } - { - readAttributeBitmap64DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap64NotDefaultValue_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap64Argument; - bitmap64Argument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP64 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP64 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64DefaultValue_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("bitmap64", value, readAttributeBitmap64DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap64DefaultValue_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap64Argument; - bitmap64Argument = - [readAttributeBitmap64DefaultValue copy]; - [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64DefaultValue_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, readAttributeBitmap64DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt8uDefaultValue; - - CHIP_ERROR TestReadAttributeInt8uDefaultValue_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, 0U)); - } - { - readAttributeInt8uDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8uNotDefaultValue_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8uArgument; - int8uArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8U Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uNotDefaultValue_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int8u", value, readAttributeInt8uDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8uDefaultValue_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8uArgument; - int8uArgument = - [readAttributeInt8uDefaultValue copy]; - [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uDefaultValue_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, readAttributeInt8uDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt16uDefaultValue; - - CHIP_ERROR TestReadAttributeInt16uDefaultValue_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, 0U)); - } - { - readAttributeInt16uDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16uNotDefaultValue_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16uArgument; - int16uArgument = - [NSNumber numberWithUnsignedShort:1U]; - [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16U Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uNotDefaultValue_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int16u", value, readAttributeInt16uDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16uDefaultValue_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16uArgument; - int16uArgument = - [readAttributeInt16uDefaultValue copy]; - [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16U Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uDefaultValue_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, readAttributeInt16uDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt32uDefaultValue; - - CHIP_ERROR TestReadAttributeInt32uDefaultValue_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, 0UL)); - } - { - readAttributeInt32uDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uNotDefaultValue_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uNotDefaultValue_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int32u", value, readAttributeInt32uDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uDefaultValue_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [readAttributeInt32uDefaultValue copy]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uDefaultValue_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, readAttributeInt32uDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt64uDefaultValue; - - CHIP_ERROR TestReadAttributeInt64uDefaultValue_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, 0ULL)); - } - { - readAttributeInt64uDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64uNotDefaultValue_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64uArgument; - int64uArgument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64U Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uNotDefaultValue_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int64u", value, readAttributeInt64uDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64uDefaultValue_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64uArgument; - int64uArgument = - [readAttributeInt64uDefaultValue copy]; - [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64U Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uDefaultValue_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, readAttributeInt64uDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt8sDefaultValue; - - CHIP_ERROR TestReadAttributeInt8sDefaultValue_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, 0)); - } - { - readAttributeInt8sDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sNotDefaultValue_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [NSNumber numberWithChar:1]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sNotDefaultValue_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int8s", value, readAttributeInt8sDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sDefaultValue_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [readAttributeInt8sDefaultValue copy]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sDefaultValue_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, readAttributeInt8sDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt16sDefaultValue; - - CHIP_ERROR TestReadAttributeInt16sDefaultValue_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, 0)); - } - { - readAttributeInt16sDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sNotDefaultValue_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [NSNumber numberWithShort:1]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sNotDefaultValue_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int16s", value, readAttributeInt16sDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sDefaultValue_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [readAttributeInt16sDefaultValue copy]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sDefaultValue_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, readAttributeInt16sDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt32sDefaultValue; - - CHIP_ERROR TestReadAttributeInt32sDefaultValue_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, 0L)); - } - { - readAttributeInt32sDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sNotDefaultValue_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [NSNumber numberWithInt:1L]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sNotDefaultValue_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int32s", value, readAttributeInt32sDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sDefaultValue_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [readAttributeInt32sDefaultValue copy]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sDefaultValue_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, readAttributeInt32sDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt64sDefaultValue; - - CHIP_ERROR TestReadAttributeInt64sDefaultValue_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, 0LL)); - } - { - readAttributeInt64sDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeIntsNotDefaultValue_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [NSNumber numberWithLongLong:1LL]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INTS Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INTS Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sNotDefaultValue_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int64s", value, readAttributeInt64sDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64sDefaultValue_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [readAttributeInt64sDefaultValue copy]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sDefaultValue_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, readAttributeInt64sDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeEnum8DefaultValue; - - CHIP_ERROR TestReadAttributeEnum8DefaultValue_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, 0U)); - } - { - readAttributeEnum8DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum8NotDefaultValue_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum8Argument; - enum8Argument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM8 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM8 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8NotDefaultValue_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("enum8", value, readAttributeEnum8DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum8DefaultValue_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum8Argument; - enum8Argument = - [readAttributeEnum8DefaultValue copy]; - [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM8 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8DefaultValue_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, readAttributeEnum8DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeEnum16DefaultValue; - - CHIP_ERROR TestReadAttributeEnum16DefaultValue_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, 0U)); - } - { - readAttributeEnum16DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum16NotDefaultValue_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum16Argument; - enum16Argument = - [NSNumber numberWithUnsignedShort:1U]; - [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM16 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM16 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16NotDefaultValue_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("enum16", value, readAttributeEnum16DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum16DefaultValue_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum16Argument; - enum16Argument = - [readAttributeEnum16DefaultValue copy]; - [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM16 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16DefaultValue_78() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, readAttributeEnum16DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeEpochUSDefaultValue; - - CHIP_ERROR TestReadAttributeEpochUsDefaultValue_79() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, 0ULL)); - } - { - readAttributeEpochUSDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochUsNotDefaultValue_80() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochUsArgument; - epochUsArgument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_US Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_US Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsNotDefaultValue_81() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("epochUs", value, readAttributeEpochUSDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochUsDefaultValue_82() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochUsArgument; - epochUsArgument = - [readAttributeEpochUSDefaultValue copy]; - [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_US Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_US Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsDefaultValue_83() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, readAttributeEpochUSDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeEpochSDefaultValue; - - CHIP_ERROR TestReadAttributeEpochSDefaultValue_84() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, 0UL)); - } - { - readAttributeEpochSDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochSNotDefaultValue_85() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochSArgument; - epochSArgument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_S Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSNotDefaultValue_86() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("epochS", value, readAttributeEpochSDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochSDefaultValue_87() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochSArgument; - epochSArgument = - [readAttributeEpochSDefaultValue copy]; - [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSDefaultValue_88() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, readAttributeEpochSDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeVendorIdDefaultValue; - - CHIP_ERROR TestReadAttributeVendorIdDefaultValue_89() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("vendor_id", actualValue, 0U)); - } - { - readAttributeVendorIdDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeVendorIdNotDefaultValue_90() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id vendorIdArgument; - vendorIdArgument = - [NSNumber numberWithUnsignedShort:1U]; - [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute vendor_id Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute vendor_id Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorIdNotDefaultValue_91() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("vendorId", value, readAttributeVendorIdDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeVendorIdDefaultValue_92() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id vendorIdArgument; - vendorIdArgument = - [readAttributeVendorIdDefaultValue copy]; - [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute vendor_id Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute vendor_id Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorIdDefaultValue_93() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("vendor_id", actualValue, readAttributeVendorIdDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nonnull readAttributeCharStringDefaultValue; - - CHIP_ERROR TestReadAttributeCharStringDefaultValue_94() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"")); - } - { - readAttributeCharStringDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringDefaultValueAndCompareToSavedValue_95() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Default Value and compare to saved value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Default Value and compare to saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, readAttributeCharStringDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringNotDefaultValue_96() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"NotDefault"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute char_string Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute char_string Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nonnull readAttributeCharStringNotDefaultValue; - - CHIP_ERROR TestReadAttributeCharStringNotDefaultValue_97() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"NotDefault")); - } - - VerifyOrReturn(CheckConstraintNotValue("charString", value, readAttributeCharStringDefaultValue)); - { - readAttributeCharStringNotDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringNotDefaultValueAndCompareToSavedValue_98() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Not Default Value and compare to saved value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Not Default Value and compare to saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, readAttributeCharStringNotDefaultValue)); - } - - VerifyOrReturn(CheckConstraintNotValue("charString", value, readAttributeCharStringDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringNotDefaultValueFromSavedValue_99() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = - [readAttributeCharStringNotDefaultValue copy]; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute char_string Not Default Value from saved value: Error: %@", err); - } else { - NSLog(@"Write attribute char_string Not Default Value from saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringNotDefaultValueAndCompareToExpectedValue_100() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Not Default Value and compare to expected value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Not Default Value and compare to expected value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"NotDefault")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringDefaultValue_101() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = - [readAttributeCharStringDefaultValue copy]; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute char_string Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute char_string Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSData * _Nonnull readAttributeOctetStringDefaultValue; - - CHIP_ERROR TestReadAttributeOctetStringDefaultValue_102() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - { - readAttributeOctetStringDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringDefaultValueAndCompareToSavedValue_103() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Default Value and compare to saved value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Default Value and compare to saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, readAttributeOctetStringDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringNotDefaultValue_104() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"NotDefault" length:10]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute octet_string Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute octet_string Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSData * _Nonnull readAttributeOctetStringNotDefaultValue; - - CHIP_ERROR TestReadAttributeOctetStringNotDefaultValue_105() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"NotDefault" length:10])); - } - - VerifyOrReturn(CheckConstraintNotValue("octetString", value, readAttributeOctetStringDefaultValue)); - { - readAttributeOctetStringNotDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringNotDefaultValueAndCompareToSavedValue_106() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Not Default Value and compare to saved value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Not Default Value and compare to saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, readAttributeOctetStringNotDefaultValue)); - } - - VerifyOrReturn(CheckConstraintNotValue("octetString", value, readAttributeOctetStringDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringNotDefaultValueFromSavedValue_107() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [readAttributeOctetStringNotDefaultValue copy]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute octet_string Not Default Value from saved value: Error: %@", err); - } else { - NSLog(@"Write attribute octet_string Not Default Value from saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringNotDefaultValueAndCompareToExpectedValue_108() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Not Default Value and compare to expected value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Not Default Value and compare to expected value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"NotDefault" length:10])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringDefaultValue_109() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [readAttributeOctetStringDefaultValue copy]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute octet_string Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute octet_string Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable readAttributeNullableBooleanDefaultValue; - - CHIP_ERROR TestReadAttributeNullableBooleanDefaultValue_110() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute nullable_boolean Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute nullable_boolean Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_boolean", actualValue)); - VerifyOrReturn(CheckValue("nullable_boolean", actualValue, false)); - } - { - readAttributeNullableBooleanDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBooleanToNull_111() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBooleanArgument; - nullableBooleanArgument = nil; - [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute nullable_boolean to null: Error: %@", err); - } else { - NSLog(@"Write attribute nullable_boolean to null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable readAttributeNullableBooleanNullValue; - - CHIP_ERROR TestReadAttributeNullableBooleanNullValue_112() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute nullable_boolean null Value: Error: %@", err); - } else { - NSLog(@"Read attribute nullable_boolean null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_boolean", actualValue)); - } - { - readAttributeNullableBooleanNullValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBooleanNullValueAgainAndCompareItToThePreviouslySavedValue_113() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute nullable_boolean null Value again and compare it to the previously saved value: Error: %@", err); - } else { - NSLog(@"Read attribute nullable_boolean null Value again and compare it to the previously saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (readAttributeNullableBooleanNullValue == nil) { - VerifyOrReturn(CheckValueNull("nullable_boolean", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("nullable_boolean", actualValue)); - VerifyOrReturn(CheckValue("nullable_boolean", actualValue, readAttributeNullableBooleanNullValue)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBooleanDefaultValue_114() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBooleanArgument; - nullableBooleanArgument = - [readAttributeNullableBooleanDefaultValue copy]; - [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute nullable_boolean Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute nullable_boolean Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestConfigVariables : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestConfigVariables() - : TestCommandBridge("TestConfigVariables") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("arg1", 0, UINT8_MAX, &mArg1); - AddArgument("returnValueWithArg1", 0, UINT8_MAX, &mReturnValueWithArg1); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestConfigVariables() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestConfigVariables\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestConfigVariables\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mArg1; - chip::Optional mReturnValueWithArg1; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull TestAddArgumentDefaultValue; - - CHIP_ERROR TestSendTestAddArgumentsCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:17U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, 20U)); - } - { - TestAddArgumentDefaultValue = values.returnValue; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestAddArgumentsCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = mArg1.HasValue() ? [NSNumber numberWithUnsignedChar:mArg1.Value()] : [NSNumber numberWithUnsignedChar:5U]; - params.arg2 = - [TestAddArgumentDefaultValue copy]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, mReturnValueWithArg1.HasValue() ? mReturnValueWithArg1.Value() : 25U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestDescriptorCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestDescriptorCluster() - : TestCommandBridge("TestDescriptorCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestDescriptorCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestDescriptorCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestDescriptorCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Device list\n"); - err = TestReadAttributeDeviceList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute Server list\n"); - err = TestReadAttributeServerList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute Client list\n"); - err = TestReadAttributeClientList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute Parts list\n"); - err = TestReadAttributePartsList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute ClusterRevision\n"); - err = TestReadAttributeClusterRevision_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute Tag list\n"); - err = TestReadAttributeTagList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read feature map Attribute\n"); - err = TestReadFeatureMapAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeDeviceList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDeviceTypeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Device list: Error: %@", err); - } else { - NSLog(@"Read attribute Device list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DeviceTypeList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("DeviceType", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[0]).deviceType, 17UL)); - VerifyOrReturn(CheckValue("Revision", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[0]).revision, 1U)); - VerifyOrReturn(CheckValue("DeviceType", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[1]).deviceType, 22UL)); - VerifyOrReturn(CheckValue("Revision", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[1]).revision, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeServerList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeServerListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Server list: Error: %@", err); - } else { - NSLog(@"Read attribute Server list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ServerList", [actualValue count], static_cast(28))); - VerifyOrReturn(CheckValue("", actualValue[0], 3UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 4UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 29UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 30UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 31UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 40UL)); - VerifyOrReturn(CheckValue("", actualValue[6], 42UL)); - VerifyOrReturn(CheckValue("", actualValue[7], 43UL)); - VerifyOrReturn(CheckValue("", actualValue[8], 44UL)); - VerifyOrReturn(CheckValue("", actualValue[9], 45UL)); - VerifyOrReturn(CheckValue("", actualValue[10], 46UL)); - VerifyOrReturn(CheckValue("", actualValue[11], 47UL)); - VerifyOrReturn(CheckValue("", actualValue[12], 48UL)); - VerifyOrReturn(CheckValue("", actualValue[13], 49UL)); - VerifyOrReturn(CheckValue("", actualValue[14], 50UL)); - VerifyOrReturn(CheckValue("", actualValue[15], 51UL)); - VerifyOrReturn(CheckValue("", actualValue[16], 52UL)); - VerifyOrReturn(CheckValue("", actualValue[17], 53UL)); - VerifyOrReturn(CheckValue("", actualValue[18], 54UL)); - VerifyOrReturn(CheckValue("", actualValue[19], 55UL)); - VerifyOrReturn(CheckValue("", actualValue[20], 56UL)); - VerifyOrReturn(CheckValue("", actualValue[21], 60UL)); - VerifyOrReturn(CheckValue("", actualValue[22], 62UL)); - VerifyOrReturn(CheckValue("", actualValue[23], 63UL)); - VerifyOrReturn(CheckValue("", actualValue[24], 64UL)); - VerifyOrReturn(CheckValue("", actualValue[25], 65UL)); - VerifyOrReturn(CheckValue("", actualValue[26], 1029UL)); - VerifyOrReturn(CheckValue("", actualValue[27], 4294048774UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeClientList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClientListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Client list: Error: %@", err); - } else { - NSLog(@"Read attribute Client list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClientList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePartsList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePartsListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Parts list: Error: %@", err); - } else { - NSLog(@"Read attribute Parts list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PartsList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeClusterRevision_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ClusterRevision: Error: %@", err); - } else { - NSLog(@"Read attribute ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeTagList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTagListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Tag list: Error: %@", err); - } else { - NSLog(@"Read attribute Tag list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TagList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValueNull("MfgCode", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[0]).mfgCode)); - VerifyOrReturn(CheckValue("NamespaceID", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[0]).namespaceID, 7U)); - VerifyOrReturn(CheckValue("Tag", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[0]).tag, 0U)); - VerifyOrReturn(CheckValueNull("MfgCode", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[1]).mfgCode)); - VerifyOrReturn(CheckValue("NamespaceID", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[1]).namespaceID, 8U)); - VerifyOrReturn(CheckValue("Tag", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[1]).tag, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFeatureMapAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read feature map Attribute: Error: %@", err); - } else { - NSLog(@"Read feature map Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestFabricRemovalWhileSubscribed : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestFabricRemovalWhileSubscribed() - : TestCommandBridge("TestFabricRemovalWhileSubscribed") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestFabricRemovalWhileSubscribed() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestFabricRemovalWhileSubscribed\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestFabricRemovalWhileSubscribed\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read number of commissioned fabrics\n"); - err = TestReadNumberOfCommissionedFabrics_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current fabric index\n"); - err = TestReadCurrentFabricIndex_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Open commissioning window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Commission from beta\n"); - err = TestCommissionFromBeta_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Report: Subscribe Fabrics Attribute from beta\n"); - err = TestReportSubscribeFabricsAttributeFromBeta_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Subscribe Fabrics Attribute from beta\n"); - err = TestSubscribeFabricsAttributeFromBeta_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Remove single own fabric\n"); - err = TestRemoveSingleOwnFabric_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mDiscriminator; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadNumberOfCommissionedFabrics_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCommissionedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read number of commissioned fabrics: Error: %@", err); - } else { - NSLog(@"Read number of commissioned fabrics: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CommissionedFabrics", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("commissionedFabrics", "int8u", "int8u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ourFabricIndex; - - CHIP_ERROR TestReadCurrentFabricIndex_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current fabric index: Error: %@", err); - } else { - NSLog(@"Read current fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFabricIndex", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentFabricIndex", [value unsignedCharValue], 1U)); - { - ourFabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open commissioning window from alpha: Error: %@", err); - } else { - NSLog(@"Open commissioning window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_4() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = 74565ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = 74565ULL; - return WaitForCommissionee("beta", value); - } - bool testSendClusterTestFabricRemovalWhileSubscribed_6_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestFabricRemovalWhileSubscribed_Fabrics_Reported - = nil; - - CHIP_ERROR TestReportSubscribeFabricsAttributeFromBeta_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestFabricRemovalWhileSubscribed_Fabrics_Reported - = ^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe Fabrics Attribute from beta: Error: %@", err); - } else { - NSLog(@"Report: Subscribe Fabrics Attribute from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("fabrics", "list", "list")); - testSendClusterTestFabricRemovalWhileSubscribed_6_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeFabricsAttributeFromBeta_7() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 5U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeFabricsWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestFabricRemovalWhileSubscribed_6_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe Fabrics Attribute from beta: Error: %@", err); - } else { - NSLog(@"Subscribe Fabrics Attribute from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestFabricRemovalWhileSubscribed_Fabrics_Reported - != nil) { - ResponseHandler callback = test_TestFabricRemovalWhileSubscribed_Fabrics_Reported; - test_TestFabricRemovalWhileSubscribed_Fabrics_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveSingleOwnFabric_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [ourFabricIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove single own fabric: Error: %@", err); - } else { - NSLog(@"Remove single own fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestGeneralCommissioning : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestGeneralCommissioning() - : TestCommandBridge("TestGeneralCommissioning") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestGeneralCommissioning() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestGeneralCommissioning\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestGeneralCommissioning\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write Breadcrumb (1/2)\n"); - err = TestWriteBreadcrumb12_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read back Breadcrumb (1/2)\n"); - err = TestReadBackBreadcrumb12_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Write Breadcrumb (2/2)\n"); - err = TestWriteBreadcrumb22_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read back Breadcrumb (2/2)\n"); - err = TestReadBackBreadcrumb22_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Reboot to reset Breadcrumb\n"); - err = TestRebootToResetBreadcrumb_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Connect to the device again\n"); - err = TestConnectToTheDeviceAgain_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read back Breadcrumb after reboot and ensure it was not persisted\n"); - err = TestReadBackBreadcrumbAfterRebootAndEnsureItWasNotPersisted_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Set Breadcrumb to nonzero value\n"); - err = TestSetBreadcrumbToNonzeroValue_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Check Breadcrumb set worked\n"); - err = TestCheckBreadcrumbSetWorked_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Send CommissioningComplete without armed fail-safe\n"); - err = TestSendCommissioningCompleteWithoutArmedFailSafe_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Check Breadcrumb was not touched by invalid CommissioningComplete\n"); - err = TestCheckBreadcrumbWasNotTouchedByInvalidCommissioningComplete_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Try to arm fail-safe\n"); - err = TestTryToArmFailSafe_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Check Breadcrumb was not touched by ArmFailSafe with commissioning window open\n"); - err = TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithCommissioningWindowOpen_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Reset Breadcrumb to 0 so we can commission\n"); - err = TestResetBreadcrumbTo0SoWeCanCommission_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Commission from beta\n"); - err = TestCommissionFromBeta_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Arm fail-safe\n"); - err = TestArmFailSafe_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Check Breadcrumb was properly set by ArmFailSafe\n"); - err = TestCheckBreadcrumbWasProperlySetByArmFailSafe_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Try to arm fail-safe from wrong fabric\n"); - err = TestTryToArmFailSafeFromWrongFabric_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Check Breadcrumb was not touched by ArmFailSafe with existing fail-safe armed\n"); - err = TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithExistingFailSafeArmed_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Send CommissioningComplete from wrong fabric\n"); - err = TestSendCommissioningCompleteFromWrongFabric_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Check Breadcrumb was not touched by CommissioningComplete from wrong fabric\n"); - err = TestCheckBreadcrumbWasNotTouchedByCommissioningCompleteFromWrongFabric_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Close out the fail-safe gracefully\n"); - err = TestCloseOutTheFailSafeGracefully_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Check Breadcrumb was reset to 0 by CommissioningComplete\n"); - err = TestCheckBreadcrumbWasResetTo0ByCommissioningComplete_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Arm fail-safe again\n"); - err = TestArmFailSafeAgain_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Check Breadcrumb was set by arming fail-safe again\n"); - err = TestCheckBreadcrumbWasSetByArmingFailSafeAgain_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Force-expire the fail-safe\n"); - err = TestForceExpireTheFailSafe_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Check Breadcrumb was reset by expiring the fail-safe\n"); - err = TestCheckBreadcrumbWasResetByExpiringTheFailSafe_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Validate presence of SupportsConcurrentConnection\n"); - err = TestValidatePresenceOfSupportsConcurrentConnection_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Read original regulatory location\n"); - err = TestReadOriginalRegulatoryLocation_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Read original location\n"); - err = TestReadOriginalLocation_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Try to SetRegulatoryConfig with 0-length country code\n"); - err = TestTryToSetRegulatoryConfigWith0LengthCountryCode_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Read back location\n"); - err = TestReadBackLocation_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Try to SetRegulatoryConfig with length-1 country code\n"); - err = TestTryToSetRegulatoryConfigWithLength1CountryCode_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Read back location second time\n"); - err = TestReadBackLocationSecondTime_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Try to SetRegulatoryConfig with length-2 country code\n"); - err = TestTryToSetRegulatoryConfigWithLength2CountryCode_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Read back location third time\n"); - err = TestReadBackLocationThirdTime_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Restore initial values\n"); - err = TestRestoreInitialValues_39(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 40; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mDiscriminator; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteBreadcrumb12_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:137438953472ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write Breadcrumb (1/2): Error: %@", err); - } else { - NSLog(@"Write Breadcrumb (1/2): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackBreadcrumb12_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back Breadcrumb (1/2): Error: %@", err); - } else { - NSLog(@"Read back Breadcrumb (1/2): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 137438953472ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteBreadcrumb22_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:81ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write Breadcrumb (2/2): Error: %@", err); - } else { - NSLog(@"Write Breadcrumb (2/2): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackBreadcrumb22_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back Breadcrumb (2/2): Error: %@", err); - } else { - NSLog(@"Read back Breadcrumb (2/2): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 81ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootToResetBreadcrumb_5() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestConnectToTheDeviceAgain_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadBackBreadcrumbAfterRebootAndEnsureItWasNotPersisted_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back Breadcrumb after reboot and ensure it was not persisted: Error: %@", err); - } else { - NSLog(@"Read back Breadcrumb after reboot and ensure it was not persisted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetBreadcrumbToNonzeroValue_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Breadcrumb to nonzero value: Error: %@", err); - } else { - NSLog(@"Set Breadcrumb to nonzero value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbSetWorked_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb set worked: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb set worked: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendCommissioningCompleteWithoutArmedFailSafe_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster commissioningCompleteWithCompletion: - ^(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send CommissioningComplete without armed fail-safe: Error: %@", err); - } else { - NSLog(@"Send CommissioningComplete without armed fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByInvalidCommissioningComplete_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was not touched by invalid CommissioningComplete: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was not touched by invalid CommissioningComplete: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToArmFailSafe_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:10U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:5000ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to arm fail-safe: Error: %@", err); - } else { - NSLog(@"Try to arm fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithCommissioningWindowOpen_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with commissioning window open: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with commissioning window open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResetBreadcrumbTo0SoWeCanCommission_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reset Breadcrumb to 0 so we can commission: Error: %@", err); - } else { - NSLog(@"Reset Breadcrumb to 0 so we can commission: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_16() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = 74565ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = 74565ULL; - return WaitForCommissionee("beta", value); - } - - CHIP_ERROR TestArmFailSafe_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:500U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:2ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Arm fail-safe: Error: %@", err); - } else { - NSLog(@"Arm fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasProperlySetByArmFailSafe_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was properly set by ArmFailSafe: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was properly set by ArmFailSafe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 2ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToArmFailSafeFromWrongFabric_20() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:10U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:5000ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to arm fail-safe from wrong fabric: Error: %@", err); - } else { - NSLog(@"Try to arm fail-safe from wrong fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithExistingFailSafeArmed_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with existing fail-safe armed: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with existing fail-safe armed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 2ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendCommissioningCompleteFromWrongFabric_22() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster commissioningCompleteWithCompletion: - ^(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send CommissioningComplete from wrong fabric: Error: %@", err); - } else { - NSLog(@"Send CommissioningComplete from wrong fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByCommissioningCompleteFromWrongFabric_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was not touched by CommissioningComplete from wrong fabric: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was not touched by CommissioningComplete from wrong fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 2ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseOutTheFailSafeGracefully_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster commissioningCompleteWithCompletion: - ^(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close out the fail-safe gracefully: Error: %@", err); - } else { - NSLog(@"Close out the fail-safe gracefully: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasResetTo0ByCommissioningComplete_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was reset to 0 by CommissioningComplete: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was reset to 0 by CommissioningComplete: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestArmFailSafeAgain_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:500U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:3ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Arm fail-safe again: Error: %@", err); - } else { - NSLog(@"Arm fail-safe again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasSetByArmingFailSafeAgain_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was set by arming fail-safe again: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was set by arming fail-safe again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 3ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestForceExpireTheFailSafe_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:0U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:4ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Force-expire the fail-safe: Error: %@", err); - } else { - NSLog(@"Force-expire the fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasResetByExpiringTheFailSafe_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was reset by expiring the fail-safe: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was reset by expiring the fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidatePresenceOfSupportsConcurrentConnection_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportsConcurrentConnectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate presence of SupportsConcurrentConnection: Error: %@", err); - } else { - NSLog(@"Validate presence of SupportsConcurrentConnection: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportsConcurrentConnection", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull originalRegulatoryConfig; - - CHIP_ERROR TestReadOriginalRegulatoryLocation_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRegulatoryConfigWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read original regulatory location: Error: %@", err); - } else { - NSLog(@"Read original regulatory location: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - originalRegulatoryConfig = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nonnull originalLocation; - - CHIP_ERROR TestReadOriginalLocation_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read original location: Error: %@", err); - } else { - NSLog(@"Read original location: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, @"XX")); - } - { - originalLocation = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToSetRegulatoryConfigWith0LengthCountryCode_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; - params.newRegulatoryConfig = - [NSNumber numberWithUnsignedChar:0U]; - params.countryCode = @""; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster setRegulatoryConfigWithParams:params completion: - ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to SetRegulatoryConfig with 0-length country code: Error: %@", err); - } else { - NSLog(@"Try to SetRegulatoryConfig with 0-length country code: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackLocation_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back location: Error: %@", err); - } else { - NSLog(@"Read back location: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, originalLocation)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToSetRegulatoryConfigWithLength1CountryCode_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; - params.newRegulatoryConfig = - [NSNumber numberWithUnsignedChar:0U]; - params.countryCode = @"U"; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster setRegulatoryConfigWithParams:params completion: - ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to SetRegulatoryConfig with length-1 country code: Error: %@", err); - } else { - NSLog(@"Try to SetRegulatoryConfig with length-1 country code: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackLocationSecondTime_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back location second time: Error: %@", err); - } else { - NSLog(@"Read back location second time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, originalLocation)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToSetRegulatoryConfigWithLength2CountryCode_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; - params.newRegulatoryConfig = - [NSNumber numberWithUnsignedChar:0U]; - params.countryCode = @"US"; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster setRegulatoryConfigWithParams:params completion: - ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to SetRegulatoryConfig with length-2 country code: Error: %@", err); - } else { - NSLog(@"Try to SetRegulatoryConfig with length-2 country code: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - { - id actualValue = values.debugText; - VerifyOrReturn(CheckValueAsString("DebugText", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackLocationThirdTime_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back location third time: Error: %@", err); - } else { - NSLog(@"Read back location third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, @"US")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRestoreInitialValues_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; - params.newRegulatoryConfig = - [originalRegulatoryConfig copy]; - params.countryCode = - [originalLocation copy]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster setRegulatoryConfigWithParams:params completion: - ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Restore initial values: Error: %@", err); - } else { - NSLog(@"Restore initial values: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestIdentifyCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestIdentifyCluster() - : TestCommandBridge("TestIdentifyCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestIdentifyCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestIdentifyCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestIdentifyCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Identify command and expect success response\n"); - err = TestSendIdentifyCommandAndExpectSuccessResponse_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendIdentifyCommandAndExpectSuccessResponse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterIdentifyParams alloc] init]; - params.identifyTime = - [NSNumber numberWithUnsignedShort:0U]; - [cluster identifyWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Identify command and expect success response: Error: %@", err); - } else { - NSLog(@"Send Identify command and expect success response: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestOperationalCredentialsCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestOperationalCredentialsCluster() - : TestCommandBridge("TestOperationalCredentialsCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestOperationalCredentialsCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestOperationalCredentialsCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestOperationalCredentialsCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read number of supported fabrics\n"); - err = TestReadNumberOfSupportedFabrics_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read number of commissioned fabrics\n"); - err = TestReadNumberOfCommissionedFabrics_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read current fabric index\n"); - err = TestReadCurrentFabricIndex_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Remove nonexistent fabric\n"); - err = TestRemoveNonexistentFabric_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read fabric list before setting label\n"); - err = TestReadFabricListBeforeSettingLabel_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Set the fabric label\n"); - err = TestSetTheFabricLabel_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read fabric list after setting label\n"); - err = TestReadFabricListAfterSettingLabel_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadNumberOfSupportedFabrics_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read number of supported fabrics: Error: %@", err); - } else { - NSLog(@"Read number of supported fabrics: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedFabrics", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("supportedFabrics", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNumberOfCommissionedFabrics_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCommissionedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read number of commissioned fabrics: Error: %@", err); - } else { - NSLog(@"Read number of commissioned fabrics: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("commissionedFabrics", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("commissionedFabrics", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ourFabricIndex; - - CHIP_ERROR TestReadCurrentFabricIndex_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current fabric index: Error: %@", err); - } else { - NSLog(@"Read current fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFabricIndex", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentFabricIndex", [value unsignedCharValue], 1U)); - { - ourFabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveNonexistentFabric_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [NSNumber numberWithUnsignedChar:243U]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove nonexistent fabric: Error: %@", err); - } else { - NSLog(@"Remove nonexistent fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.statusCode; - VerifyOrReturn(CheckValue("StatusCode", actualValue, 11U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFabricListBeforeSettingLabel_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read fabric list before setting label: Error: %@", err); - } else { - NSLog(@"Read fabric list before setting label: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Label", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).label, @"")); - VerifyOrReturn(CheckValue("FabricIndex", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).fabricIndex, ourFabricIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTheFabricLabel_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"Batcave"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set the fabric label: Error: %@", err); - } else { - NSLog(@"Set the fabric label: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.statusCode; - VerifyOrReturn(CheckValue("StatusCode", actualValue, 0U)); - } - - { - id actualValue = values.fabricIndex; - VerifyOrReturn(CheckValue("FabricIndex", actualValue, ourFabricIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFabricListAfterSettingLabel_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read fabric list after setting label: Error: %@", err); - } else { - NSLog(@"Read fabric list after setting label: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Label", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).label, @"Batcave")); - VerifyOrReturn(CheckValue("FabricIndex", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).fabricIndex, ourFabricIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestModeSelectCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestModeSelectCluster() - : TestCommandBridge("TestModeSelectCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestModeSelectCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestModeSelectCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestModeSelectCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Description\n"); - err = TestReadDescription_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read StandardNamespace\n"); - err = TestReadStandardNamespace_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read SupportedModes\n"); - err = TestReadSupportedModes_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read CurrentMode\n"); - err = TestReadCurrentMode_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read StartUpMode\n"); - err = TestReadStartUpMode_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read OnMode\n"); - err = TestReadOnMode_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Change to Supported Mode\n"); - err = TestChangeToSupportedMode_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify Current Mode Change\n"); - err = TestVerifyCurrentModeChange_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Change to Unsupported Mode\n"); - err = TestChangeToUnsupportedMode_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Toggle OnOff\n"); - err = TestToggleOnOff_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Toggle OnOff\n"); - err = TestToggleOnOff_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Verify Current Mode does not change when OnMode is null\n"); - err = TestVerifyCurrentModeDoesNotChangeWhenOnModeIsNull_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Change to Unsupported OnMode\n"); - err = TestChangeToUnsupportedOnMode_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Change OnMode\n"); - err = TestChangeOnMode_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Verify OnMode\n"); - err = TestVerifyOnMode_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Toggle OnOff\n"); - err = TestToggleOnOff_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Toggle OnOff\n"); - err = TestToggleOnOff_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Verify Current Mode Changes if OnMode is not null\n"); - err = TestVerifyCurrentModeChangesIfOnModeIsNotNull_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Change to Unsupported StartUp Mode\n"); - err = TestChangeToUnsupportedStartUpMode_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Change to Supported StartUp Mode\n"); - err = TestChangeToSupportedStartUpMode_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Verify StartUp Mode Change\n"); - err = TestVerifyStartUpModeChange_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Change CurrentMode to another value\n"); - err = TestChangeCurrentModeToAnotherValue_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Change On Mode\n"); - err = TestChangeOnMode_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Set StartUpOnOff\n"); - err = TestSetStartUpOnOff_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Reboot target device\n"); - err = TestRebootTargetDevice_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Verify Current Mode Change based on OnMode, as it overwrites StartUpMode\n"); - err = TestVerifyCurrentModeChangeBasedOnOnModeAsItOverwritesStartUpMode_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Change On Mode to Null\n"); - err = TestChangeOnModeToNull_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Reboot target device\n"); - err = TestRebootTargetDevice_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Verify Current Mode Change based on new StartUp Mode\n"); - err = TestVerifyCurrentModeChangeBasedOnNewStartUpMode_31(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 32; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadDescription_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDescriptionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Description: Error: %@", err); - } else { - NSLog(@"Read Description: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Description", actualValue, @"Coffee")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStandardNamespace_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStandardNamespaceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read StandardNamespace: Error: %@", err); - } else { - NSLog(@"Read StandardNamespace: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StandardNamespace", actualValue)); - VerifyOrReturn(CheckValue("StandardNamespace", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadSupportedModes_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedModesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read SupportedModes: Error: %@", err); - } else { - NSLog(@"Read SupportedModes: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SupportedModes", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).label, @"Black")); - VerifyOrReturn(CheckValue("Mode", ((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).mode, 0U)); - VerifyOrReturn(CheckValue("SemanticTags", [((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).semanticTags count], static_cast(1))); - VerifyOrReturn(CheckValue("Value", ((MTRModeSelectClusterSemanticTagStruct *) ((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).semanticTags[0]).value, 0U)); - VerifyOrReturn(CheckValueAsString("Label", ((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).label, @"Cappuccino")); - VerifyOrReturn(CheckValue("Mode", ((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).mode, 4U)); - VerifyOrReturn(CheckValue("SemanticTags", [((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).semanticTags count], static_cast(1))); - VerifyOrReturn(CheckValue("Value", ((MTRModeSelectClusterSemanticTagStruct *) ((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).semanticTags[0]).value, 0U)); - VerifyOrReturn(CheckValueAsString("Label", ((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).label, @"Espresso")); - VerifyOrReturn(CheckValue("Mode", ((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).mode, 7U)); - VerifyOrReturn(CheckValue("SemanticTags", [((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).semanticTags count], static_cast(1))); - VerifyOrReturn(CheckValue("Value", ((MTRModeSelectClusterSemanticTagStruct *) ((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).semanticTags[0]).value, 0U)); - } - - VerifyOrReturn(CheckConstraintType("supportedModes", "list", "list")); - VerifyOrReturn(CheckConstraintMinLength("supportedModes", value, 3)); - VerifyOrReturn(CheckConstraintMaxLength("supportedModes", value, 3)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentMode_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read CurrentMode: Error: %@", err); - } else { - NSLog(@"Read CurrentMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStartUpMode_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read StartUpMode: Error: %@", err); - } else { - NSLog(@"Read StartUpMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StartUpMode", actualValue)); - VerifyOrReturn(CheckValue("StartUpMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadOnMode_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read OnMode: Error: %@", err); - } else { - NSLog(@"Read OnMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("OnMode", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToSupportedMode_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRModeSelectClusterChangeToModeParams alloc] init]; - params.newMode = - [NSNumber numberWithUnsignedChar:4U]; - [cluster changeToModeWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Supported Mode: Error: %@", err); - } else { - NSLog(@"Change to Supported Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull currentModeBeforeToggle; - - CHIP_ERROR TestVerifyCurrentModeChange_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode Change: Error: %@", err); - } else { - NSLog(@"Verify Current Mode Change: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, 4U)); - } - { - currentModeBeforeToggle = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToUnsupportedMode_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRModeSelectClusterChangeToModeParams alloc] init]; - params.newMode = - [NSNumber numberWithUnsignedChar:2U]; - [cluster changeToModeWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Unsupported Mode: Error: %@", err); - } else { - NSLog(@"Change to Unsupported Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestToggleOnOff_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Toggle OnOff: Error: %@", err); - } else { - NSLog(@"Toggle OnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestToggleOnOff_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Toggle OnOff: Error: %@", err); - } else { - NSLog(@"Toggle OnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCurrentModeDoesNotChangeWhenOnModeIsNull_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode does not change when OnMode is null: Error: %@", err); - } else { - NSLog(@"Verify Current Mode does not change when OnMode is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, currentModeBeforeToggle)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToUnsupportedOnMode_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onModeArgument; - onModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Unsupported OnMode: Error: %@", err); - } else { - NSLog(@"Change to Unsupported OnMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeOnMode_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onModeArgument; - onModeArgument = - [NSNumber numberWithUnsignedChar:7U]; - [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change OnMode: Error: %@", err); - } else { - NSLog(@"Change OnMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable OnModeValue; - - CHIP_ERROR TestVerifyOnMode_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify OnMode: Error: %@", err); - } else { - NSLog(@"Verify OnMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OnMode", actualValue)); - VerifyOrReturn(CheckValue("OnMode", actualValue, 7U)); - } - { - OnModeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestToggleOnOff_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Toggle OnOff: Error: %@", err); - } else { - NSLog(@"Toggle OnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestToggleOnOff_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Toggle OnOff: Error: %@", err); - } else { - NSLog(@"Toggle OnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCurrentModeChangesIfOnModeIsNotNull_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode Changes if OnMode is not null: Error: %@", err); - } else { - NSLog(@"Verify Current Mode Changes if OnMode is not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, OnModeValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToUnsupportedStartUpMode_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpModeArgument; - startUpModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeStartUpModeWithValue:startUpModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Unsupported StartUp Mode: Error: %@", err); - } else { - NSLog(@"Change to Unsupported StartUp Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToSupportedStartUpMode_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpModeArgument; - startUpModeArgument = - [NSNumber numberWithUnsignedChar:7U]; - [cluster writeAttributeStartUpModeWithValue:startUpModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Supported StartUp Mode: Error: %@", err); - } else { - NSLog(@"Change to Supported StartUp Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyStartUpModeChange_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify StartUp Mode Change: Error: %@", err); - } else { - NSLog(@"Verify StartUp Mode Change: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StartUpMode", actualValue)); - VerifyOrReturn(CheckValue("StartUpMode", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeCurrentModeToAnotherValue_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRModeSelectClusterChangeToModeParams alloc] init]; - params.newMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster changeToModeWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change CurrentMode to another value: Error: %@", err); - } else { - NSLog(@"Change CurrentMode to another value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeOnMode_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onModeArgument; - onModeArgument = - [NSNumber numberWithUnsignedChar:4U]; - [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change On Mode: Error: %@", err); - } else { - NSLog(@"Change On Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetStartUpOnOff_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set StartUpOnOff: Error: %@", err); - } else { - NSLog(@"Set StartUpOnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootTargetDevice_25() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_26() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestVerifyCurrentModeChangeBasedOnOnModeAsItOverwritesStartUpMode_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode Change based on OnMode, as it overwrites StartUpMode: Error: %@", err); - } else { - NSLog(@"Verify Current Mode Change based on OnMode, as it overwrites StartUpMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeOnModeToNull_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onModeArgument; - onModeArgument = nil; - [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change On Mode to Null: Error: %@", err); - } else { - NSLog(@"Change On Mode to Null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootTargetDevice_29() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_30() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestVerifyCurrentModeChangeBasedOnNewStartUpMode_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode Change based on new StartUp Mode: Error: %@", err); - } else { - NSLog(@"Verify Current Mode Change based on new StartUp Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestTemperatureControl : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestTemperatureControl() - : TestCommandBridge("TestTemperatureControl") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestTemperatureControl() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestTemperatureControl\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestTemperatureControl\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read supported temperature levels\n"); - err = TestReadSupportedTemperatureLevels_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read selected temperature level\n"); - err = TestReadSelectedTemperatureLevel_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Set temperature level to different level\n"); - err = TestSetTemperatureLevelToDifferentLevel_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read back selected temperature level\n"); - err = TestReadBackSelectedTemperatureLevel_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Set temperature level to different level\n"); - err = TestSetTemperatureLevelToDifferentLevel_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read back selected temperature level\n"); - err = TestReadBackSelectedTemperatureLevel_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadSupportedTemperatureLevels_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedTemperatureLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read supported temperature levels: Error: %@", err); - } else { - NSLog(@"Read supported temperature levels: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SupportedTemperatureLevels", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], @"Hot")); - VerifyOrReturn(CheckValueAsString("", actualValue[1], @"Warm")); - VerifyOrReturn(CheckValueAsString("", actualValue[2], @"Freezing")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadSelectedTemperatureLevel_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read selected temperature level: Error: %@", err); - } else { - NSLog(@"Read selected temperature level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTemperatureLevelToDifferentLevel_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperatureLevel = - [NSNumber numberWithUnsignedChar:1U]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set temperature level to different level: Error: %@", err); - } else { - NSLog(@"Set temperature level to different level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSelectedTemperatureLevel_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back selected temperature level: Error: %@", err); - } else { - NSLog(@"Read back selected temperature level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTemperatureLevelToDifferentLevel_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperatureLevel = - [NSNumber numberWithUnsignedChar:3U]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set temperature level to different level: Error: %@", err); - } else { - NSLog(@"Set temperature level to different level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSelectedTemperatureLevel_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back selected temperature level: Error: %@", err); - } else { - NSLog(@"Read back selected temperature level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestSelfFabricRemoval : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSelfFabricRemoval() - : TestCommandBridge("TestSelfFabricRemoval") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSelfFabricRemoval() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSelfFabricRemoval\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSelfFabricRemoval\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read number of commissioned fabrics\n"); - err = TestReadNumberOfCommissionedFabrics_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current fabric index\n"); - err = TestReadCurrentFabricIndex_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Remove single own fabric\n"); - err = TestRemoveSingleOwnFabric_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadNumberOfCommissionedFabrics_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCommissionedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read number of commissioned fabrics: Error: %@", err); - } else { - NSLog(@"Read number of commissioned fabrics: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CommissionedFabrics", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("commissionedFabrics", "int8u", "int8u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ourFabricIndex; - - CHIP_ERROR TestReadCurrentFabricIndex_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current fabric index: Error: %@", err); - } else { - NSLog(@"Read current fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFabricIndex", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentFabricIndex", [value unsignedCharValue], 1U)); - { - ourFabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveSingleOwnFabric_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [ourFabricIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove single own fabric: Error: %@", err); - } else { - NSLog(@"Remove single own fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestSystemCommands : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSystemCommands() - : TestCommandBridge("TestSystemCommands") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("payload", &mPayload); - AddArgument("secondNodeId", 0, UINT64_MAX, &mSecondNodeId); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSystemCommands() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSystemCommands\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSystemCommands\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Stop the default accessory\n"); - err = TestStopTheDefaultAccessory_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Start the default accessory with no command line options\n"); - err = TestStartTheDefaultAccessoryWithNoCommandLineOptions_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Stop the default accessory by key\n"); - err = TestStopTheDefaultAccessoryByKey_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Start the default accessory with discriminator command line option\n"); - err = TestStartTheDefaultAccessoryWithDiscriminatorCommandLineOption_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Stop the default accessory\n"); - err = TestStopTheDefaultAccessory_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Start the default accessory with discriminator and port command line options\n"); - err = TestStartTheDefaultAccessoryWithDiscriminatorAndPortCommandLineOptions_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Stop the default accessory\n"); - err = TestStopTheDefaultAccessory_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Start the default accessory with minCommissioningTimeout only\n"); - err = TestStartTheDefaultAccessoryWithMinCommissioningTimeoutOnly_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Stop the default accessory\n"); - err = TestStopTheDefaultAccessory_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Start the default accessory by key with all command line options\n"); - err = TestStartTheDefaultAccessoryByKeyWithAllCommandLineOptions_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Start a second accessory with all command line options\n"); - err = TestStartASecondAccessoryWithAllCommandLineOptions_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Commission second accessory from alpha\n"); - err = TestCommissionSecondAccessoryFromAlpha_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for the second commissioned device to be retrieved for alpha\n"); - err = TestWaitForTheSecondCommissionedDeviceToBeRetrievedForAlpha_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Stop the second accessory\n"); - err = TestStopTheSecondAccessory_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Start a second accessory with different KVS\n"); - err = TestStartASecondAccessoryWithDifferentKvs_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Commission second accessory with new KVS from alpha\n"); - err = TestCommissionSecondAccessoryWithNewKvsFromAlpha_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait for the second commissioned device with new KVS to be retrieved for alpha\n"); - err = TestWaitForTheSecondCommissionedDeviceWithNewKvsToBeRetrievedForAlpha_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Reboot the default accessory\n"); - err = TestRebootTheDefaultAccessory_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Reboot the default accessory by key\n"); - err = TestRebootTheDefaultAccessoryByKey_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Reboot the second accessory\n"); - err = TestRebootTheSecondAccessory_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Factory Reset the default accessory\n"); - err = TestFactoryResetTheDefaultAccessory_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Factory Reset the default accessory by key\n"); - err = TestFactoryResetTheDefaultAccessoryByKey_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Factory Reset the second accessory\n"); - err = TestFactoryResetTheSecondAccessory_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Commission the now-reset second accessory from alpha\n"); - err = TestCommissionTheNowResetSecondAccessoryFromAlpha_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Wait for the second commissioned device (after reset) to be retrieved for alpha\n"); - err = TestWaitForTheSecondCommissionedDeviceAfterResetToBeRetrievedForAlpha_25(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 26; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPayload; - chip::Optional mSecondNodeId; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessory_1() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryWithNoCommandLineOptions_2() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - return Start("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessoryByKey_3() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryWithDiscriminatorCommandLineOption_4() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.discriminator.Emplace(); - value.discriminator.Value() = 1111U; - return Start("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessory_5() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryWithDiscriminatorAndPortCommandLineOptions_6() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.discriminator.Emplace(); - value.discriminator.Value() = 1111U; - value.port.Emplace(); - value.port.Value() = 5560U; - return Start("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessory_7() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryWithMinCommissioningTimeoutOnly_8() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.minCommissioningTimeout.Emplace(); - value.minCommissioningTimeout.Value() = 10U; - return Start("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessory_9() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryByKeyWithAllCommandLineOptions_10() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - value.discriminator.Emplace(); - value.discriminator.Value() = 1111U; - value.port.Emplace(); - value.port.Value() = 5560U; - value.kvs.Emplace(); - value.kvs.Value() = chip::Span("/tmp/chip_kvs_defaultgarbage: not in length on purpose", 21); - value.minCommissioningTimeout.Emplace(); - value.minCommissioningTimeout.Value() = 10U; - return Start("alpha", value); - } - - CHIP_ERROR TestStartASecondAccessoryWithAllCommandLineOptions_11() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - value.discriminator.Emplace(); - value.discriminator.Value() = 50U; - value.port.Emplace(); - value.port.Value() = 5561U; - value.kvs.Emplace(); - value.kvs.Value() = chip::Span("/tmp/chip_kvs_lockgarbage: not in length on purpose", 18); - return Start("alpha", value); - } - - CHIP_ERROR TestCommissionSecondAccessoryFromAlpha_12() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestWaitForTheSecondCommissionedDeviceToBeRetrievedForAlpha_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStopTheSecondAccessory_14() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - return Stop("alpha", value); - } - - CHIP_ERROR TestStartASecondAccessoryWithDifferentKvs_15() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - value.discriminator.Emplace(); - value.discriminator.Value() = 50U; - value.port.Emplace(); - value.port.Value() = 5561U; - value.kvs.Emplace(); - value.kvs.Value() = chip::Span("/tmp/chip_kvs_lock2garbage: not in length on purpose", 19); - return Start("alpha", value); - } - - CHIP_ERROR TestCommissionSecondAccessoryWithNewKvsFromAlpha_16() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestWaitForTheSecondCommissionedDeviceWithNewKvsToBeRetrievedForAlpha_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestRebootTheDefaultAccessory_18() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestRebootTheDefaultAccessoryByKey_19() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - return Reboot("alpha", value); - } - - CHIP_ERROR TestRebootTheSecondAccessory_20() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - return Reboot("alpha", value); - } - - CHIP_ERROR TestFactoryResetTheDefaultAccessory_21() - { - - chip::app::Clusters::SystemCommands::Commands::FactoryReset::Type value; - return FactoryReset("alpha", value); - } - - CHIP_ERROR TestFactoryResetTheDefaultAccessoryByKey_22() - { - - chip::app::Clusters::SystemCommands::Commands::FactoryReset::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - return FactoryReset("alpha", value); - } - - CHIP_ERROR TestFactoryResetTheSecondAccessory_23() - { - - chip::app::Clusters::SystemCommands::Commands::FactoryReset::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - return FactoryReset("alpha", value); - } - - CHIP_ERROR TestCommissionTheNowResetSecondAccessoryFromAlpha_24() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestWaitForTheSecondCommissionedDeviceAfterResetToBeRetrievedForAlpha_25() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - return WaitForCommissionee("alpha", value); - } -}; - -class TestBinding : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestBinding() - : TestCommandBridge("TestBinding") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestBinding() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestBinding\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestBinding\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write empty binding table\n"); - err = TestWriteEmptyBindingTable_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read empty binding table\n"); - err = TestReadEmptyBindingTable_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Write invalid binding table\n"); - err = TestWriteInvalidBindingTable_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Write binding table (endpoint 1)\n"); - err = TestWriteBindingTableEndpoint1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read binding table (endpoint 1)\n"); - err = TestReadBindingTableEndpoint1_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Write binding table (endpoint 0)\n"); - err = TestWriteBindingTableEndpoint0_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read binding table (endpoint 0)\n"); - err = TestReadBindingTableEndpoint0_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify endpoint 1 not changed\n"); - err = TestVerifyEndpoint1NotChanged_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Write over-long binding table on endpoint 1\n"); - err = TestWriteOverLongBindingTableOnEndpoint1_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteEmptyBindingTable_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write empty binding table: Error: %@", err); - } else { - NSLog(@"Write empty binding table: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEmptyBindingTable_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read empty binding table: Error: %@", err); - } else { - NSLog(@"Read empty binding table: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteInvalidBindingTable_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).node = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).group = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write invalid binding table: Error: %@", err); - } else { - NSLog(@"Write invalid binding table: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteBindingTableEndpoint1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).group = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).node = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[2] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).node = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write binding table (endpoint 1): Error: %@", err); - } else { - NSLog(@"Write binding table (endpoint 1): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBindingTableEndpoint1_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read binding table (endpoint 1): Error: %@", err); - } else { - NSLog(@"Read binding table (endpoint 1): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("Group", ((MTRBindingClusterTargetStruct *) actualValue[0]).group, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[1]).node, 1ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[1]).endpoint, 1U)); - VerifyOrReturn(CheckValue("Cluster", ((MTRBindingClusterTargetStruct *) actualValue[1]).cluster, 6UL)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[1]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[2]).node, 2ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[2]).endpoint, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[2]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteBindingTableEndpoint0_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).node = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write binding table (endpoint 0): Error: %@", err); - } else { - NSLog(@"Write binding table (endpoint 0): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBindingTableEndpoint0_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read binding table (endpoint 0): Error: %@", err); - } else { - NSLog(@"Read binding table (endpoint 0): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[0]).node, 3ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[0]).endpoint, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyEndpoint1NotChanged_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify endpoint 1 not changed: Error: %@", err); - } else { - NSLog(@"Verify endpoint 1 not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("Group", ((MTRBindingClusterTargetStruct *) actualValue[0]).group, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[1]).node, 1ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[1]).endpoint, 1U)); - VerifyOrReturn(CheckValue("Cluster", ((MTRBindingClusterTargetStruct *) actualValue[1]).cluster, 6UL)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[1]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[2]).node, 2ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[2]).endpoint, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[2]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteOverLongBindingTableOnEndpoint1_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).node = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).node = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).endpoint = - [NSNumber numberWithUnsignedShort:2U]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[2] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).node = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).endpoint = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[3] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[3]).node = - [NSNumber numberWithUnsignedLongLong:4ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[3]).endpoint = - [NSNumber numberWithUnsignedShort:4U]; - ((MTRBindingClusterTargetStruct *) temp_0[3]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[3]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[4] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[4]).node = - [NSNumber numberWithUnsignedLongLong:5ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[4]).endpoint = - [NSNumber numberWithUnsignedShort:5U]; - ((MTRBindingClusterTargetStruct *) temp_0[4]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[4]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[5] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[5]).node = - [NSNumber numberWithUnsignedLongLong:6ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[5]).endpoint = - [NSNumber numberWithUnsignedShort:6U]; - ((MTRBindingClusterTargetStruct *) temp_0[5]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[5]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[6] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[6]).node = - [NSNumber numberWithUnsignedLongLong:7ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[6]).endpoint = - [NSNumber numberWithUnsignedShort:7U]; - ((MTRBindingClusterTargetStruct *) temp_0[6]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[6]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[7] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[7]).node = - [NSNumber numberWithUnsignedLongLong:8ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[7]).endpoint = - [NSNumber numberWithUnsignedShort:8U]; - ((MTRBindingClusterTargetStruct *) temp_0[7]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[7]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[8] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[8]).node = - [NSNumber numberWithUnsignedLongLong:9ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[8]).endpoint = - [NSNumber numberWithUnsignedShort:9U]; - ((MTRBindingClusterTargetStruct *) temp_0[8]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[8]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[9] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[9]).node = - [NSNumber numberWithUnsignedLongLong:10ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[9]).endpoint = - [NSNumber numberWithUnsignedShort:10U]; - ((MTRBindingClusterTargetStruct *) temp_0[9]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[9]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[10] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[10]).node = - [NSNumber numberWithUnsignedLongLong:11ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[10]).endpoint = - [NSNumber numberWithUnsignedShort:11U]; - ((MTRBindingClusterTargetStruct *) temp_0[10]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[10]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write over-long binding table on endpoint 1: Error: %@", err); - } else { - NSLog(@"Write over-long binding table on endpoint 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestUserLabelCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestUserLabelCluster() - : TestCommandBridge("TestUserLabelCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestUserLabelCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestUserLabelCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestUserLabelCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Commit User Label List\n"); - err = TestCommitUserLabelList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify committed User Label List\n"); - err = TestVerifyCommittedUserLabelList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Clear User Label List\n"); - err = TestClearUserLabelList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read User Label List\n"); - err = TestReadUserLabelList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Write User Label List\n"); - err = TestWriteUserLabelList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Reboot target device\n"); - err = TestRebootTargetDevice_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify User Label List after reboot\n"); - err = TestVerifyUserLabelListAfterReboot_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestCommitUserLabelList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 1"; - - temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"orientation"; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"South"; - - temp_0[2] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).label = @"floor"; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).value = @"2"; - - temp_0[3] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).label = @"direction"; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).value = @"down"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Commit User Label List: Error: %@", err); - } else { - NSLog(@"Commit User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCommittedUserLabelList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify committed User Label List: Error: %@", err); - } else { - NSLog(@"Verify committed User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"room")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"bedroom 1")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"orientation")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"South")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).label, @"floor")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).value, @"2")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).label, @"direction")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).value, @"down")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearUserLabelList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear User Label List: Error: %@", err); - } else { - NSLog(@"Clear User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadUserLabelList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read User Label List: Error: %@", err); - } else { - NSLog(@"Read User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteUserLabelList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 2"; - - temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"orientation"; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"North"; - - temp_0[2] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).label = @"floor"; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).value = @"5"; - - temp_0[3] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).label = @"direction"; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).value = @"up"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write User Label List: Error: %@", err); - } else { - NSLog(@"Write User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootTargetDevice_6() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestVerifyUserLabelListAfterReboot_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify User Label List after reboot: Error: %@", err); - } else { - NSLog(@"Verify User Label List after reboot: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"room")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"bedroom 2")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"orientation")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"North")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).label, @"floor")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).value, @"5")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).label, @"direction")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).value, @"up")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestUserLabelClusterConstraints : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestUserLabelClusterConstraints() - : TestCommandBridge("TestUserLabelClusterConstraints") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestUserLabelClusterConstraints() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestUserLabelClusterConstraints\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestUserLabelClusterConstraints\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Attempt to write overly long item for label\n"); - err = TestAttemptToWriteOverlyLongItemForLabel_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Attempt to write overly long item for value\n"); - err = TestAttemptToWriteOverlyLongItemForValue_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestAttemptToWriteOverlyLongItemForLabel_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"this is longer than sixteen characters"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 2"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Attempt to write overly long item for label: Error: %@", err); - } else { - NSLog(@"Attempt to write overly long item for label: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAttemptToWriteOverlyLongItemForValue_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"test"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"this is longer than sixteen characters"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Attempt to write overly long item for value: Error: %@", err); - } else { - NSLog(@"Attempt to write overly long item for value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestArmFailSafe : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestArmFailSafe() - : TestCommandBridge("TestArmFailSafe") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestArmFailSafe() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestArmFailSafe\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestArmFailSafe\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Reboot target device\n"); - err = TestRebootTargetDevice_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Wait for the alpha device to be retrieved \n"); - err = TestWaitForTheAlphaDeviceToBeRetrieved_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Query fabrics list\n"); - err = TestQueryFabricsList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : ArmFailSafe on target device with timeout 0\n"); - err = TestArmFailSafeOnTargetDeviceWithTimeout0_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Reads NodeLabel mandatory attribute of target device\n"); - err = TestReadsNodeLabelMandatoryAttributeOfTargetDevice_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Invoke AddTrustedRootCertificate without fail-safe\n"); - err = TestInvokeAddTrustedRootCertificateWithoutFailSafe_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Invoke AddNOC without fail-safe\n"); - err = TestInvokeAddNOCWithoutFailSafe_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Invoke UpdateNOC without fail-safe\n"); - err = TestInvokeUpdateNOCWithoutFailSafe_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Invoke CSRRequest without fail-safe\n"); - err = TestInvokeCSRRequestWithoutFailSafe_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestRebootTargetDevice_0() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestWaitForTheAlphaDeviceToBeRetrieved_1() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestQueryFabricsList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Query fabrics list: Error: %@", err); - } else { - NSLog(@"Query fabrics list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("NodeID", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).nodeID, mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL)); - VerifyOrReturn(CheckValueAsString("Label", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).label, @"")); - } - - VerifyOrReturn(CheckConstraintType("fabrics", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestArmFailSafeOnTargetDeviceWithTimeout0_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:0U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"ArmFailSafe on target device with timeout 0: Error: %@", err); - } else { - NSLog(@"ArmFailSafe on target device with timeout 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadsNodeLabelMandatoryAttributeOfTargetDevice_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reads NodeLabel mandatory attribute of target device: Error: %@", err); - } else { - NSLog(@"Reads NodeLabel mandatory attribute of target device: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("NodeLabel", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestInvokeAddTrustedRootCertificateWithoutFailSafe_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterAddTrustedRootCertificateParams alloc] init]; - params.rootCACertificate = - [[NSData alloc] initWithBytes:"00000000" length:8]; - [cluster addTrustedRootCertificateWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Invoke AddTrustedRootCertificate without fail-safe: Error: %@", err); - } else { - NSLog(@"Invoke AddTrustedRootCertificate without fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestInvokeAddNOCWithoutFailSafe_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterAddNOCParams alloc] init]; - params.nocValue = - [[NSData alloc] initWithBytes:"00112233" length:8]; - params.ipkValue = - [[NSData alloc] initWithBytes:"\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007" length:16]; - params.caseAdminSubject = - [NSNumber numberWithUnsignedLongLong:1234ULL]; - params.adminVendorId = - [NSNumber numberWithUnsignedShort:65521U]; - [cluster addNOCWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Invoke AddNOC without fail-safe: Error: %@", err); - } else { - NSLog(@"Invoke AddNOC without fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestInvokeUpdateNOCWithoutFailSafe_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateNOCParams alloc] init]; - params.nocValue = - [[NSData alloc] initWithBytes:"00112233" length:8]; - [cluster updateNOCWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Invoke UpdateNOC without fail-safe: Error: %@", err); - } else { - NSLog(@"Invoke UpdateNOC without fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestInvokeCSRRequestWithoutFailSafe_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterCSRRequestParams alloc] init]; - params.csrNonce = - [[NSData alloc] initWithBytes:"\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007" length:32]; - [cluster CSRRequestWithParams:params completion: - ^(MTROperationalCredentialsClusterCSRResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Invoke CSRRequest without fail-safe: Error: %@", err); - } else { - NSLog(@"Invoke CSRRequest without fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestFanControl : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestFanControl() - : TestCommandBridge("TestFanControl") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestFanControl() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestFanControl\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestFanControl\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write fan mode\n"); - err = TestWriteFanMode_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read back fan mode\n"); - err = TestReadBackFanMode_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Write percent setting\n"); - err = TestWritePercentSetting_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read back percent setting\n"); - err = TestReadBackPercentSetting_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read back speed current\n"); - err = TestReadBackSpeedCurrent_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write percent setting\n"); - err = TestWritePercentSetting_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read back percent setting\n"); - err = TestReadBackPercentSetting_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Write speed setting\n"); - err = TestWriteSpeedSetting_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read back percent setting\n"); - err = TestReadBackPercentSetting_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read back percent current\n"); - err = TestReadBackPercentCurrent_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Write speed setting\n"); - err = TestWriteSpeedSetting_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Write fan mode\n"); - err = TestWriteFanMode_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read back percent setting\n"); - err = TestReadBackPercentSetting_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read back percent current\n"); - err = TestReadBackPercentCurrent_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read back speed current\n"); - err = TestReadBackSpeedCurrent_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Write fan mode\n"); - err = TestWriteFanMode_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read back percent setting\n"); - err = TestReadBackPercentSetting_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteFanMode_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id fanModeArgument; - fanModeArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write fan mode: Error: %@", err); - } else { - NSLog(@"Write fan mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackFanMode_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFanModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back fan mode: Error: %@", err); - } else { - NSLog(@"Read back fan mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FanMode", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWritePercentSetting_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id percentSettingArgument; - percentSettingArgument = - [NSNumber numberWithUnsignedChar:84U]; - [cluster writeAttributePercentSettingWithValue:percentSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write percent setting: Error: %@", err); - } else { - NSLog(@"Write percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); - VerifyOrReturn(CheckValue("PercentSetting", actualValue, 84U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); - VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 84U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedCurrent_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed current: Error: %@", err); - } else { - NSLog(@"Read back speed current: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SpeedCurrent", actualValue, 84U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWritePercentSetting_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id percentSettingArgument; - percentSettingArgument = nil; - [cluster writeAttributePercentSettingWithValue:percentSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write percent setting: Error: %@", err); - } else { - NSLog(@"Write percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); - VerifyOrReturn(CheckValue("PercentSetting", actualValue, 84U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteSpeedSetting_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id speedSettingArgument; - speedSettingArgument = - [NSNumber numberWithUnsignedChar:73U]; - [cluster writeAttributeSpeedSettingWithValue:speedSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write speed setting: Error: %@", err); - } else { - NSLog(@"Write speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); - VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 73U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); - VerifyOrReturn(CheckValue("PercentSetting", actualValue, 73U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentCurrent_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent current: Error: %@", err); - } else { - NSLog(@"Read back percent current: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PercentCurrent", actualValue, 73U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteSpeedSetting_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id speedSettingArgument; - speedSettingArgument = nil; - [cluster writeAttributeSpeedSettingWithValue:speedSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write speed setting: Error: %@", err); - } else { - NSLog(@"Write speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); - VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 73U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteFanMode_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id fanModeArgument; - fanModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write fan mode: Error: %@", err); - } else { - NSLog(@"Write fan mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); - VerifyOrReturn(CheckValue("PercentSetting", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentCurrent_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent current: Error: %@", err); - } else { - NSLog(@"Read back percent current: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PercentCurrent", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); - VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedCurrent_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed current: Error: %@", err); - } else { - NSLog(@"Read back speed current: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SpeedCurrent", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteFanMode_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id fanModeArgument; - fanModeArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write fan mode: Error: %@", err); - } else { - NSLog(@"Write fan mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("PercentSetting", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("SpeedSetting", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestAccessControlConstraints : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestAccessControlConstraints() - : TestCommandBridge("TestAccessControlConstraints") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestAccessControlConstraints() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestAccessControlConstraints\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestAccessControlConstraints\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read the commissioner node ID from the alpha fabric\n"); - err = TestReadTheCommissionerNodeIdFromTheAlphaFabric_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Constraint error: PASE reserved for future (TC-ACL-2.4 step 29)\n"); - err = TestConstraintErrorPaseReservedForFutureTcAcl24Step29_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Constraint error: Invalid combination administer + group (TC-ACL-2.4 step 31)\n"); - err = TestConstraintErrorInvalidCombinationAdministerGroupTcAcl24Step31_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Constraint error: Invalid auth mode (TC-ACL-2.4 step 33)\n"); - err = TestConstraintErrorInvalidAuthModeTcAcl24Step33_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Constraint error: Invalid subject (TC-ACL-2.4 step 34)\n"); - err = TestConstraintErrorInvalidSubjectTcAcl24Step34_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Constraint error: Invalid target (TC-ACL-2.4 step 38)\n"); - err = TestConstraintErrorInvalidTargetTcAcl24Step38_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Constraint error: target has both endpoint and device type (TC-ACL-2.4 step 42)\n"); - err = TestConstraintErrorTargetHasBothEndpointAndDeviceTypeTcAcl24Step42_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Constraint error: Invalid privilege value step 32)\n"); - err = TestConstraintErrorInvalidPrivilegeValueStep32_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Constraint error: invalid subject 0xFFFF_FFFF_FFFF_FFFF (TC-ACL-2.4 step 35)\n"); - err = TestConstraintErrorInvalidSubject0xFFFFFfffFfffFfffTcAcl24Step35_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Constraint error: invalid subject 0xFFFF_FFFD_0000_0000 (TC-ACL-2.4 step 36)\n"); - err = TestConstraintErrorInvalidSubject0xFFFFFffd00000000TcAcl24Step36_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Constraint error: invalid subject 0xFFFF_FFFF_FFFF_0000 (TC-ACL-2.4 step 37)\n"); - err = TestConstraintErrorInvalidSubject0xFFFFFfffFfff0000TcAcl24Step37_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull commissionerNodeIdAlpha; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheAlphaFabric_1() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdAlpha = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestConstraintErrorPaseReservedForFutureTcAcl24Step29_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:1U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: PASE reserved for future (TC-ACL-2.4 step 29): Error: %@", err); - } else { - NSLog(@"Constraint error: PASE reserved for future (TC-ACL-2.4 step 29): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidCombinationAdministerGroupTcAcl24Step31_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:3U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid combination administer + group (TC-ACL-2.4 step 31): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid combination administer + group (TC-ACL-2.4 step 31): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidAuthModeTcAcl24Step33_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:4U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid auth mode (TC-ACL-2.4 step 33): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid auth mode (TC-ACL-2.4 step 33): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidSubjectTcAcl24Step34_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid subject (TC-ACL-2.4 step 34): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid subject (TC-ACL-2.4 step 34): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidTargetTcAcl24Step38_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid target (TC-ACL-2.4 step 38): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid target (TC-ACL-2.4 step 38): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorTargetHasBothEndpointAndDeviceTypeTcAcl24Step42_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:22U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = - [NSNumber numberWithUnsignedInt:33UL]; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: target has both endpoint and device type (TC-ACL-2.4 step 42): Error: %@", err); - } else { - NSLog(@"Constraint error: target has both endpoint and device type (TC-ACL-2.4 step 42): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidPrivilegeValueStep32_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:6U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid privilege value step 32): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid privilege value step 32): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFfffFfffFfffTcAcl24Step35_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_FFFF (TC-ACL-2.4 step 35): Error: %@", err); - } else { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_FFFF (TC-ACL-2.4 step 35): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFffd00000000TcAcl24Step36_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:18446744060824649728ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFD_0000_0000 (TC-ACL-2.4 step 36): Error: %@", err); - } else { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFD_0000_0000 (TC-ACL-2.4 step 36): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFfffFfff0000TcAcl24Step37_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:18446744073709486080ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_0000 (TC-ACL-2.4 step 37): Error: %@", err); - } else { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_0000 (TC-ACL-2.4 step 37): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestLevelControlWithOnOffDependency : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestLevelControlWithOnOffDependency() - : TestCommandBridge("TestLevelControlWithOnOffDependency") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestLevelControlWithOnOffDependency() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestLevelControlWithOnOffDependency\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestLevelControlWithOnOffDependency\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Sends a MoveToLevel command to set CurrentLevel to min value\n"); - err = TestSendsAMoveToLevelCommandToSetCurrentLevelToMinValue_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Wait 100 ms\n"); - err = TestWait100Ms_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Reads CurrentLevel attribute from DUT\n"); - err = TestReadsCurrentLevelAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Write OnOffTransitionTime attribute\n"); - err = TestWriteOnOffTransitionTimeAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 100 ms\n"); - err = TestWait100Ms_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read OnOffTransitionTime attribute\n"); - err = TestReadOnOffTransitionTimeAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write OnLevel attribute\n"); - err = TestWriteOnLevelAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 100 ms\n"); - err = TestWait100Ms_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read OnLevel attribute\n"); - err = TestReadOnLevelAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read MinValue attribute\n"); - err = TestReadMinValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Send On Command\n"); - err = TestSendOnCommand_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Check on/off attribute value is true after on command\n"); - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait OnOffTransitionTime\n"); - err = TestWaitOnOffTransitionTime_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : If OnLevel is defined, check CurrentLevel is OnLevel value\n"); - err = TestIfOnLevelIsDefinedCheckCurrentLevelIsOnLevelValue_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Send Off Command\n"); - err = TestSendOffCommand_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Check on/off attribute value is false after off command\n"); - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait OnOffTransitionTime\n"); - err = TestWaitOnOffTransitionTime_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : If OnLevel is defined, check CurrentLevel is min value\n"); - err = TestIfOnLevelIsDefinedCheckCurrentLevelIsMinValue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Sends a MoveToLevel command to set CurrentLevel to a mid value\n"); - err = TestSendsAMoveToLevelCommandToSetCurrentLevelToAMidValue_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 100 ms\n"); - err = TestWait100Ms_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Reads CurrentLevel attribute from DUT\n"); - err = TestReadsCurrentLevelAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Set OnLevel attribute to null\n"); - err = TestSetOnLevelAttributeToNull_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Wait 100 ms\n"); - err = TestWait100Ms_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Read OnLevel attribute\n"); - err = TestReadOnLevelAttribute_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Send On Command\n"); - err = TestSendOnCommand_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Check on/off attribute value is true after on command\n"); - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Wait OnOffTransitionTime\n"); - err = TestWaitOnOffTransitionTime_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : If OnLevel is not defined, check CurrentLevel is restored\n"); - err = TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Send Off Command\n"); - err = TestSendOffCommand_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Wait OnOffTransitionTime\n"); - err = TestWaitOnOffTransitionTime_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : If OnLevel is not defined, check CurrentLevel is restored\n"); - err = TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_32(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 33; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendsAMoveToLevelCommandToSetCurrentLevelToMinValue_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Sends a MoveToLevel command to set CurrentLevel to min value: Error: %@", err); - } else { - NSLog(@"Sends a MoveToLevel command to set CurrentLevel to min value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadsCurrentLevelAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteOnOffTransitionTimeAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Write OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadOnOffTransitionTimeAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Read OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOffTransitionTime", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteOnLevelAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onLevelArgument; - onLevelArgument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write OnLevel attribute: Error: %@", err); - } else { - NSLog(@"Write OnLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadOnLevelAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read OnLevel attribute: Error: %@", err); - } else { - NSLog(@"Read OnLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OnLevel", actualValue)); - VerifyOrReturn(CheckValue("OnLevel", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMinValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read MinValue attribute: Error: %@", err); - } else { - NSLog(@"Read MinValue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("MinLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendOnCommand_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send On Command: Error: %@", err); - } else { - NSLog(@"Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitOnOffTransitionTime_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestIfOnLevelIsDefinedCheckCurrentLevelIsOnLevelValue_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"If OnLevel is defined, check CurrentLevel is OnLevel value: Error: %@", err); - } else { - NSLog(@"If OnLevel is defined, check CurrentLevel is OnLevel value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendOffCommand_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Off Command: Error: %@", err); - } else { - NSLog(@"Send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitOnOffTransitionTime_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 0UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestIfOnLevelIsDefinedCheckCurrentLevelIsMinValue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"If OnLevel is defined, check CurrentLevel is min value: Error: %@", err); - } else { - NSLog(@"If OnLevel is defined, check CurrentLevel is min value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendsAMoveToLevelCommandToSetCurrentLevelToAMidValue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:127U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Sends a MoveToLevel command to set CurrentLevel to a mid value: Error: %@", err); - } else { - NSLog(@"Sends a MoveToLevel command to set CurrentLevel to a mid value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadsCurrentLevelAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 127U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetOnLevelAttributeToNull_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onLevelArgument; - onLevelArgument = nil; - [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set OnLevel attribute to null: Error: %@", err); - } else { - NSLog(@"Set OnLevel attribute to null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_23() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadOnLevelAttribute_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read OnLevel attribute: Error: %@", err); - } else { - NSLog(@"Read OnLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("OnLevel", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendOnCommand_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send On Command: Error: %@", err); - } else { - NSLog(@"Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitOnOffTransitionTime_27() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Error: %@", err); - } else { - NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 127U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendOffCommand_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Off Command: Error: %@", err); - } else { - NSLog(@"Send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitOnOffTransitionTime_31() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 0UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Error: %@", err); - } else { - NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 127U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestCommissioningWindow : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestCommissioningWindow() - : TestCommandBridge("TestCommissioningWindow") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("nodeId2", 0, UINT64_MAX, &mNodeId2); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("cluster", &mCluster); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestCommissioningWindow() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestCommissioningWindow\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestCommissioningWindow\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Get alpha's fabric index\n"); - err = TestGetAlphasFabricIndex_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Check that commissioning window is not open\n"); - err = TestCheckThatCommissioningWindowIsNotOpen_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Check that there is no AdminFabricIndex\n"); - err = TestCheckThatThereIsNoAdminFabricIndex_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Check that there is no AdminVendorId\n"); - err = TestCheckThatThereIsNoAdminVendorId_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Check that commissioning window is open\n"); - err = TestCheckThatCommissioningWindowIsOpen_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Check the AdminFabricIndex\n"); - err = TestCheckTheAdminFabricIndex_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Check the AdminVendorId is not null\n"); - err = TestCheckTheAdminVendorIdIsNotNull_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Close Commissioning Window\n"); - err = TestCloseCommissioningWindow_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Check that commissioning window is again not open\n"); - err = TestCheckThatCommissioningWindowIsAgainNotOpen_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Check that again there is no AdminFabricIndex\n"); - err = TestCheckThatAgainThereIsNoAdminFabricIndex_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Check that again there is no AdminVendorId\n"); - err = TestCheckThatAgainThereIsNoAdminVendorId_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Open Commissioning Window from alpha again\n"); - err = TestOpenCommissioningWindowFromAlphaAgain_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Commission from beta\n"); - err = TestCommissionFromBeta_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Check that commissioning window is not open for the third time\n"); - err = TestCheckThatCommissioningWindowIsNotOpenForTheThirdTime_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Check that there is no AdminFabricIndex for the third time\n"); - err = TestCheckThatThereIsNoAdminFabricIndexForTheThirdTime_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Check that there is no AdminVendorId for the third time\n"); - err = TestCheckThatThereIsNoAdminVendorIdForTheThirdTime_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Get beta's fabric index\n"); - err = TestGetBetasFabricIndex_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Open Commissioning Window from beta\n"); - err = TestOpenCommissioningWindowFromBeta_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Check that commissioning window is open again\n"); - err = TestCheckThatCommissioningWindowIsOpenAgain_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Check the AdminFabricIndex again\n"); - err = TestCheckTheAdminFabricIndexAgain_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Check the AdminVendorId is not null again\n"); - err = TestCheckTheAdminVendorIdIsNotNullAgain_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Remove beta fabric\n"); - err = TestRemoveBetaFabric_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Check that commissioning window is still open\n"); - err = TestCheckThatCommissioningWindowIsStillOpen_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Check the AdminFabricIndex got reset\n"); - err = TestCheckTheAdminFabricIndexGotReset_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Check the AdminVendorId did not get reset\n"); - err = TestCheckTheAdminVendorIdDidNotGetReset_27(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 28; - - chip::Optional mNodeId; - chip::Optional mNodeId2; - chip::Optional mEndpoint; - chip::Optional mCluster; - chip::Optional mDiscriminator; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull alphaIndex; - - CHIP_ERROR TestGetAlphasFabricIndex_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get alpha's fabric index: Error: %@", err); - } else { - NSLog(@"Get alpha's fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - alphaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsNotOpen_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is not open: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is not open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatThereIsNoAdminFabricIndex_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that there is no AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check that there is no AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatThereIsNoAdminVendorId_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that there is no AdminVendorId: Error: %@", err); - } else { - NSLog(@"Check that there is no AdminVendorId: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsOpen_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is open: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminFabricIndex_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check the AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (alphaIndex == nil) { - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("AdminFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("AdminFabricIndex", actualValue, alphaIndex)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminVendorIdIsNotNull_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminVendorId is not null: Error: %@", err); - } else { - NSLog(@"Check the AdminVendorId is not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckValueNonNull("adminVendorId", value)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseCommissioningWindow_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close Commissioning Window: Error: %@", err); - } else { - NSLog(@"Close Commissioning Window: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsAgainNotOpen_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is again not open: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is again not open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatAgainThereIsNoAdminFabricIndex_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that again there is no AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check that again there is no AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatAgainThereIsNoAdminVendorId_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that again there is no AdminVendorId: Error: %@", err); - } else { - NSLog(@"Check that again there is no AdminVendorId: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlphaAgain_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha again: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_14() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - return WaitForCommissionee("beta", value); - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsNotOpenForTheThirdTime_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is not open for the third time: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is not open for the third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatThereIsNoAdminFabricIndexForTheThirdTime_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that there is no AdminFabricIndex for the third time: Error: %@", err); - } else { - NSLog(@"Check that there is no AdminFabricIndex for the third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatThereIsNoAdminVendorIdForTheThirdTime_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that there is no AdminVendorId for the third time: Error: %@", err); - } else { - NSLog(@"Check that there is no AdminVendorId for the third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull betaIndex; - - CHIP_ERROR TestGetBetasFabricIndex_19() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get beta's fabric index: Error: %@", err); - } else { - NSLog(@"Get beta's fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - betaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromBeta_20() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from beta: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsOpenAgain_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is open again: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is open again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminFabricIndexAgain_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminFabricIndex again: Error: %@", err); - } else { - NSLog(@"Check the AdminFabricIndex again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (betaIndex == nil) { - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("AdminFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("AdminFabricIndex", actualValue, betaIndex)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable adminVendorId; - - CHIP_ERROR TestCheckTheAdminVendorIdIsNotNullAgain_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminVendorId is not null again: Error: %@", err); - } else { - NSLog(@"Check the AdminVendorId is not null again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckValueNonNull("adminVendorId", value)); - { - adminVendorId = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveBetaFabric_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [betaIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove beta fabric: Error: %@", err); - } else { - NSLog(@"Remove beta fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsStillOpen_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is still open: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is still open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminFabricIndexGotReset_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminFabricIndex got reset: Error: %@", err); - } else { - NSLog(@"Check the AdminFabricIndex got reset: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminVendorIdDidNotGetReset_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminVendorId did not get reset: Error: %@", err); - } else { - NSLog(@"Check the AdminVendorId did not get reset: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (adminVendorId == nil) { - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("AdminVendorId", actualValue)); - VerifyOrReturn(CheckValue("AdminVendorId", actualValue, adminVendorId)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestCommissionerNodeId : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestCommissionerNodeId() - : TestCommandBridge("TestCommissionerNodeId") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("cluster", &mCluster); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestCommissionerNodeId() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestCommissionerNodeId\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestCommissionerNodeId\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Commission from beta\n"); - err = TestCommissionFromBeta_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Commission from gamma\n"); - err = TestCommissionFromGamma_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait for the commissioned device to be retrieved for gamma\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read the fabric ID from the alpha fabric\n"); - err = TestReadTheFabricIdFromTheAlphaFabric_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read the commissioner node ID from the alpha fabric\n"); - err = TestReadTheCommissionerNodeIdFromTheAlphaFabric_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read the fabric ID from the beta fabric\n"); - err = TestReadTheFabricIdFromTheBetaFabric_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read the commissioner node ID from the beta fabric\n"); - err = TestReadTheCommissionerNodeIdFromTheBetaFabric_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read the fabric ID from the gamma fabric\n"); - err = TestReadTheFabricIdFromTheGammaFabric_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read the commissioner node ID from the gamma fabric\n"); - err = TestReadTheCommissionerNodeIdFromTheGammaFabric_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read the ACL from alpha and check commissioner node id\n"); - err = TestReadTheAclFromAlphaAndCheckCommissionerNodeId_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read the ACL from beta and check commissioner node id\n"); - err = TestReadTheAclFromBetaAndCheckCommissionerNodeId_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read the ACL from gamma and check commissioner node id\n"); - err = TestReadTheAclFromGammaAndCheckCommissionerNodeId_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Write the ACL using the commissioner node id value\n"); - err = TestWriteTheAclUsingTheCommissionerNodeIdValue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Write the ACL using the commissioner node id value\n"); - err = TestWriteTheAclUsingTheCommissionerNodeIdValue_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read the ACL from beta and check commissioner node id\n"); - err = TestReadTheAclFromBetaAndCheckCommissionerNodeId_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read the ACL from gamma and check commissioner node id\n"); - err = TestReadTheAclFromGammaAndCheckCommissionerNodeId_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Remove beta fabric\n"); - err = TestRemoveBetaFabric_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Remove gamma fabric\n"); - err = TestRemoveGammaFabric_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mEndpoint; - chip::Optional mCluster; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_2() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("beta", value); - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromGamma_5() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("gamma", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("gamma", value); - } - NSNumber * _Nonnull alphaIndex; - - CHIP_ERROR TestReadTheFabricIdFromTheAlphaFabric_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the fabric ID from the alpha fabric: Error: %@", err); - } else { - NSLog(@"Read the fabric ID from the alpha fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - alphaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull commissionerNodeIdAlpha; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheAlphaFabric_8() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdAlpha = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - NSNumber * _Nonnull betaIndex; - - CHIP_ERROR TestReadTheFabricIdFromTheBetaFabric_9() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the fabric ID from the beta fabric: Error: %@", err); - } else { - NSLog(@"Read the fabric ID from the beta fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - betaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull commissionerNodeIdBeta; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheBetaFabric_10() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("beta", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdBeta = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - NSNumber * _Nonnull gammaIndex; - - CHIP_ERROR TestReadTheFabricIdFromTheGammaFabric_11() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the fabric ID from the gamma fabric: Error: %@", err); - } else { - NSLog(@"Read the fabric ID from the gamma fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - gammaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull commissionerNodeIdGamma; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheGammaFabric_12() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("gamma", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdGamma = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestReadTheAclFromAlphaAndCheckCommissionerNodeId_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from alpha and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from alpha and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdAlpha)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, alphaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheAclFromBetaAndCheckCommissionerNodeId_14() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from beta and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from beta and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdBeta)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, betaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheAclFromGammaAndCheckCommissionerNodeId_15() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from gamma and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from gamma and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdGamma)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, gammaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTheAclUsingTheCommissionerNodeIdValue_16() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdBeta copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [betaIndex copy]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write the ACL using the commissioner node id value: Error: %@", err); - } else { - NSLog(@"Write the ACL using the commissioner node id value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTheAclUsingTheCommissionerNodeIdValue_17() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdGamma copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [gammaIndex copy]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write the ACL using the commissioner node id value: Error: %@", err); - } else { - NSLog(@"Write the ACL using the commissioner node id value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheAclFromBetaAndCheckCommissionerNodeId_18() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from beta and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from beta and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdBeta)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, betaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheAclFromGammaAndCheckCommissionerNodeId_19() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from gamma and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from gamma and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdGamma)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, gammaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveBetaFabric_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [betaIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove beta fabric: Error: %@", err); - } else { - NSLog(@"Remove beta fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveGammaFabric_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [gammaIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove gamma fabric: Error: %@", err); - } else { - NSLog(@"Remove gamma fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestTimeSynchronization : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestTimeSynchronization() - : TestCommandBridge("TestTimeSynchronization") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestTimeSynchronization() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestTimeSynchronization\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestTimeSynchronization\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Time Zone\n"); - err = TestReadTimeZone_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Set Time Zone list\n"); - err = TestSetTimeZoneList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read Time Zone\n"); - err = TestReadTimeZone_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Set Time Zone with missing optional name field\n"); - err = TestSetTimeZoneWithMissingOptionalNameField_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read Time Zone\n"); - err = TestReadTimeZone_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Set Time Zone with very long name\n"); - err = TestSetTimeZoneWithVeryLongName_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Set Time Zone with first item validAt not zero\n"); - err = TestSetTimeZoneWithFirstItemValidAtNotZero_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Set Time Zone with second item validAt zero\n"); - err = TestSetTimeZoneWithSecondItemValidAtZero_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Set Time Zone with more than supported list count\n"); - err = TestSetTimeZoneWithMoreThanSupportedListCount_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Set Time Zone empty\n"); - err = TestSetTimeZoneEmpty_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read Time Zone\n"); - err = TestReadTimeZone_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read DSTOffset\n"); - err = TestReadDSTOffset_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Set DSTOffset single item\n"); - err = TestSetDSTOffsetSingleItem_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Set DSTOffset empty\n"); - err = TestSetDSTOffsetEmpty_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Set DSTOffset with more than 1 null value\n"); - err = TestSetDSTOffsetWithMoreThan1NullValue_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Set unsorted DSTOffset entries\n"); - err = TestSetUnsortedDSTOffsetEntries_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Set DSTOffset with multiple entries\n"); - err = TestSetDSTOffsetWithMultipleEntries_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read DSTOffset\n"); - err = TestReadDSTOffset_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Set DSTOffset with same validStarting and validUntil\n"); - err = TestSetDSTOffsetWithSameValidStartingAndValidUntil_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Set DSTOffset with more than supported list count\n"); - err = TestSetDSTOffsetWithMoreThanSupportedListCount_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadTimeZone_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Time Zone: Error: %@", err); - } else { - NSLog(@"Read Time Zone: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 0L)); - VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CET"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone list: Error: %@", err); - } else { - NSLog(@"Set Time Zone list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.dstOffsetRequired; - VerifyOrReturn(CheckValue("DSTOffsetRequired", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTimeZone_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Time Zone: Error: %@", err); - } else { - NSLog(@"Read Time Zone: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 100L)); - VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).name, @"CET")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithMissingOptionalNameField_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with missing optional name field: Error: %@", err); - } else { - NSLog(@"Set Time Zone with missing optional name field: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.dstOffsetRequired; - VerifyOrReturn(CheckValue("DSTOffsetRequired", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTimeZone_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Time Zone: Error: %@", err); - } else { - NSLog(@"Read Time Zone: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 100L)); - VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithVeryLongName_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"MunichOnTheLongRiverOfIsarInNiceSummerWeatherWithAugustinerBeerss"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with very long name: Error: %@", err); - } else { - NSLog(@"Set Time Zone with very long name: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithFirstItemValidAtNotZero_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CDT"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with first item validAt not zero: Error: %@", err); - } else { - NSLog(@"Set Time Zone with first item validAt not zero: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithSecondItemValidAtZero_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CST"; - - temp_0[1] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:200L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).name = @"CDT"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with second item validAt zero: Error: %@", err); - } else { - NSLog(@"Set Time Zone with second item validAt zero: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithMoreThanSupportedListCount_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CST"; - - temp_0[1] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:200L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).validAt = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).name = @"CDT"; - - temp_0[2] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[2]).offset = - [NSNumber numberWithInt:200L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[2]).validAt = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[2]).name = @"CET"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with more than supported list count: Error: %@", err); - } else { - NSLog(@"Set Time Zone with more than supported list count: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneEmpty_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone empty: Error: %@", err); - } else { - NSLog(@"Set Time Zone empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.dstOffsetRequired; - VerifyOrReturn(CheckValue("DSTOffsetRequired", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTimeZone_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Time Zone: Error: %@", err); - } else { - NSLog(@"Read Time Zone: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 0L)); - VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadDSTOffset_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDSTOffsetWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read DSTOffset: Error: %@", err); - } else { - NSLog(@"Read DSTOffset: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DSTOffset", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetSingleItem_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:2ULL]; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset single item: Error: %@", err); - } else { - NSLog(@"Set DSTOffset single item: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetEmpty_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset empty: Error: %@", err); - } else { - NSLog(@"Set DSTOffset empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetWithMoreThan1NullValue_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = nil; - - temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = nil; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset with more than 1 null value: Error: %@", err); - } else { - NSLog(@"Set DSTOffset with more than 1 null value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetUnsortedDSTOffsetEntries_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:3ULL]; - - temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = nil; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set unsorted DSTOffset entries: Error: %@", err); - } else { - NSLog(@"Set unsorted DSTOffset entries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetWithMultipleEntries_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:2ULL]; - - temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = nil; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset with multiple entries: Error: %@", err); - } else { - NSLog(@"Set DSTOffset with multiple entries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadDSTOffset_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDSTOffsetWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read DSTOffset: Error: %@", err); - } else { - NSLog(@"Read DSTOffset: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DSTOffset", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).offset, 1L)); - VerifyOrReturn(CheckValue("ValidStarting", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).validStarting, 1ULL)); - VerifyOrReturn(CheckValueNonNull("ValidUntil", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).validUntil)); - VerifyOrReturn(CheckValue("ValidUntil", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).validUntil, 2ULL)); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[1]).offset, 0L)); - VerifyOrReturn(CheckValue("ValidStarting", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[1]).validStarting, 3ULL)); - VerifyOrReturn(CheckValueNull("ValidUntil", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[1]).validUntil)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetWithSameValidStartingAndValidUntil_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset with same validStarting and validUntil: Error: %@", err); - } else { - NSLog(@"Set DSTOffset with same validStarting and validUntil: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetWithMoreThanSupportedListCount_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:2ULL]; - - temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = - [NSNumber numberWithUnsignedLongLong:5ULL]; - - temp_0[2] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[2]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[2]).validStarting = - [NSNumber numberWithUnsignedLongLong:6ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[2]).validUntil = nil; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset with more than supported list count: Error: %@", err); - } else { - NSLog(@"Set DSTOffset with more than supported list count: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestOperationalState : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestOperationalState() - : TestCommandBridge("TestOperationalState") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestOperationalState() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestOperationalState\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestOperationalState\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Phase List\n"); - err = TestReadPhaseList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current Phase\n"); - err = TestReadCurrentPhase_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read Countdown Time\n"); - err = TestReadCountdownTime_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read Operational State List\n"); - err = TestReadOperationalStateList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read current Operational Error\n"); - err = TestReadCurrentOperationalError_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Start Command\n"); - err = TestStartCommand_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Pause Command\n"); - err = TestPauseCommand_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Resume Command\n"); - err = TestResumeCommand_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Stop Command\n"); - err = TestStopCommand_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadPhaseList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhaseListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Phase List: Error: %@", err); - } else { - NSLog(@"Read Phase List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("PhaseList", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentPhase_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPhaseWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Phase: Error: %@", err); - } else { - NSLog(@"Read current Phase: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CurrentPhase", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCountdownTime_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCountdownTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Countdown Time: Error: %@", err); - } else { - NSLog(@"Read Countdown Time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CountdownTime", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadOperationalStateList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Operational State List: Error: %@", err); - } else { - NSLog(@"Read Operational State List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStateList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[0]).operationalStateID, 0U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[1]).operationalStateID, 1U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[2]).operationalStateID, 2U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[3]).operationalStateID, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalError_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalErrorWithCompletion:^(MTROperationalStateClusterErrorStateStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational Error: Error: %@", err); - } else { - NSLog(@"Read current Operational Error: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStartCommand_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster startWithCompletion: - ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Start Command: Error: %@", err); - } else { - NSLog(@"Start Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPauseCommand_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Pause Command: Error: %@", err); - } else { - NSLog(@"Pause Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResumeCommand_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster resumeWithCompletion: - ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Resume Command: Error: %@", err); - } else { - NSLog(@"Resume Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStopCommand_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopWithCompletion: - ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Stop Command: Error: %@", err); - } else { - NSLog(@"Stop Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestRVCOperationalState : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestRVCOperationalState() - : TestCommandBridge("TestRVCOperationalState") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestRVCOperationalState() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestRVCOperationalState\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestRVCOperationalState\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Phase List\n"); - err = TestReadPhaseList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current Phase\n"); - err = TestReadCurrentPhase_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read Countdown Time\n"); - err = TestReadCountdownTime_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read Operational State List\n"); - err = TestReadOperationalStateList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read current Operational Error\n"); - err = TestReadCurrentOperationalError_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Pause Command\n"); - err = TestPauseCommand_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Resume Command\n"); - err = TestResumeCommand_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_12(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadPhaseList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhaseListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Phase List: Error: %@", err); - } else { - NSLog(@"Read Phase List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("PhaseList", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentPhase_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPhaseWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Phase: Error: %@", err); - } else { - NSLog(@"Read current Phase: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CurrentPhase", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCountdownTime_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCountdownTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Countdown Time: Error: %@", err); - } else { - NSLog(@"Read Countdown Time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CountdownTime", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadOperationalStateList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Operational State List: Error: %@", err); - } else { - NSLog(@"Read Operational State List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStateList", [actualValue count], static_cast(7))); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[0]).operationalStateID, 0U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[1]).operationalStateID, 1U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[2]).operationalStateID, 2U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[3]).operationalStateID, 3U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[4]).operationalStateID, 64U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[5]).operationalStateID, 65U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[6]).operationalStateID, 66U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalError_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalErrorWithCompletion:^(MTRRVCOperationalStateClusterErrorStateStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational Error: Error: %@", err); - } else { - NSLog(@"Read current Operational Error: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPauseCommand_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Pause Command: Error: %@", err); - } else { - NSLog(@"Pause Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResumeCommand_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster resumeWithCompletion: - ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Resume Command: Error: %@", err); - } else { - NSLog(@"Resume Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestDishwasherAlarm : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestDishwasherAlarm() - : TestCommandBridge("TestDishwasherAlarm") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestDishwasherAlarm() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestDishwasherAlarm\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestDishwasherAlarm\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Supported Attribute\n"); - err = TestReadSupportedAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read State Attribute\n"); - err = TestReadStateAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read feature map Attribute\n"); - err = TestReadFeatureMapAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Modify enabled alarms Command\n"); - err = TestModifyEnabledAlarmsCommand_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read State Attribute\n"); - err = TestReadStateAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Modify enabled alarms Command\n"); - err = TestModifyEnabledAlarmsCommand_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read State Attribute\n"); - err = TestReadStateAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Modify enabled alarms Command\n"); - err = TestModifyEnabledAlarmsCommand_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read State Attribute\n"); - err = TestReadStateAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Reset Command\n"); - err = TestResetCommand_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read State Attribute\n"); - err = TestReadStateAttribute_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadSupportedAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Supported Attribute: Error: %@", err); - } else { - NSLog(@"Read Supported Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Supported", actualValue, 47UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 47UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 7UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFeatureMapAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read feature map Attribute: Error: %@", err); - } else { - NSLog(@"Read feature map Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyEnabledAlarmsCommand_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDishwasherAlarmClusterModifyEnabledAlarmsParams alloc] init]; - params.mask = - [NSNumber numberWithUnsignedInt:41UL]; - [cluster modifyEnabledAlarmsWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify enabled alarms Command: Error: %@", err); - } else { - NSLog(@"Modify enabled alarms Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyEnabledAlarmsCommand_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDishwasherAlarmClusterModifyEnabledAlarmsParams alloc] init]; - params.mask = - [NSNumber numberWithUnsignedInt:105UL]; - [cluster modifyEnabledAlarmsWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify enabled alarms Command: Error: %@", err); - } else { - NSLog(@"Modify enabled alarms Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyEnabledAlarmsCommand_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDishwasherAlarmClusterModifyEnabledAlarmsParams alloc] init]; - params.mask = - [NSNumber numberWithUnsignedInt:59UL]; - [cluster modifyEnabledAlarmsWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify enabled alarms Command: Error: %@", err); - } else { - NSLog(@"Modify enabled alarms Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResetCommand_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDishwasherAlarmClusterResetParams alloc] init]; - params.alarms = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster resetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reset Command: Error: %@", err); - } else { - NSLog(@"Reset Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestMultiAdmin : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestMultiAdmin() - : TestCommandBridge("TestMultiAdmin") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("nodeIdForDuplicateCommissioning", 0, UINT64_MAX, &mNodeIdForDuplicateCommissioning); - AddArgument("nodeId2", 0, UINT64_MAX, &mNodeId2); - AddArgument("nodeId3", 0, UINT64_MAX, &mNodeId3); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestMultiAdmin() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestMultiAdmin\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestMultiAdmin\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Stop target device\n"); - err = TestStopTargetDevice_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Start target device with the provided discriminator for basic commissioning advertisement\n"); - err = TestStartTargetDeviceWithTheProvidedDiscriminatorForBasicCommissioningAdvertisement_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Wait for the commissioned device to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Commission from alpha when the commissioning window is not opened\n"); - err = TestCommissionFromAlphaWhenTheCommissioningWindowIsNotOpened_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Commission from alpha again\n"); - err = TestCommissionFromAlphaAgain_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Check that we just have the one fabric and did not add a new one\n"); - err = TestCheckThatWeJustHaveTheOneFabricAndDidNotAddANewOne_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Close Commissioning Window after failed commissioning\n"); - err = TestCloseCommissioningWindowAfterFailedCommissioning_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Open Commissioning Window from alpha again\n"); - err = TestOpenCommissioningWindowFromAlphaAgain_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Commission from beta\n"); - err = TestCommissionFromBeta_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Open Commissioning Window from beta\n"); - err = TestOpenCommissioningWindowFromBeta_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Commission from gamma\n"); - err = TestCommissionFromGamma_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for the commissioned device to be retrieved for gamma\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : read the mandatory attribute: NodeLabel from alpha\n"); - err = TestReadTheMandatoryAttributeNodeLabelFromAlpha_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : write the mandatory attribute NodeLabel from beta\n"); - err = TestWriteTheMandatoryAttributeNodeLabelFromBeta_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : read the mandatory attribute: NodeLabel from gamma\n"); - err = TestReadTheMandatoryAttributeNodeLabelFromGamma_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : write the mandatory attribute NodeLabel back to default\n"); - err = TestWriteTheMandatoryAttributeNodeLabelBackToDefault_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mNodeIdForDuplicateCommissioning; - chip::Optional mNodeId2; - chip::Optional mNodeId3; - chip::Optional mEndpoint; - chip::Optional mDiscriminator; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestStopTargetDevice_0() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTargetDeviceWithTheProvidedDiscriminatorForBasicCommissioningAdvertisement_1() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.discriminator.Emplace(); - value.discriminator.Value() = mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U; - return Start("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestCommissionFromAlphaWhenTheCommissioningWindowIsNotOpened_3() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeIdForDuplicateCommissioning.HasValue() ? mNodeIdForDuplicateCommissioning.Value() : 17ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromAlphaAgain_5() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeIdForDuplicateCommissioning.HasValue() ? mNodeIdForDuplicateCommissioning.Value() : 17ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestCheckThatWeJustHaveTheOneFabricAndDidNotAddANewOne_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = false; - [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that we just have the one fabric and did not add a new one: Error: %@", err); - } else { - NSLog(@"Check that we just have the one fabric and did not add a new one: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("NodeID", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).nodeID, mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseCommissioningWindowAfterFailedCommissioning_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close Commissioning Window after failed commissioning: Error: %@", err); - } else { - NSLog(@"Close Commissioning Window after failed commissioning: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlphaAgain_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha again: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_9() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - return WaitForCommissionee("beta", value); - } - - CHIP_ERROR TestOpenCommissioningWindowFromBeta_11() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from beta: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromGamma_12() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("gamma", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; - return WaitForCommissionee("gamma", value); - } - NSString * _Nonnull readFromAlpha; - - CHIP_ERROR TestReadTheMandatoryAttributeNodeLabelFromAlpha_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"read the mandatory attribute: NodeLabel from alpha: Error: %@", err); - } else { - NSLog(@"read the mandatory attribute: NodeLabel from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("NodeLabel", actualValue, @"")); - } - { - readFromAlpha = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTheMandatoryAttributeNodeLabelFromBeta_15() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"written from beta"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"write the mandatory attribute NodeLabel from beta: Error: %@", err); - } else { - NSLog(@"write the mandatory attribute NodeLabel from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheMandatoryAttributeNodeLabelFromGamma_16() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"read the mandatory attribute: NodeLabel from gamma: Error: %@", err); - } else { - NSLog(@"read the mandatory attribute: NodeLabel from gamma: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("nodeLabel", value, readFromAlpha)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTheMandatoryAttributeNodeLabelBackToDefault_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = - [readFromAlpha copy]; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"write the mandatory attribute NodeLabel back to default: Error: %@", err); - } else { - NSLog(@"write the mandatory attribute NodeLabel back to default: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGSW_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGSW_1_1() - : TestCommandBridge("Test_TC_DGSW_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGSW_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGSW_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGSW_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip(" !DGSW.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGSW.S.F00(Watermarks) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGSW.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDGSWSF00WatermarksEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads optional attribute(ThreadMetrics) in AttributeList\n"); - if (ShouldSkip("DGSW.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeThreadMetricsInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads optional attribute(CurrentHeapFree) in AttributeList\n"); - if (ShouldSkip("DGSW.S.A0001")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributeCurrentHeapFreeInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4d: TH reads optional attribute(CurrentHeapUsed) in AttributeList\n"); - if (ShouldSkip("DGSW.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeCurrentHeapUsedInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4e: TH reads Feature dependent attribute(CurrentHeapHighWatermark) in AttributeList\n"); - if (ShouldSkip("( DGSW.S.F00 || DGSW.S.A0003 )")) { - NextTest(); - return; - } - err = TestStep4eThReadsFeatureDependentAttributeCurrentHeapHighWatermarkInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip("DGSW.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5b: TH reads EventList from DUT\n"); - if (ShouldSkip(" !DGSW.S.E00 && PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - NextTest(); - return; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip("DGSW.S.F00")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip(" !DGSW.S.F00 ")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDGSWSF00WatermarksEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DGSW.S.F00(Watermarks) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DGSW.S.F00(Watermarks) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeThreadMetricsInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(ThreadMetrics) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(ThreadMetrics) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributeCurrentHeapFreeInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(CurrentHeapFree) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(CurrentHeapFree) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeCurrentHeapUsedInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(CurrentHeapUsed) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(CurrentHeapUsed) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsFeatureDependentAttributeCurrentHeapHighWatermarkInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads Feature dependent attribute(CurrentHeapHighWatermark) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads Feature dependent attribute(CurrentHeapHighWatermark) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestSubscribe_OnOff : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSubscribe_OnOff() - : TestCommandBridge("TestSubscribe_OnOff") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSubscribe_OnOff() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSubscribe_OnOff\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSubscribe_OnOff\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Set OnOff Attribute to false\n"); - err = TestSetOnOffAttributeToFalse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Report: Subscribe OnOff Attribute\n"); - err = TestReportSubscribeOnOffAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Subscribe OnOff Attribute\n"); - err = TestSubscribeOnOffAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Turn On the light to see attribute change\n"); - err = TestTurnOnTheLightToSeeAttributeChange_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Check for attribute report\n"); - err = TestCheckForAttributeReport_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Turn Off the light to see attribute change\n"); - err = TestTurnOffTheLightToSeeAttributeChange_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Check for attribute report\n"); - err = TestCheckForAttributeReport_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSetOnOffAttributeToFalse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set OnOff Attribute to false: Error: %@", err); - } else { - NSLog(@"Set OnOff Attribute to false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestSubscribe_OnOff_2_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestSubscribe_OnOff_OnOff_Reported - = nil; - - CHIP_ERROR TestReportSubscribeOnOffAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_OnOff_OnOff_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe OnOff Attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe OnOff Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, false)); - } - - testSendClusterTestSubscribe_OnOff_2_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeOnOffAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 5U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeOnOffWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestSubscribe_OnOff_2_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe OnOff Attribute: Error: %@", err); - } else { - NSLog(@"Subscribe OnOff Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestSubscribe_OnOff_OnOff_Reported - != nil) { - ResponseHandler callback = test_TestSubscribe_OnOff_OnOff_Reported; - test_TestSubscribe_OnOff_OnOff_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOnTheLightToSeeAttributeChange_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn On the light to see attribute change: Error: %@", err); - } else { - NSLog(@"Turn On the light to see attribute change: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForAttributeReport_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_OnOff_OnOff_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for attribute report: Error: %@", err); - } else { - NSLog(@"Check for attribute report: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, true)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffTheLightToSeeAttributeChange_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off the light to see attribute change: Error: %@", err); - } else { - NSLog(@"Turn Off the light to see attribute change: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForAttributeReport_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_OnOff_OnOff_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for attribute report: Error: %@", err); - } else { - NSLog(@"Check for attribute report: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, false)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } -}; - -class TestSubscribe_AdministratorCommissioning : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSubscribe_AdministratorCommissioning() - : TestCommandBridge("TestSubscribe_AdministratorCommissioning") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ourVendorId", 0, UINT16_MAX, &mOurVendorId); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSubscribe_AdministratorCommissioning() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSubscribe_AdministratorCommissioning\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSubscribe_AdministratorCommissioning\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Get ourfabric index\n"); - err = TestGetOurfabricIndex_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Report: Subscribe WindowStatus Attribute\n"); - err = TestReportSubscribeWindowStatusAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Subscribe WindowStatus Attribute\n"); - err = TestSubscribeWindowStatusAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Open the commissioning window 1\n"); - err = TestOpenTheCommissioningWindow1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Check for first attribute report for WindowStatus\n"); - err = TestCheckForFirstAttributeReportForWindowStatus_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Close the commissioning window 1\n"); - err = TestCloseTheCommissioningWindow1_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Check for second attribute report for WindowStatus\n"); - err = TestCheckForSecondAttributeReportForWindowStatus_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Report: Subscribe AdminVendorId Attribute\n"); - err = TestReportSubscribeAdminVendorIdAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Subscribe AdminVendorId Attribute\n"); - err = TestSubscribeAdminVendorIdAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Open the commissioning window 2\n"); - err = TestOpenTheCommissioningWindow2_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Check for first attribute report for AdminVendorId\n"); - err = TestCheckForFirstAttributeReportForAdminVendorId_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Close the commissioning window 2\n"); - err = TestCloseTheCommissioningWindow2_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Check for second attribute report for AdminVendorId\n"); - err = TestCheckForSecondAttributeReportForAdminVendorId_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Report: Subscribe AdminFabricIndex Attribute\n"); - err = TestReportSubscribeAdminFabricIndexAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Subscribe AdminFabricIndex Attribute\n"); - err = TestSubscribeAdminFabricIndexAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Open the commissioning window 3\n"); - err = TestOpenTheCommissioningWindow3_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Check for first attribute report for AdminFabricIndex\n"); - err = TestCheckForFirstAttributeReportForAdminFabricIndex_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Close the commissioning window 2\n"); - err = TestCloseTheCommissioningWindow2_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Check for second attribute report for AdminFabricIndex\n"); - err = TestCheckForSecondAttributeReportForAdminFabricIndex_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mOurVendorId; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull ourFabricIndex; - - CHIP_ERROR TestGetOurfabricIndex_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get ourfabric index: Error: %@", err); - } else { - NSLog(@"Get ourfabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ourFabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestSubscribe_AdministratorCommissioning_2_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = nil; - - CHIP_ERROR TestReportSubscribeWindowStatusAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe WindowStatus Attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe WindowStatus Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - testSendClusterTestSubscribe_AdministratorCommissioning_2_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeWindowStatusAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 50U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeWindowStatusWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestSubscribe_AdministratorCommissioning_2_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe WindowStatus Attribute: Error: %@", err); - } else { - NSLog(@"Subscribe WindowStatus Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - != nil) { - ResponseHandler callback = test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported; - test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenTheCommissioningWindow1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open the commissioning window 1: Error: %@", err); - } else { - NSLog(@"Open the commissioning window 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForFirstAttributeReportForWindowStatus_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for first attribute report for WindowStatus: Error: %@", err); - } else { - NSLog(@"Check for first attribute report for WindowStatus: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseTheCommissioningWindow1_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close the commissioning window 1: Error: %@", err); - } else { - NSLog(@"Close the commissioning window 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForSecondAttributeReportForWindowStatus_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for second attribute report for WindowStatus: Error: %@", err); - } else { - NSLog(@"Check for second attribute report for WindowStatus: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestSubscribe_AdministratorCommissioning_8_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = nil; - - CHIP_ERROR TestReportSubscribeAdminVendorIdAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe AdminVendorId Attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe AdminVendorId Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - testSendClusterTestSubscribe_AdministratorCommissioning_8_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeAdminVendorIdAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 50U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeAdminVendorIdWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestSubscribe_AdministratorCommissioning_8_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe AdminVendorId Attribute: Error: %@", err); - } else { - NSLog(@"Subscribe AdminVendorId Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - != nil) { - ResponseHandler callback = test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported; - test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenTheCommissioningWindow2_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open the commissioning window 2: Error: %@", err); - } else { - NSLog(@"Open the commissioning window 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForFirstAttributeReportForAdminVendorId_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for first attribute report for AdminVendorId: Error: %@", err); - } else { - NSLog(@"Check for first attribute report for AdminVendorId: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("AdminVendorId", actualValue)); - VerifyOrReturn(CheckValue("AdminVendorId", actualValue, mOurVendorId.HasValue() ? mOurVendorId.Value() : 65521U)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseTheCommissioningWindow2_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close the commissioning window 2: Error: %@", err); - } else { - NSLog(@"Close the commissioning window 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForSecondAttributeReportForAdminVendorId_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for second attribute report for AdminVendorId: Error: %@", err); - } else { - NSLog(@"Check for second attribute report for AdminVendorId: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestSubscribe_AdministratorCommissioning_14_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = nil; - - CHIP_ERROR TestReportSubscribeAdminFabricIndexAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe AdminFabricIndex Attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe AdminFabricIndex Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - testSendClusterTestSubscribe_AdministratorCommissioning_14_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeAdminFabricIndexAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 50U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeAdminFabricIndexWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestSubscribe_AdministratorCommissioning_14_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe AdminFabricIndex Attribute: Error: %@", err); - } else { - NSLog(@"Subscribe AdminFabricIndex Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - != nil) { - ResponseHandler callback = test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported; - test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenTheCommissioningWindow3_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open the commissioning window 3: Error: %@", err); - } else { - NSLog(@"Open the commissioning window 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForFirstAttributeReportForAdminFabricIndex_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for first attribute report for AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check for first attribute report for AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (ourFabricIndex == nil) { - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("AdminFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("AdminFabricIndex", actualValue, ourFabricIndex)); - } - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseTheCommissioningWindow2_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close the commissioning window 2: Error: %@", err); - } else { - NSLog(@"Close the commissioning window 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForSecondAttributeReportForAdminFabricIndex_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for second attribute report for AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check for second attribute report for AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } -}; - -class DL_UsersAndCredentials : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - DL_UsersAndCredentials() - : TestCommandBridge("DL_UsersAndCredentials") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~DL_UsersAndCredentials() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: DL_UsersAndCredentials\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: DL_UsersAndCredentials\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read available user slot and verify response fields\n"); - err = TestReadAvailableUserSlotAndVerifyResponseFields_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Get number of supported users and verify default value\n"); - err = TestGetNumberOfSupportedUsersAndVerifyDefaultValue_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read fails for user with index 0\n"); - err = TestReadFailsForUserWithIndex0_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read fails for user with index greater than Number Of Users Supported\n"); - err = TestReadFailsForUserWithIndexGreaterThanNumberOfUsersSupported_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Create new user with default parameters\n"); - err = TestCreateNewUserWithDefaultParameters_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read the user back and verify its fields\n"); - err = TestReadTheUserBackAndVerifyItsFields_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Set user at the occupied index fails with appropriate response\n"); - err = TestSetUserAtTheOccupiedIndexFailsWithAppropriateResponse_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Modify userName for existing user\n"); - err = TestModifyUserNameForExistingUser_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Modify userUniqueId for existing user\n"); - err = TestModifyUserUniqueIdForExistingUser_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Modify userStatus for existing user\n"); - err = TestModifyUserStatusForExistingUser_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Modify userType for existing user\n"); - err = TestModifyUserTypeForExistingUser_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Modify credentialRule for existing user\n"); - err = TestModifyCredentialRuleForExistingUser_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Modify all fields for existing user\n"); - err = TestModifyAllFieldsForExistingUser_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Add another user with non-default fields\n"); - err = TestAddAnotherUserWithNonDefaultFields_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read the new user back and verify its fields\n"); - err = TestReadTheNewUserBackAndVerifyItsFields_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Try to add a user with userStatus 0\n"); - err = TestTryToAddAUserWithUserStatus0_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Make sure the user did not get created\n"); - err = TestMakeSureTheUserDidNotGetCreated_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Try to add a user with userStatus 2\n"); - err = TestTryToAddAUserWithUserStatus2_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Make sure the user did not get created\n"); - err = TestMakeSureTheUserDidNotGetCreated_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Try to add a user with userStatus 3\n"); - err = TestTryToAddAUserWithUserStatus3_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Read the new third user back and verify its fields\n"); - err = TestReadTheNewThirdUserBackAndVerifyItsFields_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Create user in the last slot\n"); - err = TestCreateUserInTheLastSlot_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Read the last user back and verify its fields\n"); - err = TestReadTheLastUserBackAndVerifyItsFields_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : User creation in the 0 slot fails\n"); - err = TestUserCreationInThe0SlotFails_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : User creation in the out-of-bounds slot fails\n"); - err = TestUserCreationInTheOutOfBoundsSlotFails_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Clear first user\n"); - err = TestClearFirstUser_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Read cleared user and verify it is available\n"); - err = TestReadClearedUserAndVerifyItIsAvailable_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Create new user in the cleared slot\n"); - err = TestCreateNewUserInTheClearedSlot_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Read the user in the previously cleared slot and verify its fields\n"); - err = TestReadTheUserInThePreviouslyClearedSlotAndVerifyItsFields_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Clear user with index 0 fails\n"); - err = TestClearUserWithIndex0Fails_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Clear user with out-of-bounds index fails\n"); - err = TestClearUserWithOutOfBoundsIndexFails_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Clear all users\n"); - err = TestClearAllUsers_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Read first cleared user and verify it is available\n"); - err = TestReadFirstClearedUserAndVerifyItIsAvailable_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Read last cleared user and verify it is available\n"); - err = TestReadLastClearedUserAndVerifyItIsAvailable_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Get number of supported PIN credentials and verify default value\n"); - err = TestGetNumberOfSupportedPinCredentialsAndVerifyDefaultValue_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Check that PIN credential does not exist\n"); - err = TestCheckThatPinCredentialDoesNotExist_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Reading PIN credential with index 0 returns no credential\n"); - err = TestReadingPinCredentialWithIndex0ReturnsNoCredential_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Reading PIN credential with out-of-bounds index returns no credential\n"); - err = TestReadingPinCredentialWithOutOfBoundsIndexReturnsNoCredential_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Verify that a user with UserStatus = 0 cannot be added via SetCredential\n"); - err = TestVerifyThatAUserWithUserStatus0CannotBeAddedViaSetCredential_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Verify that a user with UserStatus = 2 cannot be added via SetCredential\n"); - err = TestVerifyThatAUserWithUserStatus2CannotBeAddedViaSetCredential_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Create new PIN credential and user\n"); - err = TestCreateNewPinCredentialAndUser_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Verify created user\n"); - err = TestVerifyCreatedUser_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Verify created PIN credential\n"); - err = TestVerifyCreatedPinCredential_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Create new PIN credential and user with index 0 fails\n"); - err = TestCreateNewPinCredentialAndUserWithIndex0Fails_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Create new PIN credential and user with out-of-bounds index fails\n"); - err = TestCreateNewPinCredentialAndUserWithOutOfBoundsIndexFails_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Get number of supported RFID credentials and verify default value\n"); - err = TestGetNumberOfSupportedRfidCredentialsAndVerifyDefaultValue_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Reading RFID credential with index 0 returns no credential\n"); - err = TestReadingRfidCredentialWithIndex0ReturnsNoCredential_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Reading RFID credential with out-of-bounds index returns no credential\n"); - err = TestReadingRfidCredentialWithOutOfBoundsIndexReturnsNoCredential_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Check that RFID credential does not exist\n"); - err = TestCheckThatRfidCredentialDoesNotExist_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Create new RFID credential and add it to existing user with non-null UserStatus should fail\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserStatusShouldFail_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Create new RFID credential and add it to existing user with non-null UserType should fail\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeShouldFail_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Create new RFID credential and add it to existing user with non-null UserType and UserStatus should fail\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeAndUserStatusShouldFail_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Create new RFID credential and add it to existing user\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUser_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Verify modified user\n"); - err = TestVerifyModifiedUser_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Verify created credential\n"); - err = TestVerifyCreatedCredential_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Create new RFID credential and user with index 0 fails\n"); - err = TestCreateNewRfidCredentialAndUserWithIndex0Fails_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Create new RFID credential and user with out-of-bounds index fails\n"); - err = TestCreateNewRfidCredentialAndUserWithOutOfBoundsIndexFails_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Create new credential and try to add it to 0 user\n"); - err = TestCreateNewCredentialAndTryToAddItTo0User_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Create new credential and try to add it to out-of-bounds user\n"); - err = TestCreateNewCredentialAndTryToAddItToOutOfBoundsUser_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Create new PIN with too short data\n"); - err = TestCreateNewPinWithTooShortData_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Create new PIN with too long data\n"); - err = TestCreateNewPinWithTooLongData_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Create new RFID with too short data\n"); - err = TestCreateNewRfidWithTooShortData_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Create new PIN with Programming user type fails\n"); - err = TestCreateNewPinWithProgrammingUserTypeFails_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Create new RFID with too short data\n"); - err = TestCreateNewRfidWithTooShortData_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Create new PIN credential with data the would cause duplicate\n"); - err = TestCreateNewPinCredentialWithDataTheWouldCauseDuplicate_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Create new RFID credential with data the would cause duplicate\n"); - err = TestCreateNewRfidCredentialWithDataTheWouldCauseDuplicate_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Modify credentialData of existing PIN credential with non-null UserStatus should fail\n"); - err = TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusShouldFail_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Modify credentialData of existing PIN credential with non-null UserType should fail\n"); - err = TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserTypeShouldFail_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Modify credentialData of existing PIN credential with non-null UserStatus and UserType should fail\n"); - err = TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusAndUserTypeShouldFail_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Modify credentialData of existing PIN credential\n"); - err = TestModifyCredentialDataOfExistingPinCredential_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Verify that credential was changed by creating new credential with old data\n"); - err = TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithOldData_77(); - break; - case 78: - ChipLogProgress(chipTool, " ***** Test Step 78 : Verify that credential was changed by creating new credential with new data\n"); - err = TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithNewData_78(); - break; - case 79: - ChipLogProgress(chipTool, " ***** Test Step 79 : Create new RFID credential and add it to existing user\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUser_79(); - break; - case 80: - ChipLogProgress(chipTool, " ***** Test Step 80 : Verify modified user\n"); - err = TestVerifyModifiedUser_80(); - break; - case 81: - ChipLogProgress(chipTool, " ***** Test Step 81 : Create new RFID credential and add it to existing user\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUser_81(); - break; - case 82: - ChipLogProgress(chipTool, " ***** Test Step 82 : Verify modified user\n"); - err = TestVerifyModifiedUser_82(); - break; - case 83: - ChipLogProgress(chipTool, " ***** Test Step 83 : Clear first PIN credential\n"); - err = TestClearFirstPinCredential_83(); - break; - case 84: - ChipLogProgress(chipTool, " ***** Test Step 84 : Read back the credential and make sure it is deleted\n"); - err = TestReadBackTheCredentialAndMakeSureItIsDeleted_84(); - break; - case 85: - ChipLogProgress(chipTool, " ***** Test Step 85 : Read the user back and make sure PIN credential is deleted\n"); - err = TestReadTheUserBackAndMakeSurePinCredentialIsDeleted_85(); - break; - case 86: - ChipLogProgress(chipTool, " ***** Test Step 86 : Clear the second PIN credential\n"); - err = TestClearTheSecondPinCredential_86(); - break; - case 87: - ChipLogProgress(chipTool, " ***** Test Step 87 : Read back the credential and make sure it is deleted\n"); - err = TestReadBackTheCredentialAndMakeSureItIsDeleted_87(); - break; - case 88: - ChipLogProgress(chipTool, " ***** Test Step 88 : Read the user back and make sure related user is deleted\n"); - err = TestReadTheUserBackAndMakeSureRelatedUserIsDeleted_88(); - break; - case 89: - ChipLogProgress(chipTool, " ***** Test Step 89 : Create new RFID credential with user\n"); - err = TestCreateNewRfidCredentialWithUser_89(); - break; - case 90: - ChipLogProgress(chipTool, " ***** Test Step 90 : Clear all the RFID credentials\n"); - err = TestClearAllTheRfidCredentials_90(); - break; - case 91: - ChipLogProgress(chipTool, " ***** Test Step 91 : Read back the fist RFID credential and make sure it is deleted\n"); - err = TestReadBackTheFistRfidCredentialAndMakeSureItIsDeleted_91(); - break; - case 92: - ChipLogProgress(chipTool, " ***** Test Step 92 : Read back the second RFID credential and make sure it is deleted\n"); - err = TestReadBackTheSecondRfidCredentialAndMakeSureItIsDeleted_92(); - break; - case 93: - ChipLogProgress(chipTool, " ***** Test Step 93 : Read back the third RFID credential and make sure it is deleted\n"); - err = TestReadBackTheThirdRfidCredentialAndMakeSureItIsDeleted_93(); - break; - case 94: - ChipLogProgress(chipTool, " ***** Test Step 94 : Read the user related with first RFID back and make sure it has only PIN credential\n"); - err = TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItHasOnlyPinCredential_94(); - break; - case 95: - ChipLogProgress(chipTool, " ***** Test Step 95 : Read the user related with second RFID back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithSecondRfidBackAndMakeSureItIsDeleted_95(); - break; - case 96: - ChipLogProgress(chipTool, " ***** Test Step 96 : Create new PIN credential with user\n"); - err = TestCreateNewPinCredentialWithUser_96(); - break; - case 97: - ChipLogProgress(chipTool, " ***** Test Step 97 : Create new RFID credential with user\n"); - err = TestCreateNewRfidCredentialWithUser_97(); - break; - case 98: - ChipLogProgress(chipTool, " ***** Test Step 98 : Create another RFID credential with user\n"); - err = TestCreateAnotherRfidCredentialWithUser_98(); - break; - case 99: - ChipLogProgress(chipTool, " ***** Test Step 99 : Clear all the credentials\n"); - err = TestClearAllTheCredentials_99(); - break; - case 100: - ChipLogProgress(chipTool, " ***** Test Step 100 : Read back the first PIN credential and make sure it is deleted\n"); - err = TestReadBackTheFirstPinCredentialAndMakeSureItIsDeleted_100(); - break; - case 101: - ChipLogProgress(chipTool, " ***** Test Step 101 : Read back the first RFID credential and make sure it is deleted\n"); - err = TestReadBackTheFirstRfidCredentialAndMakeSureItIsDeleted_101(); - break; - case 102: - ChipLogProgress(chipTool, " ***** Test Step 102 : Read back the second PIN credential and make sure it is deleted\n"); - err = TestReadBackTheSecondPinCredentialAndMakeSureItIsDeleted_102(); - break; - case 103: - ChipLogProgress(chipTool, " ***** Test Step 103 : Read the user related with first PIN back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithFirstPinBackAndMakeSureItIsDeleted_103(); - break; - case 104: - ChipLogProgress(chipTool, " ***** Test Step 104 : Read the user related with first RFID back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItIsDeleted_104(); - break; - case 105: - ChipLogProgress(chipTool, " ***** Test Step 105 : Read the user related with second PIN back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithSecondPinBackAndMakeSureItIsDeleted_105(); - break; - case 106: - ChipLogProgress(chipTool, " ***** Test Step 106 : Read the user related with last RFID back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithLastRfidBackAndMakeSureItIsDeleted_106(); - break; - case 107: - ChipLogProgress(chipTool, " ***** Test Step 107 : Create new Programming PIN credential with invalid index\n"); - err = TestCreateNewProgrammingPinCredentialWithInvalidIndex_107(); - break; - case 108: - ChipLogProgress(chipTool, " ***** Test Step 108 : Create new Programming PIN credential with valid index\n"); - err = TestCreateNewProgrammingPinCredentialWithValidIndex_108(); - break; - case 109: - ChipLogProgress(chipTool, " ***** Test Step 109 : Verify created user\n"); - err = TestVerifyCreatedUser_109(); - break; - case 110: - ChipLogProgress(chipTool, " ***** Test Step 110 : Verify created programming PIN credential\n"); - err = TestVerifyCreatedProgrammingPinCredential_110(); - break; - case 111: - ChipLogProgress(chipTool, " ***** Test Step 111 : Modify the Programming PIN credential\n"); - err = TestModifyTheProgrammingPinCredential_111(); - break; - case 112: - ChipLogProgress(chipTool, " ***** Test Step 112 : Clearing Programming PIN fails\n"); - err = TestClearingProgrammingPinFails_112(); - break; - case 113: - ChipLogProgress(chipTool, " ***** Test Step 113 : Clearing Programming PIN with invalid index fails\n"); - err = TestClearingProgrammingPinWithInvalidIndexFails_113(); - break; - case 114: - ChipLogProgress(chipTool, " ***** Test Step 114 : Clearing PIN credential with zero index fails\n"); - err = TestClearingPinCredentialWithZeroIndexFails_114(); - break; - case 115: - ChipLogProgress(chipTool, " ***** Test Step 115 : Clearing PIN credential with out-of-bound index fails\n"); - err = TestClearingPinCredentialWithOutOfBoundIndexFails_115(); - break; - case 116: - ChipLogProgress(chipTool, " ***** Test Step 116 : Clearing RFID credential with zero index fails\n"); - err = TestClearingRfidCredentialWithZeroIndexFails_116(); - break; - case 117: - ChipLogProgress(chipTool, " ***** Test Step 117 : Clearing RFID credential with out-of-bound index fails\n"); - err = TestClearingRfidCredentialWithOutOfBoundIndexFails_117(); - break; - case 118: - ChipLogProgress(chipTool, " ***** Test Step 118 : Clear the Programming PIN user\n"); - err = TestClearTheProgrammingPinUser_118(); - break; - case 119: - ChipLogProgress(chipTool, " ***** Test Step 119 : Make sure Programming PIN user is deleted\n"); - err = TestMakeSureProgrammingPinUserIsDeleted_119(); - break; - case 120: - ChipLogProgress(chipTool, " ***** Test Step 120 : Make sure programming PIN credential is deleted\n"); - err = TestMakeSureProgrammingPinCredentialIsDeleted_120(); - break; - case 121: - ChipLogProgress(chipTool, " ***** Test Step 121 : Create new PIN credential and user\n"); - err = TestCreateNewPinCredentialAndUser_121(); - break; - case 122: - ChipLogProgress(chipTool, " ***** Test Step 122 : Create second PIN credential and add it to existing user\n"); - err = TestCreateSecondPinCredentialAndAddItToExistingUser_122(); - break; - case 123: - ChipLogProgress(chipTool, " ***** Test Step 123 : Create third PIN credential and add it to existing user\n"); - err = TestCreateThirdPinCredentialAndAddItToExistingUser_123(); - break; - case 124: - ChipLogProgress(chipTool, " ***** Test Step 124 : Create fourth PIN credential and add it to existing user\n"); - err = TestCreateFourthPinCredentialAndAddItToExistingUser_124(); - break; - case 125: - ChipLogProgress(chipTool, " ***** Test Step 125 : Create fifth PIN credential and add it to existing user\n"); - err = TestCreateFifthPinCredentialAndAddItToExistingUser_125(); - break; - case 126: - ChipLogProgress(chipTool, " ***** Test Step 126 : Try to create sixth PIN credential and make sure it fails\n"); - err = TestTryToCreateSixthPinCredentialAndMakeSureItFails_126(); - break; - case 127: - ChipLogProgress(chipTool, " ***** Test Step 127 : Final clean-up\n"); - err = TestFinalCleanUp_127(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 78: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 79: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 80: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 81: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 82: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 83: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 84: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 85: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 86: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 87: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 88: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 89: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 90: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 91: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 92: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 93: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 94: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 95: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 96: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 97: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 98: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 99: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 100: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 101: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 102: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 103: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 104: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 105: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 106: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 107: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 108: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 109: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 110: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 111: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 112: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 113: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 114: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 115: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 116: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 117: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 118: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 119: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 120: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 121: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 122: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 123: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 124: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 125: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 126: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 127: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 128; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAvailableUserSlotAndVerifyResponseFields_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read available user slot and verify response fields: Error: %@", err); - } else { - NSLog(@"Read available user slot and verify response fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; - - CHIP_ERROR TestGetNumberOfSupportedUsersAndVerifyDefaultValue_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get number of supported users and verify default value: Error: %@", err); - } else { - NSLog(@"Get number of supported users and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfTotalUsersSupported", actualValue, 10U)); - } - { - NumberOfTotalUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFailsForUserWithIndex0_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read fails for user with index 0: Error: %@", err); - } else { - NSLog(@"Read fails for user with index 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFailsForUserWithIndexGreaterThanNumberOfUsersSupported_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read fails for user with index greater than Number Of Users Supported: Error: %@", err); - } else { - NSLog(@"Read fails for user with index greater than Number Of Users Supported: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewUserWithDefaultParameters_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new user with default parameters: Error: %@", err); - } else { - NSLog(@"Create new user with default parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserBackAndVerifyItsFields_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetUserAtTheOccupiedIndexFailsWithAppropriateResponse_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set user at the occupied index fails with appropriate response: Error: %@", err); - } else { - NSLog(@"Set user at the occupied index fails with appropriate response: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyUserNameForExistingUser_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"new_user"; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify userName for existing user: Error: %@", err); - } else { - NSLog(@"Modify userName for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyUserUniqueIdForExistingUser_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:305441741UL]; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify userUniqueId for existing user: Error: %@", err); - } else { - NSLog(@"Modify userUniqueId for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyUserStatusForExistingUser_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = - [NSNumber numberWithUnsignedChar:3U]; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify userStatus for existing user: Error: %@", err); - } else { - NSLog(@"Modify userStatus for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyUserTypeForExistingUser_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = - [NSNumber numberWithUnsignedChar:6U]; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify userType for existing user: Error: %@", err); - } else { - NSLog(@"Modify userType for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 6U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialRuleForExistingUser_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = - [NSNumber numberWithUnsignedChar:2U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialRule for existing user: Error: %@", err); - } else { - NSLog(@"Modify credentialRule for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 6U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 2U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyAllFieldsForExistingUser_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"test_user"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:466460832UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:1U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify all fields for existing user: Error: %@", err); - } else { - NSLog(@"Modify all fields for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"test_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 466460832UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 1U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddAnotherUserWithNonDefaultFields_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = @"test_user2"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:12648430UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:1U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:2U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add another user with non-default fields: Error: %@", err); - } else { - NSLog(@"Add another user with non-default fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheNewUserBackAndVerifyItsFields_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the new user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the new user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"test_user2")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 12648430UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 1U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 2U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToAddAUserWithUserStatus0_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - params.userName = @"test_user3"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:47802UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:0U]; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to add a user with userStatus 0: Error: %@", err); - } else { - NSLog(@"Try to add a user with userStatus 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureTheUserDidNotGetCreated_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure the user did not get created: Error: %@", err); - } else { - NSLog(@"Make sure the user did not get created: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToAddAUserWithUserStatus2_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - params.userName = @"test_user3"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:47802UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:2U]; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to add a user with userStatus 2: Error: %@", err); - } else { - NSLog(@"Try to add a user with userStatus 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureTheUserDidNotGetCreated_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure the user did not get created: Error: %@", err); - } else { - NSLog(@"Make sure the user did not get created: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToAddAUserWithUserStatus3_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - params.userName = @"test_user3"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:47802UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:3U]; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to add a user with userStatus 3: Error: %@", err); - } else { - NSLog(@"Try to add a user with userStatus 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheNewThirdUserBackAndVerifyItsFields_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the new third user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the new third user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"test_user3")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 47802UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateUserInTheLastSlot_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NumberOfTotalUsersSupportedValue copy]; - params.userName = @"last_user"; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create user in the last slot: Error: %@", err); - } else { - NSLog(@"Create user in the last slot: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheLastUserBackAndVerifyItsFields_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NumberOfTotalUsersSupportedValue copy]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the last user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the last user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, NumberOfTotalUsersSupportedValue)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"last_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestUserCreationInThe0SlotFails_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"User creation in the 0 slot fails: Error: %@", err); - } else { - NSLog(@"User creation in the 0 slot fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestUserCreationInTheOutOfBoundsSlotFails_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"User creation in the out-of-bounds slot fails: Error: %@", err); - } else { - NSLog(@"User creation in the out-of-bounds slot fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearFirstUser_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear first user: Error: %@", err); - } else { - NSLog(@"Clear first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadClearedUserAndVerifyItIsAvailable_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read cleared user and verify it is available: Error: %@", err); - } else { - NSLog(@"Read cleared user and verify it is available: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewUserInTheClearedSlot_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new user in the cleared slot: Error: %@", err); - } else { - NSLog(@"Create new user in the cleared slot: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserInThePreviouslyClearedSlotAndVerifyItsFields_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user in the previously cleared slot and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the user in the previously cleared slot and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearUserWithIndex0Fails_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear user with index 0 fails: Error: %@", err); - } else { - NSLog(@"Clear user with index 0 fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearUserWithOutOfBoundsIndexFails_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear user with out-of-bounds index fails: Error: %@", err); - } else { - NSLog(@"Clear user with out-of-bounds index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllUsers_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all users: Error: %@", err); - } else { - NSLog(@"Clear all users: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFirstClearedUserAndVerifyItIsAvailable_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read first cleared user and verify it is available: Error: %@", err); - } else { - NSLog(@"Read first cleared user and verify it is available: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLastClearedUserAndVerifyItIsAvailable_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NumberOfTotalUsersSupportedValue copy]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read last cleared user and verify it is available: Error: %@", err); - } else { - NSLog(@"Read last cleared user and verify it is available: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, NumberOfTotalUsersSupportedValue)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfPINUsersSupportedValue; - - CHIP_ERROR TestGetNumberOfSupportedPinCredentialsAndVerifyDefaultValue_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfPINUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get number of supported PIN credentials and verify default value: Error: %@", err); - } else { - NSLog(@"Get number of supported PIN credentials and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfPINUsersSupported", actualValue, 10U)); - } - { - NumberOfPINUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatPinCredentialDoesNotExist_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that PIN credential does not exist: Error: %@", err); - } else { - NSLog(@"Check that PIN credential does not exist: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadingPinCredentialWithIndex0ReturnsNoCredential_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reading PIN credential with index 0 returns no credential: Error: %@", err); - } else { - NSLog(@"Reading PIN credential with index 0 returns no credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadingPinCredentialWithOutOfBoundsIndexReturnsNoCredential_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfPINUsersSupportedValue unsignedShortValue] + 1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reading PIN credential with out-of-bounds index returns no credential: Error: %@", err); - } else { - NSLog(@"Reading PIN credential with out-of-bounds index returns no credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatAUserWithUserStatus0CannotBeAddedViaSetCredential_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = - [NSNumber numberWithUnsignedChar:0U]; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that a user with UserStatus = 0 cannot be added via SetCredential: Error: %@", err); - } else { - NSLog(@"Verify that a user with UserStatus = 0 cannot be added via SetCredential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatAUserWithUserStatus2CannotBeAddedViaSetCredential_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = - [NSNumber numberWithUnsignedChar:2U]; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that a user with UserStatus = 2 cannot be added via SetCredential: Error: %@", err); - } else { - NSLog(@"Verify that a user with UserStatus = 2 cannot be added via SetCredential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndUser_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedUser_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created user: Error: %@", err); - } else { - NSLog(@"Verify created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedPinCredential_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created PIN credential: Error: %@", err); - } else { - NSLog(@"Verify created PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndUserWithIndex0Fails_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and user with index 0 fails: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and user with index 0 fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndUserWithOutOfBoundsIndexFails_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfPINUsersSupportedValue unsignedShortValue] + 1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and user with out-of-bounds index fails: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and user with out-of-bounds index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfRFIDUsersSupportedValue; - - CHIP_ERROR TestGetNumberOfSupportedRfidCredentialsAndVerifyDefaultValue_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfRFIDUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get number of supported RFID credentials and verify default value: Error: %@", err); - } else { - NSLog(@"Get number of supported RFID credentials and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfRFIDUsersSupported", actualValue, 10U)); - } - { - NumberOfRFIDUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadingRfidCredentialWithIndex0ReturnsNoCredential_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reading RFID credential with index 0 returns no credential: Error: %@", err); - } else { - NSLog(@"Reading RFID credential with index 0 returns no credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadingRfidCredentialWithOutOfBoundsIndexReturnsNoCredential_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfRFIDUsersSupportedValue unsignedShortValue] + 1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reading RFID credential with out-of-bounds index returns no credential: Error: %@", err); - } else { - NSLog(@"Reading RFID credential with out-of-bounds index returns no credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatRfidCredentialDoesNotExist_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that RFID credential does not exist: Error: %@", err); - } else { - NSLog(@"Check that RFID credential does not exist: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserStatusShouldFail_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserStatus should fail: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserStatus should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeShouldFail_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserType should fail: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserType should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeAndUserStatusShouldFail_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserType and UserStatus should fail: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserType and UserStatus should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUser_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyModifiedUser_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify modified user: Error: %@", err); - } else { - NSLog(@"Verify modified user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedCredential_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created credential: Error: %@", err); - } else { - NSLog(@"Verify created credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndUserWithIndex0Fails_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"new_rfid_data_field" length:19]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and user with index 0 fails: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and user with index 0 fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndUserWithOutOfBoundsIndexFails_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfRFIDUsersSupportedValue unsignedShortValue] + 1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"new_rfid_data_field" length:19]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and user with out-of-bounds index fails: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and user with out-of-bounds index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewCredentialAndTryToAddItTo0User_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123465" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new credential and try to add it to 0 user: Error: %@", err); - } else { - NSLog(@"Create new credential and try to add it to 0 user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewCredentialAndTryToAddItToOutOfBoundsUser_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123465" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new credential and try to add it to out-of-bounds user: Error: %@", err); - } else { - NSLog(@"Create new credential and try to add it to out-of-bounds user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinWithTooShortData_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"12345" length:5]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN with too short data: Error: %@", err); - } else { - NSLog(@"Create new PIN with too short data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinWithTooLongData_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456789" length:9]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN with too long data: Error: %@", err); - } else { - NSLog(@"Create new PIN with too long data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidWithTooShortData_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data" length:9]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID with too short data: Error: %@", err); - } else { - NSLog(@"Create new RFID with too short data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinWithProgrammingUserTypeFails_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = - [NSNumber numberWithUnsignedChar:3U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN with Programming user type fails: Error: %@", err); - } else { - NSLog(@"Create new PIN with Programming user type fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidWithTooShortData_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"very_long_rfid_data_to_test_boundaries" length:38]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID with too short data: Error: %@", err); - } else { - NSLog(@"Create new RFID with too short data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialWithDataTheWouldCauseDuplicate_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential with data the would cause duplicate: Error: %@", err); - } else { - NSLog(@"Create new PIN credential with data the would cause duplicate: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialWithDataTheWouldCauseDuplicate_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential with data the would cause duplicate: Error: %@", err); - } else { - NSLog(@"Create new RFID credential with data the would cause duplicate: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusShouldFail_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus should fail: Error: %@", err); - } else { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserTypeShouldFail_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserType should fail: Error: %@", err); - } else { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserType should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusAndUserTypeShouldFail_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus and UserType should fail: Error: %@", err); - } else { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus and UserType should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialDataOfExistingPinCredential_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialData of existing PIN credential: Error: %@", err); - } else { - NSLog(@"Modify credentialData of existing PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithOldData_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that credential was changed by creating new credential with old data: Error: %@", err); - } else { - NSLog(@"Verify that credential was changed by creating new credential with old data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithNewData_78() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that credential was changed by creating new credential with new data: Error: %@", err); - } else { - NSLog(@"Verify that credential was changed by creating new credential with new data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUser_79() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_7890" length:14]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyModifiedUser_80() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify modified user: Error: %@", err); - } else { - NSLog(@"Verify modified user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialIndex, 2U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUser_81() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"789012" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyModifiedUser_82() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify modified user: Error: %@", err); - } else { - NSLog(@"Verify modified user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialIndex, 2U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[3]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[3]).credentialIndex, 3U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearFirstPinCredential_83() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear first PIN credential: Error: %@", err); - } else { - NSLog(@"Clear first PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheCredentialAndMakeSureItIsDeleted_84() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserBackAndMakeSurePinCredentialIsDeleted_85() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user back and make sure PIN credential is deleted: Error: %@", err); - } else { - NSLog(@"Read the user back and make sure PIN credential is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 2U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialIndex, 3U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearTheSecondPinCredential_86() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear the second PIN credential: Error: %@", err); - } else { - NSLog(@"Clear the second PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheCredentialAndMakeSureItIsDeleted_87() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserBackAndMakeSureRelatedUserIsDeleted_88() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user back and make sure related user is deleted: Error: %@", err); - } else { - NSLog(@"Read the user back and make sure related user is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialWithUser_89() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_12345" length:15]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential with user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential with user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllTheRfidCredentials_90() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:65534U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all the RFID credentials: Error: %@", err); - } else { - NSLog(@"Clear all the RFID credentials: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheFistRfidCredentialAndMakeSureItIsDeleted_91() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the fist RFID credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the fist RFID credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheSecondRfidCredentialAndMakeSureItIsDeleted_92() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the second RFID credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the second RFID credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheThirdRfidCredentialAndMakeSureItIsDeleted_93() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the third RFID credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the third RFID credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItHasOnlyPinCredential_94() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with first RFID back and make sure it has only PIN credential: Error: %@", err); - } else { - NSLog(@"Read the user related with first RFID back and make sure it has only PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 3U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithSecondRfidBackAndMakeSureItIsDeleted_95() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with second RFID back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with second RFID back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialWithUser_96() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential with user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential with user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialWithUser_97() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_1234" length:14]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential with user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential with user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherRfidCredentialWithUser_98() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:6U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_9876" length:14]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another RFID credential with user: Error: %@", err); - } else { - NSLog(@"Create another RFID credential with user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 4U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllTheCredentials_99() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = nil; - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all the credentials: Error: %@", err); - } else { - NSLog(@"Clear all the credentials: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheFirstPinCredentialAndMakeSureItIsDeleted_100() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the first PIN credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the first PIN credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheFirstRfidCredentialAndMakeSureItIsDeleted_101() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the first RFID credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the first RFID credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheSecondPinCredentialAndMakeSureItIsDeleted_102() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:6U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the second PIN credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the second PIN credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithFirstPinBackAndMakeSureItIsDeleted_103() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with first PIN back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with first PIN back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItIsDeleted_104() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with first RFID back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with first RFID back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithSecondPinBackAndMakeSureItIsDeleted_105() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with second PIN back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with second PIN back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithLastRfidBackAndMakeSureItIsDeleted_106() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:4U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with last RFID back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with last RFID back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 4U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewProgrammingPinCredentialWithInvalidIndex_107() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new Programming PIN credential with invalid index: Error: %@", err); - } else { - NSLog(@"Create new Programming PIN credential with invalid index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewProgrammingPinCredentialWithValidIndex_108() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new Programming PIN credential with valid index: Error: %@", err); - } else { - NSLog(@"Create new Programming PIN credential with valid index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedUser_109() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created user: Error: %@", err); - } else { - NSLog(@"Verify created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 0U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 0U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedProgrammingPinCredential_110() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created programming PIN credential: Error: %@", err); - } else { - NSLog(@"Verify created programming PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyTheProgrammingPinCredential_111() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"654321" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify the Programming PIN credential: Error: %@", err); - } else { - NSLog(@"Modify the Programming PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingProgrammingPinFails_112() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing Programming PIN fails: Error: %@", err); - } else { - NSLog(@"Clearing Programming PIN fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingProgrammingPinWithInvalidIndexFails_113() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing Programming PIN with invalid index fails: Error: %@", err); - } else { - NSLog(@"Clearing Programming PIN with invalid index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingPinCredentialWithZeroIndexFails_114() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing PIN credential with zero index fails: Error: %@", err); - } else { - NSLog(@"Clearing PIN credential with zero index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingPinCredentialWithOutOfBoundIndexFails_115() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfPINUsersSupportedValue unsignedShortValue] + 1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing PIN credential with out-of-bound index fails: Error: %@", err); - } else { - NSLog(@"Clearing PIN credential with out-of-bound index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingRfidCredentialWithZeroIndexFails_116() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing RFID credential with zero index fails: Error: %@", err); - } else { - NSLog(@"Clearing RFID credential with zero index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingRfidCredentialWithOutOfBoundIndexFails_117() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfRFIDUsersSupportedValue unsignedShortValue] + 1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing RFID credential with out-of-bound index fails: Error: %@", err); - } else { - NSLog(@"Clearing RFID credential with out-of-bound index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearTheProgrammingPinUser_118() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear the Programming PIN user: Error: %@", err); - } else { - NSLog(@"Clear the Programming PIN user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureProgrammingPinUserIsDeleted_119() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure Programming PIN user is deleted: Error: %@", err); - } else { - NSLog(@"Make sure Programming PIN user is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureProgrammingPinCredentialIsDeleted_120() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure programming PIN credential is deleted: Error: %@", err); - } else { - NSLog(@"Make sure programming PIN credential is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndUser_121() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateSecondPinCredentialAndAddItToExistingUser_122() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000001" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create second PIN credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create second PIN credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateThirdPinCredentialAndAddItToExistingUser_123() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000002" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create third PIN credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create third PIN credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateFourthPinCredentialAndAddItToExistingUser_124() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:4U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000003" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create fourth PIN credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create fourth PIN credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateFifthPinCredentialAndAddItToExistingUser_125() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:5U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000004" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create fifth PIN credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create fifth PIN credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 6U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToCreateSixthPinCredentialAndMakeSureItFails_126() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:6U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000005" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to create sixth PIN credential and make sure it fails: Error: %@", err); - } else { - NSLog(@"Try to create sixth PIN credential and make sure it fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 137U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestFinalCleanUp_127() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Final clean-up: Error: %@", err); - } else { - NSLog(@"Final clean-up: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class DL_Schedules : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - DL_Schedules() - : TestCommandBridge("DL_Schedules") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~DL_Schedules() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: DL_Schedules\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: DL_Schedules\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Create new PIN credential and schedule user\n"); - err = TestCreateNewPinCredentialAndScheduleUser_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Get number of supported users\n"); - err = TestGetNumberOfSupportedUsers_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Get Max number of Week Day schedules for user and verify default value\n"); - err = TestGetMaxNumberOfWeekDaySchedulesForUserAndVerifyDefaultValue_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Get Max number of Year Day schedules for user and verify default value\n"); - err = TestGetMaxNumberOfYearDaySchedulesForUserAndVerifyDefaultValue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Get Max number of Holiday schedules and verify default value\n"); - err = TestGetMaxNumberOfHolidaySchedulesAndVerifyDefaultValue_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Create Week Day schedule with 0 index\n"); - err = TestCreateWeekDayScheduleWith0Index_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Create Week Day schedule with out-of-bounds index\n"); - err = TestCreateWeekDayScheduleWithOutOfBoundsIndex_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Create Week Day schedule with 0 user index\n"); - err = TestCreateWeekDayScheduleWith0UserIndex_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Create Week Day schedule with out-of-bounds user index\n"); - err = TestCreateWeekDayScheduleWithOutOfBoundsUserIndex_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Create Week Day schedule for non-existing user\n"); - err = TestCreateWeekDayScheduleForNonExistingUser_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Create Week Day schedule with 0 days mask\n"); - err = TestCreateWeekDayScheduleWith0DaysMask_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Create Week Day schedule for Sunday and Monday\n"); - err = TestCreateWeekDayScheduleForSundayAndMonday_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Create Week Day schedule for Sunday Wednesday and Saturday\n"); - err = TestCreateWeekDayScheduleForSundayWednesdayAndSaturday_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Create Week Day schedule with invalid start hour\n"); - err = TestCreateWeekDayScheduleWithInvalidStartHour_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Create Week Day schedule with invalid start minute\n"); - err = TestCreateWeekDayScheduleWithInvalidStartMinute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Create Week Day schedule with invalid end hour\n"); - err = TestCreateWeekDayScheduleWithInvalidEndHour_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Create Week Day schedule with invalid end minute\n"); - err = TestCreateWeekDayScheduleWithInvalidEndMinute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Create Week Day schedule with start hour later that end hour\n"); - err = TestCreateWeekDayScheduleWithStartHourLaterThatEndHour_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Create Week Day schedule with start minute later that end minute when hours are equal\n"); - err = TestCreateWeekDayScheduleWithStartMinuteLaterThatEndMinuteWhenHoursAreEqual_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Make sure that previous operations did not create a schedule\n"); - err = TestMakeSureThatPreviousOperationsDidNotCreateASchedule_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Get Week Day schedule with 0 index\n"); - err = TestGetWeekDayScheduleWith0Index_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Get Week Day schedule with out-of-bounds index\n"); - err = TestGetWeekDayScheduleWithOutOfBoundsIndex_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Get Week Day schedule with 0 user index\n"); - err = TestGetWeekDayScheduleWith0UserIndex_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Get Week Day schedule with out-of-bounds user index\n"); - err = TestGetWeekDayScheduleWithOutOfBoundsUserIndex_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Get Week Day schedule with non-existing user index\n"); - err = TestGetWeekDayScheduleWithNonExistingUserIndex_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Create Year Day schedule with 0 index\n"); - err = TestCreateYearDayScheduleWith0Index_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Create Year Day schedule with out-of-bounds index\n"); - err = TestCreateYearDayScheduleWithOutOfBoundsIndex_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Create Year Day schedule with 0 user index\n"); - err = TestCreateYearDayScheduleWith0UserIndex_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Create Year Day schedule with out-of-bounds user index\n"); - err = TestCreateYearDayScheduleWithOutOfBoundsUserIndex_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Create Year Day schedule for non-existing user\n"); - err = TestCreateYearDayScheduleForNonExistingUser_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Create Year Day schedule with start hour later that end hour\n"); - err = TestCreateYearDayScheduleWithStartHourLaterThatEndHour_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Make sure that previous operations did not create a schedule\n"); - err = TestMakeSureThatPreviousOperationsDidNotCreateASchedule_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Get Year Day schedule with 0 index\n"); - err = TestGetYearDayScheduleWith0Index_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Get Year Day schedule with out-of-bounds index\n"); - err = TestGetYearDayScheduleWithOutOfBoundsIndex_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Get Year Day schedule with 0 user index\n"); - err = TestGetYearDayScheduleWith0UserIndex_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Get Year Day schedule with out-of-bounds user index\n"); - err = TestGetYearDayScheduleWithOutOfBoundsUserIndex_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Get Year Day schedule with non-existing user index\n"); - err = TestGetYearDayScheduleWithNonExistingUserIndex_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Create Holiday schedule with 0 index\n"); - err = TestCreateHolidayScheduleWith0Index_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Create Holiday schedule with out-of-bounds index\n"); - err = TestCreateHolidayScheduleWithOutOfBoundsIndex_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Create Holiday schedule with start hour later that end hour\n"); - err = TestCreateHolidayScheduleWithStartHourLaterThatEndHour_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Create Holiday schedule with invalid operating mode\n"); - err = TestCreateHolidayScheduleWithInvalidOperatingMode_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Make sure that previous operations did not create a schedule\n"); - err = TestMakeSureThatPreviousOperationsDidNotCreateASchedule_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Get Holiday schedule with 0 index\n"); - err = TestGetHolidayScheduleWith0Index_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Get Holiday schedule with out-of-bounds index\n"); - err = TestGetHolidayScheduleWithOutOfBoundsIndex_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Create Holiday schedule with valid parameters\n"); - err = TestCreateHolidayScheduleWithValidParameters_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Verify created schedule\n"); - err = TestVerifyCreatedSchedule_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Create Week Day schedule with valid parameters\n"); - err = TestCreateWeekDayScheduleWithValidParameters_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Verify created schedule\n"); - err = TestVerifyCreatedSchedule_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Create Year Day schedule with valid parameters\n"); - err = TestCreateYearDayScheduleWithValidParameters_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Verify created schedule\n"); - err = TestVerifyCreatedSchedule_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Clear Week Day schedule with 0 index\n"); - err = TestClearWeekDayScheduleWith0Index_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Clear Week Day schedule with out-of-bounds index\n"); - err = TestClearWeekDayScheduleWithOutOfBoundsIndex_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Clear Week Day schedule with 0 user index\n"); - err = TestClearWeekDayScheduleWith0UserIndex_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Clear Week Day schedule with out-of-bounds user index\n"); - err = TestClearWeekDayScheduleWithOutOfBoundsUserIndex_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Clear Week Day schedule with non-existing user\n"); - err = TestClearWeekDayScheduleWithNonExistingUser_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Make sure that week day schedule was not deleted\n"); - err = TestMakeSureThatWeekDayScheduleWasNotDeleted_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Make sure that year day schedule was not deleted\n"); - err = TestMakeSureThatYearDayScheduleWasNotDeleted_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Make sure that holiday schedule was not deleted\n"); - err = TestMakeSureThatHolidayScheduleWasNotDeleted_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Clear Year Day schedule with 0 index\n"); - err = TestClearYearDayScheduleWith0Index_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Clear Year Day schedule with out-of-bounds index\n"); - err = TestClearYearDayScheduleWithOutOfBoundsIndex_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Clear Year Day schedule with 0 user index\n"); - err = TestClearYearDayScheduleWith0UserIndex_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Clear Year Day schedule with out-of-bounds user index\n"); - err = TestClearYearDayScheduleWithOutOfBoundsUserIndex_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Clear Year Day schedule with non-existing user\n"); - err = TestClearYearDayScheduleWithNonExistingUser_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Make sure that week day schedule was not deleted\n"); - err = TestMakeSureThatWeekDayScheduleWasNotDeleted_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Make sure that year day schedule was not deleted\n"); - err = TestMakeSureThatYearDayScheduleWasNotDeleted_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Make sure that holiday schedule was not deleted\n"); - err = TestMakeSureThatHolidayScheduleWasNotDeleted_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Clear Holiday schedule with 0 index\n"); - err = TestClearHolidayScheduleWith0Index_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Clear Holiday schedule with out-of-bounds index\n"); - err = TestClearHolidayScheduleWithOutOfBoundsIndex_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Make sure that week day schedule was not deleted\n"); - err = TestMakeSureThatWeekDayScheduleWasNotDeleted_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Make sure that year day schedule was not deleted\n"); - err = TestMakeSureThatYearDayScheduleWasNotDeleted_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Make sure that holiday schedule was not deleted\n"); - err = TestMakeSureThatHolidayScheduleWasNotDeleted_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Create another Week Day schedule with valid parameters\n"); - err = TestCreateAnotherWeekDayScheduleWithValidParameters_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Verify created week day schedule\n"); - err = TestVerifyCreatedWeekDaySchedule_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Create another Year Day schedule with valid parameters\n"); - err = TestCreateAnotherYearDayScheduleWithValidParameters_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Verify created year day schedule\n"); - err = TestVerifyCreatedYearDaySchedule_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Create another Holiday schedule with valid parameters\n"); - err = TestCreateAnotherHolidayScheduleWithValidParameters_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Verify created holiday schedule\n"); - err = TestVerifyCreatedHolidaySchedule_77(); - break; - case 78: - ChipLogProgress(chipTool, " ***** Test Step 78 : Clear a single week day schedule for the first user\n"); - err = TestClearASingleWeekDayScheduleForTheFirstUser_78(); - break; - case 79: - ChipLogProgress(chipTool, " ***** Test Step 79 : Verify cleared week day schedule\n"); - err = TestVerifyClearedWeekDaySchedule_79(); - break; - case 80: - ChipLogProgress(chipTool, " ***** Test Step 80 : Clear all remaining week day schedules for the first user\n"); - err = TestClearAllRemainingWeekDaySchedulesForTheFirstUser_80(); - break; - case 81: - ChipLogProgress(chipTool, " ***** Test Step 81 : Verify cleared week schedule\n"); - err = TestVerifyClearedWeekSchedule_81(); - break; - case 82: - ChipLogProgress(chipTool, " ***** Test Step 82 : Make sure that first year day schedule was not deleted\n"); - err = TestMakeSureThatFirstYearDayScheduleWasNotDeleted_82(); - break; - case 83: - ChipLogProgress(chipTool, " ***** Test Step 83 : Make sure that second year day schedule was not deleted\n"); - err = TestMakeSureThatSecondYearDayScheduleWasNotDeleted_83(); - break; - case 84: - ChipLogProgress(chipTool, " ***** Test Step 84 : Make sure that first holiday schedule was not deleted\n"); - err = TestMakeSureThatFirstHolidayScheduleWasNotDeleted_84(); - break; - case 85: - ChipLogProgress(chipTool, " ***** Test Step 85 : Make sure that second holiday schedule was not deleted\n"); - err = TestMakeSureThatSecondHolidayScheduleWasNotDeleted_85(); - break; - case 86: - ChipLogProgress(chipTool, " ***** Test Step 86 : Create another Week Day schedule with valid parameters\n"); - err = TestCreateAnotherWeekDayScheduleWithValidParameters_86(); - break; - case 87: - ChipLogProgress(chipTool, " ***** Test Step 87 : Clear a single year day schedule for the first user\n"); - err = TestClearASingleYearDayScheduleForTheFirstUser_87(); - break; - case 88: - ChipLogProgress(chipTool, " ***** Test Step 88 : Verify cleared year day schedule\n"); - err = TestVerifyClearedYearDaySchedule_88(); - break; - case 89: - ChipLogProgress(chipTool, " ***** Test Step 89 : Clear all remaining year schedules for the first user\n"); - err = TestClearAllRemainingYearSchedulesForTheFirstUser_89(); - break; - case 90: - ChipLogProgress(chipTool, " ***** Test Step 90 : Verify that second year day schedule was cleared\n"); - err = TestVerifyThatSecondYearDayScheduleWasCleared_90(); - break; - case 91: - ChipLogProgress(chipTool, " ***** Test Step 91 : Verify created week day schedule\n"); - err = TestVerifyCreatedWeekDaySchedule_91(); - break; - case 92: - ChipLogProgress(chipTool, " ***** Test Step 92 : Clear all remaining week day schedules for the first user\n"); - err = TestClearAllRemainingWeekDaySchedulesForTheFirstUser_92(); - break; - case 93: - ChipLogProgress(chipTool, " ***** Test Step 93 : Create new user without credential so we can add more schedules to it\n"); - err = TestCreateNewUserWithoutCredentialSoWeCanAddMoreSchedulesToIt_93(); - break; - case 94: - ChipLogProgress(chipTool, " ***** Test Step 94 : Create Week Day schedule with valid parameters for first user\n"); - err = TestCreateWeekDayScheduleWithValidParametersForFirstUser_94(); - break; - case 95: - ChipLogProgress(chipTool, " ***** Test Step 95 : Verify created week day schedule for first user\n"); - err = TestVerifyCreatedWeekDayScheduleForFirstUser_95(); - break; - case 96: - ChipLogProgress(chipTool, " ***** Test Step 96 : Create Year Day schedule for first user\n"); - err = TestCreateYearDayScheduleForFirstUser_96(); - break; - case 97: - ChipLogProgress(chipTool, " ***** Test Step 97 : Verify created year day schedule for first\n"); - err = TestVerifyCreatedYearDayScheduleForFirst_97(); - break; - case 98: - ChipLogProgress(chipTool, " ***** Test Step 98 : Create Week Day schedule with valid parameters for second user\n"); - err = TestCreateWeekDayScheduleWithValidParametersForSecondUser_98(); - break; - case 99: - ChipLogProgress(chipTool, " ***** Test Step 99 : Verify created week day schedule for first user\n"); - err = TestVerifyCreatedWeekDayScheduleForFirstUser_99(); - break; - case 100: - ChipLogProgress(chipTool, " ***** Test Step 100 : Create Year Day schedule for second user\n"); - err = TestCreateYearDayScheduleForSecondUser_100(); - break; - case 101: - ChipLogProgress(chipTool, " ***** Test Step 101 : Verify created year day schedule for first\n"); - err = TestVerifyCreatedYearDayScheduleForFirst_101(); - break; - case 102: - ChipLogProgress(chipTool, " ***** Test Step 102 : Cleanup the user\n"); - err = TestCleanupTheUser_102(); - break; - case 103: - ChipLogProgress(chipTool, " ***** Test Step 103 : Make sure clearing first user also cleared week day schedules\n"); - err = TestMakeSureClearingFirstUserAlsoClearedWeekDaySchedules_103(); - break; - case 104: - ChipLogProgress(chipTool, " ***** Test Step 104 : Make sure clearing first user also cleared year day schedules\n"); - err = TestMakeSureClearingFirstUserAlsoClearedYearDaySchedules_104(); - break; - case 105: - ChipLogProgress(chipTool, " ***** Test Step 105 : Make sure clearing second user also cleared week day schedules\n"); - err = TestMakeSureClearingSecondUserAlsoClearedWeekDaySchedules_105(); - break; - case 106: - ChipLogProgress(chipTool, " ***** Test Step 106 : Make sure clearing second user also cleared year day schedules\n"); - err = TestMakeSureClearingSecondUserAlsoClearedYearDaySchedules_106(); - break; - case 107: - ChipLogProgress(chipTool, " ***** Test Step 107 : Make sure that first holiday schedule was not deleted\n"); - err = TestMakeSureThatFirstHolidayScheduleWasNotDeleted_107(); - break; - case 108: - ChipLogProgress(chipTool, " ***** Test Step 108 : Make sure that second holiday schedule was not deleted\n"); - err = TestMakeSureThatSecondHolidayScheduleWasNotDeleted_108(); - break; - case 109: - ChipLogProgress(chipTool, " ***** Test Step 109 : Create another Holiday schedule at the last slot\n"); - err = TestCreateAnotherHolidayScheduleAtTheLastSlot_109(); - break; - case 110: - ChipLogProgress(chipTool, " ***** Test Step 110 : Verify Created Holiday Schedule\n"); - err = TestVerifyCreatedHolidaySchedule_110(); - break; - case 111: - ChipLogProgress(chipTool, " ***** Test Step 111 : Create new PIN credential and schedule user\n"); - err = TestCreateNewPinCredentialAndScheduleUser_111(); - break; - case 112: - ChipLogProgress(chipTool, " ***** Test Step 112 : Create Week Day schedule for first user\n"); - err = TestCreateWeekDayScheduleForFirstUser_112(); - break; - case 113: - ChipLogProgress(chipTool, " ***** Test Step 113 : Create Year Day schedule for first user\n"); - err = TestCreateYearDayScheduleForFirstUser_113(); - break; - case 114: - ChipLogProgress(chipTool, " ***** Test Step 114 : Clear a single holiday schedule\n"); - err = TestClearASingleHolidaySchedule_114(); - break; - case 115: - ChipLogProgress(chipTool, " ***** Test Step 115 : Make sure that first holiday schedule was not deleted\n"); - err = TestMakeSureThatFirstHolidayScheduleWasNotDeleted_115(); - break; - case 116: - ChipLogProgress(chipTool, " ***** Test Step 116 : Make sure that second holiday schedule was deleted\n"); - err = TestMakeSureThatSecondHolidayScheduleWasDeleted_116(); - break; - case 117: - ChipLogProgress(chipTool, " ***** Test Step 117 : Make sure that third holiday schedule was not deleted\n"); - err = TestMakeSureThatThirdHolidayScheduleWasNotDeleted_117(); - break; - case 118: - ChipLogProgress(chipTool, " ***** Test Step 118 : Make sure clearing holiday schedule did not clear week day schedule\n"); - err = TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_118(); - break; - case 119: - ChipLogProgress(chipTool, " ***** Test Step 119 : Make sure clearing holiday schedule did not clear year day schedule\n"); - err = TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_119(); - break; - case 120: - ChipLogProgress(chipTool, " ***** Test Step 120 : Clear all remaining holiday schedules\n"); - err = TestClearAllRemainingHolidaySchedules_120(); - break; - case 121: - ChipLogProgress(chipTool, " ***** Test Step 121 : Make sure that first holiday is still deleted\n"); - err = TestMakeSureThatFirstHolidayIsStillDeleted_121(); - break; - case 122: - ChipLogProgress(chipTool, " ***** Test Step 122 : Make sure that second holiday schedule was deleted\n"); - err = TestMakeSureThatSecondHolidayScheduleWasDeleted_122(); - break; - case 123: - ChipLogProgress(chipTool, " ***** Test Step 123 : Make sure that third holiday schedule was not deleted\n"); - err = TestMakeSureThatThirdHolidayScheduleWasNotDeleted_123(); - break; - case 124: - ChipLogProgress(chipTool, " ***** Test Step 124 : Make sure clearing holiday schedule did not clear week day schedule\n"); - err = TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_124(); - break; - case 125: - ChipLogProgress(chipTool, " ***** Test Step 125 : Make sure clearing holiday schedule did not clear year day schedule\n"); - err = TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_125(); - break; - case 126: - ChipLogProgress(chipTool, " ***** Test Step 126 : Final Cleanup\n"); - err = TestFinalCleanup_126(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 78: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 79: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 80: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 81: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 82: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 83: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 84: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 85: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 86: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 87: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 88: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 89: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 90: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 91: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 92: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 93: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 94: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 95: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 96: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 97: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 98: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 99: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 100: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 101: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 102: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 103: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 104: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 105: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 106: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 107: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 108: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 109: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 110: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 111: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 112: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 113: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 114: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 115: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 116: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 117: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 118: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 119: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 120: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 121: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 122: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 123: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 124: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 125: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 126: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 127; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestCreateNewPinCredentialAndScheduleUser_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and schedule user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and schedule user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; - - CHIP_ERROR TestGetNumberOfSupportedUsers_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get number of supported users: Error: %@", err); - } else { - NSLog(@"Get number of supported users: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfTotalUsersSupported", actualValue, 10U)); - } - { - NumberOfTotalUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfWeekDaySchedulesSupportedPerUserValue; - - CHIP_ERROR TestGetMaxNumberOfWeekDaySchedulesForUserAndVerifyDefaultValue_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfWeekDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Max number of Week Day schedules for user and verify default value: Error: %@", err); - } else { - NSLog(@"Get Max number of Week Day schedules for user and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfWeekDaySchedulesSupportedPerUser", actualValue, 10U)); - } - { - NumberOfWeekDaySchedulesSupportedPerUserValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfYearDaySchedulesSupportedPerUserValue; - - CHIP_ERROR TestGetMaxNumberOfYearDaySchedulesForUserAndVerifyDefaultValue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfYearDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Max number of Year Day schedules for user and verify default value: Error: %@", err); - } else { - NSLog(@"Get Max number of Year Day schedules for user and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfYearDaySchedulesSupportedPerUser", actualValue, 10U)); - } - { - NumberOfYearDaySchedulesSupportedPerUserValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfHolidaySchedulesSupportedValue; - - CHIP_ERROR TestGetMaxNumberOfHolidaySchedulesAndVerifyDefaultValue_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfHolidaySchedulesSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Max number of Holiday schedules and verify default value: Error: %@", err); - } else { - NSLog(@"Get Max number of Holiday schedules and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfHolidaySchedulesSupported", actualValue, 10U)); - } - { - NumberOfHolidaySchedulesSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWith0Index_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithOutOfBoundsIndex_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWith0UserIndex_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithOutOfBoundsUserIndex_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleForNonExistingUser_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule for non-existing user: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule for non-existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWith0DaysMask_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:0U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with 0 days mask: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with 0 days mask: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleForSundayAndMonday_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:3U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule for Sunday and Monday: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule for Sunday and Monday: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleForSundayWednesdayAndSaturday_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:73U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule for Sunday Wednesday and Saturday: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule for Sunday Wednesday and Saturday: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithInvalidStartHour_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:24U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with invalid start hour: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with invalid start hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithInvalidStartMinute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:60U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with invalid start minute: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with invalid start minute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithInvalidEndHour_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:24U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with invalid end hour: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with invalid end hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithInvalidEndMinute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:60U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with invalid end minute: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with invalid end minute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithStartHourLaterThatEndHour_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:19U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with start hour later that end hour: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with start hour later that end hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithStartMinuteLaterThatEndMinuteWhenHoursAreEqual_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:50U]; - params.endHour = - [NSNumber numberWithUnsignedChar:15U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:49U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with start minute later that end minute when hours are equal: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with start minute later that end minute when hours are equal: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatPreviousOperationsDidNotCreateASchedule_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that previous operations did not create a schedule: Error: %@", err); - } else { - NSLog(@"Make sure that previous operations did not create a schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWith0Index_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWithOutOfBoundsIndex_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, [NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWith0UserIndex_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 0U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWithOutOfBoundsUserIndex_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, [NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWithNonExistingUserIndex_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with non-existing user index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with non-existing user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWith0Index_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWithOutOfBoundsIndex_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWith0UserIndex_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWithOutOfBoundsUserIndex_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleForNonExistingUser_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule for non-existing user: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule for non-existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWithStartHourLaterThatEndHour_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345688UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with start hour later that end hour: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with start hour later that end hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatPreviousOperationsDidNotCreateASchedule_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that previous operations did not create a schedule: Error: %@", err); - } else { - NSLog(@"Make sure that previous operations did not create a schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWith0Index_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWithOutOfBoundsIndex_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, [NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWith0UserIndex_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 0U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWithOutOfBoundsUserIndex_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, [NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWithNonExistingUserIndex_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with non-existing user index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with non-existing user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWith0Index_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWithOutOfBoundsIndex_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfHolidaySchedulesSupportedValue unsignedCharValue] + 1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWithStartHourLaterThatEndHour_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345688UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with start hour later that end hour: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with start hour later that end hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWithInvalidOperatingMode_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:5U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with invalid operating mode: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with invalid operating mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatPreviousOperationsDidNotCreateASchedule_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that previous operations did not create a schedule: Error: %@", err); - } else { - NSLog(@"Make sure that previous operations did not create a schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetHolidayScheduleWith0Index_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:0U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Holiday schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Get Holiday schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 0U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetHolidayScheduleWithOutOfBoundsIndex_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfHolidaySchedulesSupportedValue unsignedCharValue] + 1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Holiday schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Get Holiday schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, [NumberOfHolidaySchedulesSupportedValue unsignedCharValue] + 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWithValidParameters_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedSchedule_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created schedule: Error: %@", err); - } else { - NSLog(@"Verify created schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithValidParameters_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedSchedule_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created schedule: Error: %@", err); - } else { - NSLog(@"Verify created schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWithValidParameters_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedSchedule_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created schedule: Error: %@", err); - } else { - NSLog(@"Verify created schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWith0Index_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWithOutOfBoundsIndex_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWith0UserIndex_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWithOutOfBoundsUserIndex_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWithNonExistingUser_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with non-existing user: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with non-existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatWeekDayScheduleWasNotDeleted_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that week day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that week day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatYearDayScheduleWasNotDeleted_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatHolidayScheduleWasNotDeleted_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWith0Index_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWithOutOfBoundsIndex_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWith0UserIndex_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWithOutOfBoundsUserIndex_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWithNonExistingUser_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with non-existing user: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with non-existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatWeekDayScheduleWasNotDeleted_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that week day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that week day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatYearDayScheduleWasNotDeleted_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatHolidayScheduleWasNotDeleted_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearHolidayScheduleWith0Index_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:0U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Holiday schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Clear Holiday schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearHolidayScheduleWithOutOfBoundsIndex_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Holiday schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Clear Holiday schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatWeekDayScheduleWasNotDeleted_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that week day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that week day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatYearDayScheduleWasNotDeleted_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatHolidayScheduleWasNotDeleted_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherWeekDayScheduleWithValidParameters_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:2U]; - params.startHour = - [NSNumber numberWithUnsignedChar:0U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Week Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create another Week Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedWeekDaySchedule_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created week day schedule: Error: %@", err); - } else { - NSLog(@"Verify created week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 2U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherYearDayScheduleWithValidParameters_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:9000UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:888888888UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Year Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create another Year Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedYearDaySchedule_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created year day schedule: Error: %@", err); - } else { - NSLog(@"Verify created year day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherHolidayScheduleWithValidParameters_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:123456UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:1234567UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:1U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Holiday schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create another Holiday schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedHolidaySchedule_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created holiday schedule: Error: %@", err); - } else { - NSLog(@"Verify created holiday schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 123456UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1234567UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearASingleWeekDayScheduleForTheFirstUser_78() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear a single week day schedule for the first user: Error: %@", err); - } else { - NSLog(@"Clear a single week day schedule for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyClearedWeekDaySchedule_79() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify cleared week day schedule: Error: %@", err); - } else { - NSLog(@"Verify cleared week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllRemainingWeekDaySchedulesForTheFirstUser_80() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:254U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all remaining week day schedules for the first user: Error: %@", err); - } else { - NSLog(@"Clear all remaining week day schedules for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyClearedWeekSchedule_81() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify cleared week schedule: Error: %@", err); - } else { - NSLog(@"Verify cleared week schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstYearDayScheduleWasNotDeleted_82() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondYearDayScheduleWasNotDeleted_83() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstHolidayScheduleWasNotDeleted_84() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasNotDeleted_85() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 123456UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1234567UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherWeekDayScheduleWithValidParameters_86() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:2U]; - params.startHour = - [NSNumber numberWithUnsignedChar:0U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Week Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create another Week Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearASingleYearDayScheduleForTheFirstUser_87() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear a single year day schedule for the first user: Error: %@", err); - } else { - NSLog(@"Clear a single year day schedule for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyClearedYearDaySchedule_88() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify cleared year day schedule: Error: %@", err); - } else { - NSLog(@"Verify cleared year day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllRemainingYearSchedulesForTheFirstUser_89() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:254U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all remaining year schedules for the first user: Error: %@", err); - } else { - NSLog(@"Clear all remaining year schedules for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatSecondYearDayScheduleWasCleared_90() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that second year day schedule was cleared: Error: %@", err); - } else { - NSLog(@"Verify that second year day schedule was cleared: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedWeekDaySchedule_91() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created week day schedule: Error: %@", err); - } else { - NSLog(@"Verify created week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 2U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllRemainingWeekDaySchedulesForTheFirstUser_92() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:254U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all remaining week day schedules for the first user: Error: %@", err); - } else { - NSLog(@"Clear all remaining week day schedules for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewUserWithoutCredentialSoWeCanAddMoreSchedulesToIt_93() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new user without credential so we can add more schedules to it: Error: %@", err); - } else { - NSLog(@"Create new user without credential so we can add more schedules to it: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithValidParametersForFirstUser_94() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:0U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with valid parameters for first user: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with valid parameters for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedWeekDayScheduleForFirstUser_95() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created week day schedule for first user: Error: %@", err); - } else { - NSLog(@"Verify created week day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleForFirstUser_96() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:9000UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:888888888UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule for first user: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedYearDayScheduleForFirst_97() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created year day schedule for first: Error: %@", err); - } else { - NSLog(@"Verify created year day schedule for first: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 4U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithValidParametersForSecondUser_98() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:64U]; - params.startHour = - [NSNumber numberWithUnsignedChar:23U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with valid parameters for second user: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with valid parameters for second user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedWeekDayScheduleForFirstUser_99() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created week day schedule for first user: Error: %@", err); - } else { - NSLog(@"Verify created week day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 4U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 64U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 23U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleForSecondUser_100() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:55555UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:7777777UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule for second user: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule for second user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedYearDayScheduleForFirst_101() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created year day schedule for first: Error: %@", err); - } else { - NSLog(@"Verify created year day schedule for first: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 55555UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 7777777UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheUser_102() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the user: Error: %@", err); - } else { - NSLog(@"Cleanup the user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingFirstUserAlsoClearedWeekDaySchedules_103() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing first user also cleared week day schedules: Error: %@", err); - } else { - NSLog(@"Make sure clearing first user also cleared week day schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingFirstUserAlsoClearedYearDaySchedules_104() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing first user also cleared year day schedules: Error: %@", err); - } else { - NSLog(@"Make sure clearing first user also cleared year day schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 4U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingSecondUserAlsoClearedWeekDaySchedules_105() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing second user also cleared week day schedules: Error: %@", err); - } else { - NSLog(@"Make sure clearing second user also cleared week day schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 4U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingSecondUserAlsoClearedYearDaySchedules_106() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing second user also cleared year day schedules: Error: %@", err); - } else { - NSLog(@"Make sure clearing second user also cleared year day schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstHolidayScheduleWasNotDeleted_107() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasNotDeleted_108() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 123456UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1234567UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherHolidayScheduleAtTheLastSlot_109() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NumberOfHolidaySchedulesSupportedValue copy]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:1UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:100UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:4U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Holiday schedule at the last slot: Error: %@", err); - } else { - NSLog(@"Create another Holiday schedule at the last slot: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedHolidaySchedule_110() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NumberOfHolidaySchedulesSupportedValue copy]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Created Holiday Schedule: Error: %@", err); - } else { - NSLog(@"Verify Created Holiday Schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, NumberOfHolidaySchedulesSupportedValue)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 1UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 100UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndScheduleUser_111() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and schedule user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and schedule user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleForFirstUser_112() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:0U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule for first user: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleForFirstUser_113() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:9000UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:888888888UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule for first user: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearASingleHolidaySchedule_114() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear a single holiday schedule: Error: %@", err); - } else { - NSLog(@"Clear a single holiday schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstHolidayScheduleWasNotDeleted_115() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasDeleted_116() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second holiday schedule was deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second holiday schedule was deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatThirdHolidayScheduleWasNotDeleted_117() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NumberOfHolidaySchedulesSupportedValue copy]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that third holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that third holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, NumberOfHolidaySchedulesSupportedValue)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 1UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 100UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_118() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Error: %@", err); - } else { - NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_119() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Error: %@", err); - } else { - NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllRemainingHolidaySchedules_120() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:254U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all remaining holiday schedules: Error: %@", err); - } else { - NSLog(@"Clear all remaining holiday schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstHolidayIsStillDeleted_121() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first holiday is still deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first holiday is still deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasDeleted_122() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second holiday schedule was deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second holiday schedule was deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatThirdHolidayScheduleWasNotDeleted_123() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NumberOfHolidaySchedulesSupportedValue copy]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that third holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that third holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, NumberOfHolidaySchedulesSupportedValue)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_124() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Error: %@", err); - } else { - NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_125() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Error: %@", err); - } else { - NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestFinalCleanup_126() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Final Cleanup: Error: %@", err); - } else { - NSLog(@"Final Cleanup: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_1_1() - : TestCommandBridge("Test_TC_DRLK_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip(" !DRLK.S.F00 && !DRLK.S.F01 && !DRLK.S.F02 && !DRLK.S.F04 && !DRLK.S.F05 && !DRLK.S.F06 && !DRLK.S.F07 && !DRLK.S.F08 && !DRLK.S.F0a && !DRLK.S.F0b && !DRLK.S.F0c ")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DRLK.S.F00(PIN) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDrlksf00pinEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DRLK.S.F01(RID) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenDrlksf01ridEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given DRLK.S.F02(FGP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenDrlksf02fgpEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given DRLK.S.F04(WDSCH) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F04")) { - NextTest(); - return; - } - err = TestStep3eGivenDrlksf04wdschEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given DRLK.S.F05(DPS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F05")) { - NextTest(); - return; - } - err = TestStep3fGivenDrlksf05dpsEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given DRLK.S.F06(FACE) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F06")) { - NextTest(); - return; - } - err = TestStep3gGivenDrlksf06faceEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given DRLK.S.F07(COTA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F07")) { - NextTest(); - return; - } - err = TestStep3hGivenDrlksf07cotaEnsureFeaturemapHasTheCorrectBitSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given DRLK.S.F08(USR) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F08")) { - NextTest(); - return; - } - err = TestStep3iGivenDrlksf08usrEnsureFeaturemapHasTheCorrectBitSet_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given DRLK.S.F0a(YDSCH) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F0a")) { - NextTest(); - return; - } - err = TestStep3jGivenDRLKSF0aYDSCHEnsureFeaturemapHasTheCorrectBitSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given DRLK.S.F0b(HDSCH) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F0b")) { - NextTest(); - return; - } - err = TestStep3kGivenDRLKSF0bHDSCHEnsureFeaturemapHasTheCorrectBitSet_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given DRLK.S.F0c(UBOLT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F0c")) { - NextTest(); - return; - } - err = TestStep3lGivenDRLKSF0cUBOLTEnsureFeaturemapHasTheCorrectBitSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4b: TH reads Feature dependent(DRLK.S.F05) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F05")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentDRLKSF05AttributesInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4c: TH reads Feature dependent(DRLK.S.F08) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F08")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentDRLKSF08AttributesInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4d: TH reads Feature dependent(DRLK.S.F00) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsFeatureDependentDRLKSF00AttributesInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4e: TH reads Feature dependent(DRLK.S.F01) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F01")) { - NextTest(); - return; - } - err = TestStep4eThReadsFeatureDependentDRLKSF01AttributesInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4f: TH reads Feature dependent(DRLK.S.F04) attribute in AttributeList\n"); - if (ShouldSkip("DRLK.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsFeatureDependentDRLKSF04AttributeInAttributeList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4g: TH reads Feature dependent(DRLK.S.F0a) attribute in AttributeList\n"); - if (ShouldSkip("DRLK.S.F0a")) { - NextTest(); - return; - } - err = TestStep4gThReadsFeatureDependentDRLKSF0aAttributeInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4h: TH reads Feature dependent(DRLK.S.F0b) attribute in AttributeList\n"); - if (ShouldSkip("DRLK.S.F0b")) { - NextTest(); - return; - } - err = TestStep4hThReadsFeatureDependentDRLKSF0bAttributeInAttributeList_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4i: TH reads Feature dependent(DRLK.S.F00 or DRLK.S.F01) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F00 || DRLK.S.F01")) { - NextTest(); - return; - } - err = TestStep4iThReadsFeatureDependentDRLKSF00OrDrlksf01AttributesInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4j: TH reads Feature dependent(DRLK.S.F07 or DRLK.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("DRLK.S.F07 || DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep4jThReadsFeatureDependentDRLKSF07OrDrlksf00AttributeInAttributeList_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4k: TH reads optional attribute(Language) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0021")) { - NextTest(); - return; - } - err = TestStep4kThReadsOptionalAttributeLanguageInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4l: TH reads optional attribute(LEDSettings) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0022")) { - NextTest(); - return; - } - err = TestStep4lThReadsOptionalAttributeLEDSettingsInAttributeList_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4m: TH reads optional attribute(AutoRelockTime) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0023")) { - NextTest(); - return; - } - err = TestStep4mThReadsOptionalAttributeAutoRelockTimeInAttributeList_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4n: TH reads optional attribute(SoundVolume) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0024")) { - NextTest(); - return; - } - err = TestStep4nThReadsOptionalAttributeSoundVolumeInAttributeList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4o: TH reads optional attribute(DefaultConfigurationRegister) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0027")) { - NextTest(); - return; - } - err = TestStep4oThReadsOptionalAttributeDefaultConfigurationRegisterInAttributeList_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 4p: TH reads optional attribute(EnableLocalProgramming) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0028")) { - NextTest(); - return; - } - err = TestStep4pThReadsOptionalAttributeEnableLocalProgrammingInAttributeList_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4q: TH reads optional attribute(EnableOneTouchLocking) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0029")) { - NextTest(); - return; - } - err = TestStep4qThReadsOptionalAttributeEnableOneTouchLockingInAttributeList_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4r: TH reads optional attribute(EnableInsideStatusLED) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A002a")) { - NextTest(); - return; - } - err = TestStep4rThReadsOptionalAttributeEnableInsideStatusLEDInAttributeList_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 4s: TH reads optional attribute(EnablePrivacyModeButton) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A002b")) { - NextTest(); - return; - } - err = TestStep4sThReadsOptionalAttributeEnablePrivacyModeButtonInAttributeList_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4t: TH reads optional attribute(LocalProgrammingFeatures) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A002c")) { - NextTest(); - return; - } - err = TestStep4tThReadsOptionalAttributeLocalProgrammingFeaturesInAttributeList_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 5b: TH reads optional event(Door position sensor) in EventList\n"); - if (ShouldSkip("DRLK.S.F05 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 5c: TH reads optional event(User commands and database) in EventList\n"); - if (ShouldSkip("DRLK.S.F08 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 6a: TH reads AcceptedCommandList from DUT\n"); - err = TestStep6aThReadsAcceptedCommandListFromDut_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 6b: TH reads Feature dependent commands(DRLK.S.F04) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F04")) { - NextTest(); - return; - } - err = TestStep6bThReadsFeatureDependentCommandsDRLKSF04InAcceptedCommandList_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 6c: TH reads Feature dependent commands(DRLK.S.F0a) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F0a")) { - NextTest(); - return; - } - err = TestStep6cThReadsFeatureDependentCommandsDRLKSF0aInAcceptedCommandList_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 6d: TH reads Feature dependent commands(DRLK.S.F0b) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F0b")) { - NextTest(); - return; - } - err = TestStep6dThReadsFeatureDependentCommandsDRLKSF0bInAcceptedCommandList_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 6e: TH reads Feature dependent commands(DRLK.S.F0c) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F0c")) { - NextTest(); - return; - } - err = TestStep6eThReadsFeatureDependentCommandsDRLKSF0cInAcceptedCommandList_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 6f: TH reads Feature dependent commands(DRLK.S.F08) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F08")) { - NextTest(); - return; - } - err = TestStep6fThReadsFeatureDependentCommandsDRLKSF08InAcceptedCommandList_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 6g: TH reads optional commands(DRLK.S.C03.Rsp) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6gThReadsOptionalCommandsDRLKSC03RspInAcceptedCommandList_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 7a: TH reads Feature dependent command(DRLK.S.F04) in GeneratedCommandList\n"); - if (ShouldSkip("DRLK.S.F04")) { - NextTest(); - return; - } - err = TestStep7aThReadsFeatureDependentCommandDRLKSF04InGeneratedCommandList_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 7b: TH reads Feature dependent command(DRLK.S.F0a) in GeneratedCommandList\n"); - if (ShouldSkip("DRLK.S.F0a")) { - NextTest(); - return; - } - err = TestStep7bThReadsFeatureDependentCommandDRLKSF0aInGeneratedCommandList_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 7c: TH reads Feature dependent command(DRLK.S.F0b) in GeneratedCommandList\n"); - if (ShouldSkip("DRLK.S.F0b")) { - NextTest(); - return; - } - err = TestStep7cThReadsFeatureDependentCommandDRLKSF0bInGeneratedCommandList_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 7d: TH reads Feature dependent command(DRLK.S.F08) in GeneratedCommandList\n"); - if (ShouldSkip("DRLK.S.F08")) { - NextTest(); - return; - } - err = TestStep7dThReadsFeatureDependentCommandDRLKSF08InGeneratedCommandList_48(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 49; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 7U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDrlksf00pinEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DRLK.S.F00(PIN) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DRLK.S.F00(PIN) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenDrlksf01ridEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given DRLK.S.F01(RID) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given DRLK.S.F01(RID) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenDrlksf02fgpEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given DRLK.S.F02(FGP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given DRLK.S.F02(FGP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenDrlksf04wdschEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given DRLK.S.F04(WDSCH) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given DRLK.S.F04(WDSCH) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenDrlksf05dpsEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given DRLK.S.F05(DPS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given DRLK.S.F05(DPS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenDrlksf06faceEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given DRLK.S.F06(FACE) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given DRLK.S.F06(FACE) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenDrlksf07cotaEnsureFeaturemapHasTheCorrectBitSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given DRLK.S.F07(COTA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given DRLK.S.F07(COTA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenDrlksf08usrEnsureFeaturemapHasTheCorrectBitSet_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given DRLK.S.F08(USR) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3i: Given DRLK.S.F08(USR) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenDRLKSF0aYDSCHEnsureFeaturemapHasTheCorrectBitSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given DRLK.S.F0a(YDSCH) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given DRLK.S.F0a(YDSCH) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenDRLKSF0bHDSCHEnsureFeaturemapHasTheCorrectBitSet_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given DRLK.S.F0b(HDSCH) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3k: Given DRLK.S.F0b(HDSCH) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenDRLKSF0cUBOLTEnsureFeaturemapHasTheCorrectBitSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given DRLK.S.F0c(UBOLT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given DRLK.S.F0c(UBOLT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentDRLKSF05AttributesInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent(DRLK.S.F05) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent(DRLK.S.F05) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentDRLKSF08AttributesInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads Feature dependent(DRLK.S.F08) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads Feature dependent(DRLK.S.F08) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsFeatureDependentDRLKSF00AttributesInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads Feature dependent(DRLK.S.F00) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads Feature dependent(DRLK.S.F00) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 24UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsFeatureDependentDRLKSF01AttributesInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads Feature dependent(DRLK.S.F01) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads Feature dependent(DRLK.S.F01) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsFeatureDependentDRLKSF04AttributeInAttributeList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads Feature dependent(DRLK.S.F04) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads Feature dependent(DRLK.S.F04) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsFeatureDependentDRLKSF0aAttributeInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads Feature dependent(DRLK.S.F0a) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads Feature dependent(DRLK.S.F0a) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsFeatureDependentDRLKSF0bAttributeInAttributeList_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads Feature dependent(DRLK.S.F0b) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads Feature dependent(DRLK.S.F0b) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsFeatureDependentDRLKSF00OrDrlksf01AttributesInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads Feature dependent(DRLK.S.F00 or DRLK.S.F01) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads Feature dependent(DRLK.S.F00 or DRLK.S.F01) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsFeatureDependentDRLKSF07OrDrlksf00AttributeInAttributeList_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads Feature dependent(DRLK.S.F07 or DRLK.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads Feature dependent(DRLK.S.F07 or DRLK.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 51UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsOptionalAttributeLanguageInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH reads optional attribute(Language) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: TH reads optional attribute(Language) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsOptionalAttributeLEDSettingsInAttributeList_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: TH reads optional attribute(LEDSettings) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: TH reads optional attribute(LEDSettings) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsOptionalAttributeAutoRelockTimeInAttributeList_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: TH reads optional attribute(AutoRelockTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4m: TH reads optional attribute(AutoRelockTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 35UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsOptionalAttributeSoundVolumeInAttributeList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: TH reads optional attribute(SoundVolume) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4n: TH reads optional attribute(SoundVolume) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsOptionalAttributeDefaultConfigurationRegisterInAttributeList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: TH reads optional attribute(DefaultConfigurationRegister) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4o: TH reads optional attribute(DefaultConfigurationRegister) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 39UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsOptionalAttributeEnableLocalProgrammingInAttributeList_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4p: TH reads optional attribute(EnableLocalProgramming) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4p: TH reads optional attribute(EnableLocalProgramming) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 40UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qThReadsOptionalAttributeEnableOneTouchLockingInAttributeList_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4q: TH reads optional attribute(EnableOneTouchLocking) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4q: TH reads optional attribute(EnableOneTouchLocking) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4rThReadsOptionalAttributeEnableInsideStatusLEDInAttributeList_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4r: TH reads optional attribute(EnableInsideStatusLED) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4r: TH reads optional attribute(EnableInsideStatusLED) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 42UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4sThReadsOptionalAttributeEnablePrivacyModeButtonInAttributeList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4s: TH reads optional attribute(EnablePrivacyModeButton) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4s: TH reads optional attribute(EnablePrivacyModeButton) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 43UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4tThReadsOptionalAttributeLocalProgrammingFeaturesInAttributeList_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4t: TH reads optional attribute(LocalProgrammingFeatures) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4t: TH reads optional attribute(LocalProgrammingFeatures) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 44UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsAcceptedCommandListFromDut_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFeatureDependentCommandsDRLKSF04InAcceptedCommandList_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads Feature dependent commands(DRLK.S.F04) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads Feature dependent commands(DRLK.S.F04) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 11UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 12UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 13UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsFeatureDependentCommandsDRLKSF0aInAcceptedCommandList_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads Feature dependent commands(DRLK.S.F0a) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads Feature dependent commands(DRLK.S.F0a) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 14UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsFeatureDependentCommandsDRLKSF0bInAcceptedCommandList_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads Feature dependent commands(DRLK.S.F0b) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads Feature dependent commands(DRLK.S.F0b) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eThReadsFeatureDependentCommandsDRLKSF0cInAcceptedCommandList_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: TH reads Feature dependent commands(DRLK.S.F0c) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6e: TH reads Feature dependent commands(DRLK.S.F0c) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 39UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fThReadsFeatureDependentCommandsDRLKSF08InAcceptedCommandList_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: TH reads Feature dependent commands(DRLK.S.F08) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6f: TH reads Feature dependent commands(DRLK.S.F08) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 26UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 29UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 34UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 36UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 38UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gThReadsOptionalCommandsDRLKSC03RspInAcceptedCommandList_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6g: TH reads optional commands(DRLK.S.C03.Rsp) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6g: TH reads optional commands(DRLK.S.C03.Rsp) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThReadsFeatureDependentCommandDRLKSF04InGeneratedCommandList_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH reads Feature dependent command(DRLK.S.F04) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7a: TH reads Feature dependent command(DRLK.S.F04) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bThReadsFeatureDependentCommandDRLKSF0aInGeneratedCommandList_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH reads Feature dependent command(DRLK.S.F0a) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7b: TH reads Feature dependent command(DRLK.S.F0a) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 15UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7cThReadsFeatureDependentCommandDRLKSF0bInGeneratedCommandList_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7c: TH reads Feature dependent command(DRLK.S.F0b) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7c: TH reads Feature dependent command(DRLK.S.F0b) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7dThReadsFeatureDependentCommandDRLKSF08InGeneratedCommandList_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7d: TH reads Feature dependent command(DRLK.S.F08) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7d: TH reads Feature dependent command(DRLK.S.F08) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 28UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 35UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 37UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_4() - : TestCommandBridge("Test_TC_DRLK_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Create new user\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestCreateNewUser_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read the user back and verify its fields\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestReadTheUserBackAndVerifyItsFields_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Create new PIN credential and lock/unlock user\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestCreateNewPinCredentialAndLockUnlockUser_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify created PIN credential\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestVerifyCreatedPinCredential_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); - if (ShouldSkip("DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep1aThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); - if (ShouldSkip("DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep1bThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY && !DRLK.S.M.AutoRelockTimeAttributeWritable")) { - NextTest(); - return; - } - err = TestStep1cThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && !DRLK.S.M.AutoRelockTimeAttributeWritable")) { - NextTest(); - return; - } - err = TestStep1dThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds\n"); - if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep2aThSendsTheUnlockWithTimeoutArgumentValueAs10Seconds_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds\n"); - if (ShouldSkip(" DRLK.S.F08 && DRLK.S.F00 && DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP ")) { - NextTest(); - return; - } - err = TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds\n"); - if (ShouldSkip(" (!DRLK.S.F08 || !DRLK.S.F00) && DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP ")) { - NextTest(); - return; - } - err = TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for AutoRelockTime Expires\n"); - if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestWaitForAutoRelockTimeExpires_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for AutoRelockTime Expires\n"); - if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestWaitForAutoRelockTimeExpires_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2c: TH reads LockState attribute\n"); - if (ShouldSkip("DRLK.S.A0000 && DRLK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsLockStateAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Cleanup the created user\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestCleanupTheCreatedUser_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Clean the created credential\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestCleanTheCreatedCredential_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestCreateNewUser_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new user: Error: %@", err); - } else { - NSLog(@"Create new user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserBackAndVerifyItsFields_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndLockUnlockUser_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and lock/unlock user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and lock/unlock user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedPinCredential_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created PIN credential: Error: %@", err); - } else { - NSLog(@"Verify created PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id autoRelockTimeArgument; - autoRelockTimeArgument = - [NSNumber numberWithUnsignedInt:10UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id autoRelockTimeArgument; - autoRelockTimeArgument = - [NSNumber numberWithUnsignedInt:60UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id autoRelockTimeArgument; - autoRelockTimeArgument = - [NSNumber numberWithUnsignedInt:10UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id autoRelockTimeArgument; - autoRelockTimeArgument = - [NSNumber numberWithUnsignedInt:60UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsTheUnlockWithTimeoutArgumentValueAs10Seconds_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; - params.timeout = - [NSNumber numberWithUnsignedShort:10U]; - params.pinCode = - [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster unlockWithTimeoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; - params.timeout = - [NSNumber numberWithUnsignedShort:60U]; - params.pinCode = - [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster unlockWithTimeoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; - params.timeout = - [NSNumber numberWithUnsignedShort:60U]; - [cluster unlockWithTimeoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitForAutoRelockTimeExpires_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 11000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestWaitForAutoRelockTimeExpires_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 70000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsLockStateAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLockStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads LockState attribute: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads LockState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LockState", actualValue)); - VerifyOrReturn(CheckValue("LockState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUser_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user: Error: %@", err); - } else { - NSLog(@"Cleanup the created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanTheCreatedCredential_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clean the created credential: Error: %@", err); - } else { - NSLog(@"Clean the created credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_5() - : TestCommandBridge("Test_TC_DRLK_2_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user\n"); - err = TestPreconditionCreateNewUser_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); - err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute and saves for future use\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.A0014")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfWeekDaySchedulesSupportedPerUserAttributeAndSavesForFutureUse_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads NumberOfTotalUsers Supported attribute and saves for future use\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep2ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH send Set Week Day Schedule Command to DUT with the following values : a)WeekDayIndex as 1 b)UserIndex as 1 c)DaysMaskMap as 2 d)StartHour as 15 e)StartMinute as 45 f)EndHour as 16 g)EndMinute as 55 \n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendSetWeekDayScheduleCommandToDutWithTheFollowingValuesAWeekDayIndexAs1BUserIndexAs1CDaysMaskMapAs2DStartHourAs15EStartMinuteAs45FEndHourAs16GEndMinuteAs55_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH send Get Week Day Schedule Command to DUT with a)WeekDayIndex as 1 b)UserIndex as 1 \n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { - NextTest(); - return; - } - err = TestStep4ThSendGetWeekDayScheduleCommandToDutWithAWeekDayIndexAs1BUserIndexAs1_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH send Set Week Day Schedule Command to DUT with the following values : a)WeekDayIndex as 0 (invalid value) b)UserIndex as 1 c)DaysMaskMap as 7 (invalid value) d)StartHour as 15 e)StartMinute as 45 f)EndHour as 16 g)EndMinute as 55\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendSetWeekDayScheduleCommandToDutWithTheFollowingValuesAWeekDayIndexAs0InvalidValueBUserIndexAs1CDaysMaskMapAs7InvalidValueDStartHourAs15EStartMinuteAs45FEndHourAs16GEndMinuteAs55_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH send Get Week Day Schedule Command to DUT : a)WeekDayIndex as 0 b)UserIndex as 1 \n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { - NextTest(); - return; - } - err = TestStep6ThSendGetWeekDayScheduleCommandToDutAWeekDayIndexAs0BUserIndexAs1_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH sends Get Week Day Schedule Command to DUT with following values: a)WeekDayIndex as 1 (index of existing Schedule entry) b)UserIndex as 2 (index on non-existent User)\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { - NextTest(); - return; - } - err = TestStep7ThSendsGetWeekDayScheduleCommandToDutWithFollowingValuesAWeekDayIndexAs1IndexOfExistingScheduleEntryBUserIndexAs2IndexOnNonExistentUser_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 8: TH sends Clear Week Day Schedule Command to DUT with : a)WeekDayIndex as 1 b)UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0d.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsClearWeekDayScheduleCommandToDutWithAWeekDayIndexAs1BUserIndexAs1_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 9: TH sends Get Week Day Schedule Command to DUT with following values: a)WeekDayIndex as 1 b)UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { - NextTest(); - return; - } - err = TestStep9ThSendsGetWeekDayScheduleCommandToDutWithFollowingValuesAWeekDayIndexAs1BUserIndexAs1_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Cleanup the created user\n"); - err = TestCleanupTheCreatedUser_12(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionCreateNewUser_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Create new user: Error: %@", err); - } else { - NSLog(@"Precondition: Create new user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Precondition: Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfWeekDaySchedulesSupportedPerUserValue; - - CHIP_ERROR TestStep1ThReadsNumberOfWeekDaySchedulesSupportedPerUserAttributeAndSavesForFutureUse_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfWeekDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute and saves for future use: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute and saves for future use: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfWeekDaySchedulesSupportedPerUser", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfWeekDaySchedulesSupportedPerUser", [value unsignedCharValue], 255U)); - { - NumberOfWeekDaySchedulesSupportedPerUserValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; - - CHIP_ERROR TestStep2ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute and saves for future use: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute and saves for future use: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); - { - NumberOfTotalUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendSetWeekDayScheduleCommandToDutWithTheFollowingValuesAWeekDayIndexAs1BUserIndexAs1CDaysMaskMapAs2DStartHourAs15EStartMinuteAs45FEndHourAs16GEndMinuteAs55_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:2U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:45U]; - params.endHour = - [NSNumber numberWithUnsignedChar:16U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:55U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH send Set Week Day Schedule Command to DUT with the following values : a)WeekDayIndex as 1 b)UserIndex as 1 c)DaysMaskMap as 2 d)StartHour as 15 e)StartMinute as 45 f)EndHour as 16 g)EndMinute as 55 : Error: %@", err); - } else { - NSLog(@"Step 3: TH send Set Week Day Schedule Command to DUT with the following values : a)WeekDayIndex as 1 b)UserIndex as 1 c)DaysMaskMap as 2 d)StartHour as 15 e)StartMinute as 45 f)EndHour as 16 g)EndMinute as 55 : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendGetWeekDayScheduleCommandToDutWithAWeekDayIndexAs1BUserIndexAs1_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH send Get Week Day Schedule Command to DUT with a)WeekDayIndex as 1 b)UserIndex as 1 : Error: %@", err); - } else { - NSLog(@"Step 4: TH send Get Week Day Schedule Command to DUT with a)WeekDayIndex as 1 b)UserIndex as 1 : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 2U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 45U)); - } - - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, true)); - if (values.endHour != nil) { - - VerifyOrReturn(CheckConstraintMinValue("endHour", [values.endHour unsignedCharValue], 16U)); - } - - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, true)); - if (values.endMinute != nil) { - - VerifyOrReturn(CheckConstraintMinValue("endMinute", [values.endMinute unsignedCharValue], 55U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendSetWeekDayScheduleCommandToDutWithTheFollowingValuesAWeekDayIndexAs0InvalidValueBUserIndexAs1CDaysMaskMapAs7InvalidValueDStartHourAs15EStartMinuteAs45FEndHourAs16GEndMinuteAs55_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:7U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:45U]; - params.endHour = - [NSNumber numberWithUnsignedChar:16U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:55U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH send Set Week Day Schedule Command to DUT with the following values : a)WeekDayIndex as 0 (invalid value) b)UserIndex as 1 c)DaysMaskMap as 7 (invalid value) d)StartHour as 15 e)StartMinute as 45 f)EndHour as 16 g)EndMinute as 55: Error: %@", err); - } else { - NSLog(@"Step 5: TH send Set Week Day Schedule Command to DUT with the following values : a)WeekDayIndex as 0 (invalid value) b)UserIndex as 1 c)DaysMaskMap as 7 (invalid value) d)StartHour as 15 e)StartMinute as 45 f)EndHour as 16 g)EndMinute as 55: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendGetWeekDayScheduleCommandToDutAWeekDayIndexAs0BUserIndexAs1_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH send Get Week Day Schedule Command to DUT : a)WeekDayIndex as 0 b)UserIndex as 1 : Error: %@", err); - } else { - NSLog(@"Step 6: TH send Get Week Day Schedule Command to DUT : a)WeekDayIndex as 0 b)UserIndex as 1 : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); - if (values.daysMask != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); - if (values.startHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); - if (values.startMinute != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); - if (values.endHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); - if (values.endMinute != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsGetWeekDayScheduleCommandToDutWithFollowingValuesAWeekDayIndexAs1IndexOfExistingScheduleEntryBUserIndexAs2IndexOnNonExistentUser_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends Get Week Day Schedule Command to DUT with following values: a)WeekDayIndex as 1 (index of existing Schedule entry) b)UserIndex as 2 (index on non-existent User): Error: %@", err); - } else { - NSLog(@"Step 7: TH sends Get Week Day Schedule Command to DUT with following values: a)WeekDayIndex as 1 (index of existing Schedule entry) b)UserIndex as 2 (index on non-existent User): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); - if (values.daysMask != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); - if (values.startHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); - if (values.startMinute != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); - if (values.endHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); - if (values.endMinute != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsClearWeekDayScheduleCommandToDutWithAWeekDayIndexAs1BUserIndexAs1_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends Clear Week Day Schedule Command to DUT with : a)WeekDayIndex as 1 b)UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends Clear Week Day Schedule Command to DUT with : a)WeekDayIndex as 1 b)UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsGetWeekDayScheduleCommandToDutWithFollowingValuesAWeekDayIndexAs1BUserIndexAs1_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends Get Week Day Schedule Command to DUT with following values: a)WeekDayIndex as 1 b)UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends Get Week Day Schedule Command to DUT with following values: a)WeekDayIndex as 1 b)UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); - if (values.daysMask != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); - if (values.startHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); - if (values.startMinute != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); - if (values.endHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); - if (values.endMinute != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUser_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user: Error: %@", err); - } else { - NSLog(@"Cleanup the created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_6 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_6() - : TestCommandBridge("Test_TC_DRLK_2_6") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_6() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_6\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_6\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for commissionee\n"); - err = TestWaitForCommissionee_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.A0016")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfHolidaySchedulesSupportedAndSavesForFutureUse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 Seconds c)LocalEndTime as 30 Seconds d)OperatingMode as 0\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C11.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20SecondsCLocalEndTimeAs30SecondsDOperatingModeAs0_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep3aThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 c)LocalEndTime as 30 d)OperatingMode as 5(Invalid value)\n"); - if (ShouldSkip("DRLK.S.C11.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20CLocalEndTimeAs30DOperatingModeAs5InvalidValue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends Get Holiday Schedule Command to DUT with Invalid HolidayIndex as 15\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep5ThSendsGetHolidayScheduleCommandToDutWithInvalidHolidayIndexAs15_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH sends Get Holiday Schedule Command to DUT with the HolidayIndex as 10 (value is in the the range of step 1 but Holiday Schedule entry not available)\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep6ThSendsGetHolidayScheduleCommandToDutWithTheHolidayIndexAs10ValueIsInTheTheRangeOfStep1ButHolidayScheduleEntryNotAvailable_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH send Clear Holiday Schedule Command to DUT with HolidayIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C13.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendClearHolidayScheduleCommandToDutWithHolidayIndexAs1_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep8ThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Cleanup the created user\n"); - err = TestCleanupTheCreatedUser_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForCommissionee_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull NumberOfHolidaySchedulesSupportedValue; - - CHIP_ERROR TestStep1ThReadsNumberOfHolidaySchedulesSupportedAndSavesForFutureUse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfHolidaySchedulesSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfHolidaySchedulesSupported", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfHolidaySchedulesSupported", [value unsignedCharValue], 255U)); - { - NumberOfHolidaySchedulesSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20SecondsCLocalEndTimeAs30SecondsDOperatingModeAs0_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:20UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:30UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 Seconds c)LocalEndTime as 30 Seconds d)OperatingMode as 0: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 Seconds c)LocalEndTime as 30 Seconds d)OperatingMode as 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 20UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 30UL)); - } - - if (values.localEndTime != nil) { - - VerifyOrReturn(CheckConstraintMinValue("localEndTime", [values.localEndTime unsignedIntValue], 21UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20CLocalEndTimeAs30DOperatingModeAs5InvalidValue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:20UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:30UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:5U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 c)LocalEndTime as 30 d)OperatingMode as 5(Invalid value): Error: %@", err); - } else { - NSLog(@"Step 4: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 c)LocalEndTime as 30 d)OperatingMode as 5(Invalid value): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsGetHolidayScheduleCommandToDutWithInvalidHolidayIndexAs15_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:15U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends Get Holiday Schedule Command to DUT with Invalid HolidayIndex as 15: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends Get Holiday Schedule Command to DUT with Invalid HolidayIndex as 15: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 15U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsGetHolidayScheduleCommandToDutWithTheHolidayIndexAs10ValueIsInTheTheRangeOfStep1ButHolidayScheduleEntryNotAvailable_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:10U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends Get Holiday Schedule Command to DUT with the HolidayIndex as 10 (value is in the the range of step 1 but Holiday Schedule entry not available): Error: %@", err); - } else { - NSLog(@"Step 6: TH sends Get Holiday Schedule Command to DUT with the HolidayIndex as 10 (value is in the the range of step 1 but Holiday Schedule entry not available): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 10U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendClearHolidayScheduleCommandToDutWithHolidayIndexAs1_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH send Clear Holiday Schedule Command to DUT with HolidayIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 7: TH send Clear Holiday Schedule Command to DUT with HolidayIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUser_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user: Error: %@", err); - } else { - NSLog(@"Cleanup the created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_7 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_7() - : TestCommandBridge("Test_TC_DRLK_2_7") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_7() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_7\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_7\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user\n"); - err = TestPreconditionCreateNewUser_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); - err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute and saves for future use\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.A0015")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfYearDaySchedulesSupportedPerUserAttributeAndSavesForFutureUse_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads NumberOfTotalUsers Supported attribute and saves for future use\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep2ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH sends Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1 c)LocalStartTime as 960 Seconds d)LocalEndTime as 1980 Seconds\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0e.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsSetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs1BUserIndexAs1CLocalStartTimeAs960SecondsDLocalEndTimeAs1980Seconds_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep4a4bThSendsGetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs1BUserIndexAs1_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH send Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 0(Invalid value) b)UserIndex as 15(Invalid value) c)LocalStartTime as 1020 d)LocalEndTime as 2040\n"); - if (ShouldSkip("DRLK.S.C0e.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendSetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs0InvalidValueBUserIndexAs15InvalidValueCLocalStartTimeAs1020DLocalEndTimeAs2040_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH sends Get Year Day Schedule Command to DUT with : a)YearDayIndex as 0 b)UserIndex as 15\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep6ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs0BUserIndexAs15_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7a: Create a new user with UserIndex as 5 then TH sends Get Year Day Schedule Command to DUT with\n"); - err = TestStep7aCreateANewUserWithUserIndexAs5ThenThSendsGetYearDayScheduleCommandToDutWith_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7b: YearDayIndex as 10 (value is in the the range of step 1 but YearDay Schedule entry not available) : UserIndex as 5\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep7bYearDayIndexAs10ValueIsInTheTheRangeOfStep1ButYearDayScheduleEntryNotAvailableUserIndexAs5_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 8: TH sends Clear Year Day Schedule to DUT with a)YearDayIndex as 1 b)UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsClearYearDayScheduleToDutWithAYearDayIndexAs1BUserIndexAs1_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 9: TH sends Get Year Day Schedule Command to DUT with a)YearDayIndex as 1 (value is in the the range of step 1 but YearDay Schedule entry not available) b)UserDayIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx && DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs1ValueIsInTheTheRangeOfStep1ButYearDayScheduleEntryNotAvailableBUserDayIndexAs1_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 10: TH sends Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1 c)LocalStartTime as 1080 Seconds d)LocalEndTime as 2100 Seconds\n"); - if (ShouldSkip("DRLK.S.C0e.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThSendsSetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs1BUserIndexAs1CLocalStartTimeAs1080SecondsDLocalEndTimeAs2100Seconds_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 11: TH sends Get Year Day Schedule Command to DUT with : a)YearDayIndex as 1 b)UserDayIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep11ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs1BUserDayIndexAs1_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 12: TH sends Get Year Day Schedule Command to DUT with a)YearDayIndex as 1 (index of existing Schedule entry) b)UserIndex as 2 (index on non-existent User)\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep12ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs1IndexOfExistingScheduleEntryBUserIndexAs2IndexOnNonExistentUser_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 13: TH sends Clear Year Day Schedule to DUT with a)YearDayIndex as 0(Invalid value) b)UserIndex as 0 (Invalid value)\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsClearYearDayScheduleToDutWithAYearDayIndexAs0InvalidValueBUserIndexAs0InvalidValue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Clear a year day schedule for the first user\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestClearAYearDayScheduleForTheFirstUser_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Cleanup the created user with UserIndex 1\n"); - err = TestCleanupTheCreatedUserWithUserIndex1_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Cleanup the created user with UserIndex 5\n"); - err = TestCleanupTheCreatedUserWithUserIndex5_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionCreateNewUser_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Create new user: Error: %@", err); - } else { - NSLog(@"Precondition: Create new user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Precondition: Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfYearDaySchedulesSupportedPerUserValue; - - CHIP_ERROR TestStep1ThReadsNumberOfYearDaySchedulesSupportedPerUserAttributeAndSavesForFutureUse_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfYearDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute and saves for future use: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute and saves for future use: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfYearDaySchedulesSupportedPerUser", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfYearDaySchedulesSupportedPerUser", [value unsignedCharValue], 255U)); - { - NumberOfYearDaySchedulesSupportedPerUserValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; - - CHIP_ERROR TestStep2ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute and saves for future use: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute and saves for future use: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); - { - NumberOfTotalUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsSetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs1BUserIndexAs1CLocalStartTimeAs960SecondsDLocalEndTimeAs1980Seconds_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:960UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:1980UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1 c)LocalStartTime as 960 Seconds d)LocalEndTime as 1980 Seconds: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1 c)LocalStartTime as 960 Seconds d)LocalEndTime as 1980 Seconds: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a4bThSendsGetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs1BUserIndexAs1_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 960UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1980UL)); - } - - if (values.localEndTime != nil) { - - VerifyOrReturn(CheckConstraintMinValue("localEndTime", [values.localEndTime unsignedIntValue], 961UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendSetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs0InvalidValueBUserIndexAs15InvalidValueCLocalStartTimeAs1020DLocalEndTimeAs2040_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:15U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:1020UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:2040UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH send Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 0(Invalid value) b)UserIndex as 15(Invalid value) c)LocalStartTime as 1020 d)LocalEndTime as 2040: Error: %@", err); - } else { - NSLog(@"Step 5: TH send Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 0(Invalid value) b)UserIndex as 15(Invalid value) c)LocalStartTime as 1020 d)LocalEndTime as 2040: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs0BUserIndexAs15_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:15U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends Get Year Day Schedule Command to DUT with : a)YearDayIndex as 0 b)UserIndex as 15: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends Get Year Day Schedule Command to DUT with : a)YearDayIndex as 0 b)UserIndex as 15: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 15U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aCreateANewUserWithUserIndexAs5ThenThSendsGetYearDayScheduleCommandToDutWith_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:5U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: Create a new user with UserIndex as 5 then TH sends Get Year Day Schedule Command to DUT with: Error: %@", err); - } else { - NSLog(@"Step 7a: Create a new user with UserIndex as 5 then TH sends Get Year Day Schedule Command to DUT with: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bYearDayIndexAs10ValueIsInTheTheRangeOfStep1ButYearDayScheduleEntryNotAvailableUserIndexAs5_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NumberOfYearDaySchedulesSupportedPerUserValue copy]; - params.userIndex = - [NSNumber numberWithUnsignedShort:5U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: YearDayIndex as 10 (value is in the the range of step 1 but YearDay Schedule entry not available) : UserIndex as 5: Error: %@", err); - } else { - NSLog(@"Step 7b: YearDayIndex as 10 (value is in the the range of step 1 but YearDay Schedule entry not available) : UserIndex as 5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, NumberOfYearDaySchedulesSupportedPerUserValue)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 5U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsClearYearDayScheduleToDutWithAYearDayIndexAs1BUserIndexAs1_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends Clear Year Day Schedule to DUT with a)YearDayIndex as 1 b)UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends Clear Year Day Schedule to DUT with a)YearDayIndex as 1 b)UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs1ValueIsInTheTheRangeOfStep1ButYearDayScheduleEntryNotAvailableBUserDayIndexAs1_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends Get Year Day Schedule Command to DUT with a)YearDayIndex as 1 (value is in the the range of step 1 but YearDay Schedule entry not available) b)UserDayIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends Get Year Day Schedule Command to DUT with a)YearDayIndex as 1 (value is in the the range of step 1 but YearDay Schedule entry not available) b)UserDayIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThSendsSetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs1BUserIndexAs1CLocalStartTimeAs1080SecondsDLocalEndTimeAs2100Seconds_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:1080UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:2100UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1 c)LocalStartTime as 1080 Seconds d)LocalEndTime as 2100 Seconds: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1 c)LocalStartTime as 1080 Seconds d)LocalEndTime as 2100 Seconds: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs1BUserDayIndexAs1_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends Get Year Day Schedule Command to DUT with : a)YearDayIndex as 1 b)UserDayIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends Get Year Day Schedule Command to DUT with : a)YearDayIndex as 1 b)UserDayIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 1080UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 2100UL)); - } - - if (values.localEndTime != nil) { - - VerifyOrReturn(CheckConstraintMinValue("localEndTime", [values.localEndTime unsignedIntValue], 1081UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs1IndexOfExistingScheduleEntryBUserIndexAs2IndexOnNonExistentUser_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH sends Get Year Day Schedule Command to DUT with a)YearDayIndex as 1 (index of existing Schedule entry) b)UserIndex as 2 (index on non-existent User): Error: %@", err); - } else { - NSLog(@"Step 12: TH sends Get Year Day Schedule Command to DUT with a)YearDayIndex as 1 (index of existing Schedule entry) b)UserIndex as 2 (index on non-existent User): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThSendsClearYearDayScheduleToDutWithAYearDayIndexAs0InvalidValueBUserIndexAs0InvalidValue_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends Clear Year Day Schedule to DUT with a)YearDayIndex as 0(Invalid value) b)UserIndex as 0 (Invalid value): Error: %@", err); - } else { - NSLog(@"Step 13: TH sends Clear Year Day Schedule to DUT with a)YearDayIndex as 0(Invalid value) b)UserIndex as 0 (Invalid value): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAYearDayScheduleForTheFirstUser_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear a year day schedule for the first user: Error: %@", err); - } else { - NSLog(@"Clear a year day schedule for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUserWithUserIndex1_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user with UserIndex 1: Error: %@", err); - } else { - NSLog(@"Cleanup the created user with UserIndex 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUserWithUserIndex5_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:5U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user with UserIndex 5: Error: %@", err); - } else { - NSLog(@"Cleanup the created user with UserIndex 5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_8 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_8() - : TestCommandBridge("Test_TC_DRLK_2_8") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_8() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_8\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_8\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs0CredentialRuleAs0_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends Get User Command to DUT with UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep3ThSendsGetUserCommandToDutWithUserIndexAs1_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) CredentialRule as 3\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs10InvalidValueCredentialRuleAs3_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 CredentialRule as 0\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1SameAsStep2UserNameAsXxxUserUniqueIDAs8965UserStatusAs1UserTypeAs0CredentialRuleAs0_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6b: TH sends Get User Command to DUT with UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.C1a.Rsp && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep6bThSendsGetUserCommandToDutWithUserIndexAs2_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs2UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 8: TH sends Get User Command to DUT with the UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep8ThSendsGetUserCommandToDutWithTheUserIndexAs2_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 9: TH sends Clear User Command to DUT with the UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1d.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsClearUserCommandToDutWithTheUserIndexAs1_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 10: TH sends Get User Command to DUT with the UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep10ThSendsGetUserCommandToDutWithTheUserIndexAs1_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1d.Rsp")) { - NextTest(); - return; - } - err = TestTestCleanupThSendsClearUserCommandToDutWithTheUserIndexAs2_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestTestCleanupThSendsGetUserCommandToDutWithTheUserIndexAs2_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - VerifyOrReturn(CheckValue("clusterStatus present", status.mClusterStatus.HasValue(), true)); - VerifyOrReturn(CheckValue("clusterStatus value", status.mClusterStatus.Value(), 3)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull Current_NumberOfTotalUsersSupported; - - CHIP_ERROR TestStep1ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); - { - Current_NumberOfTotalUsersSupported = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs0CredentialRuleAs0_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsGetUserCommandToDutWithUserIndexAs1_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends Get User Command to DUT with UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends Get User Command to DUT with UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs10InvalidValueCredentialRuleAs3_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:10U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:3U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) CredentialRule as 3: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) CredentialRule as 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1SameAsStep2UserNameAsXxxUserUniqueIDAs8965UserStatusAs1UserTypeAs0CredentialRuleAs0_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:8965UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 CredentialRule as 0: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 CredentialRule as 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Error: %@", err); - } else { - NSLog(@"Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThSendsGetUserCommandToDutWithUserIndexAs2_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH sends Get User Command to DUT with UserIndex as 2: Error: %@", err); - } else { - NSLog(@"Step 6b: TH sends Get User Command to DUT with UserIndex as 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs2UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsGetUserCommandToDutWithTheUserIndexAs2_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends Get User Command to DUT with the UserIndex as 2: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends Get User Command to DUT with the UserIndex as 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsClearUserCommandToDutWithTheUserIndexAs1_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends Clear User Command to DUT with the UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends Clear User Command to DUT with the UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThSendsGetUserCommandToDutWithTheUserIndexAs1_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends Get User Command to DUT with the UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends Get User Command to DUT with the UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTestCleanupThSendsClearUserCommandToDutWithTheUserIndexAs2_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2: Error: %@", err); - } else { - NSLog(@"Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTestCleanupThSendsGetUserCommandToDutWithTheUserIndexAs2_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2: Error: %@", err); - } else { - NSLog(@"Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_11 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_11() - : TestCommandBridge("Test_TC_DRLK_2_11") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("PINCredentialData", &mPINCredentialData); - AddArgument("RFIDCredentialData", &mRFIDCredentialData); - AddArgument("FingerVeinCredentialData", &mFingerVeinCredentialData); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_11() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_11\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_11\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user with default parameters\n"); - err = TestPreconditionCreateNewUserWithDefaultParameters_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); - err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep1aThReadsNumberOfTotalUsersSupportedAndSavesForFutureUse_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1b: TH reads MinPINCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep1bThReadsMinPINCodeLengthAndSavesForFutureUse_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1c: TH reads MaxPINCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep1cThReadsMaxPINCodeLengthAndSavesForFutureUse_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1d: TH reads MinRFIDCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.A001a")) { - NextTest(); - return; - } - err = TestStep1dThReadsMinRFIDCodeLengthAndSavesForFutureUse_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1e: TH reads MaxRFIDCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.A0019")) { - NextTest(); - return; - } - err = TestStep1eThReadsMaxRFIDCodeLengthAndSavesForFutureUse_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2a: TH sends Set Credential Command to DUT with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { - NextTest(); - return; - } - err = TestStep2aThSendsSetCredentialCommandToDutWithTypePin_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2b: TH sends Set Credential Command to DUT with type RFID\n"); - if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { - NextTest(); - return; - } - err = TestStep2bThSendsSetCredentialCommandToDutWithTypeRfid_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2c: TH sends Set Credential Command to DUT with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { - NextTest(); - return; - } - err = TestStep2cThSendsSetCredentialCommandToDutWithTypeFingerVein_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3a: TH sends Get Credential Status Command with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep3aThSendsGetCredentialStatusCommandWithTypePin_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3b: TH sends Get Credential Status Command with type RFID\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep3bThSendsGetCredentialStatusCommandWithTypeRfid_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c: TH sends Get Credential Status Command with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep3cThSendsGetCredentialStatusCommandWithTypeFingerVein_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4a: TH sends Clear Credential Command to DUT with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsClearCredentialCommandToDutWithTypePin_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4b: TH sends Get Credential Status Command with type RFID\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep4bThSendsGetCredentialStatusCommandWithTypeRfid_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4c: TH sends Get Credential Status Command with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep4cThSendsGetCredentialStatusCommandWithTypeFingerVein_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4d: TH sends Clear Credential Command to DUT with type RFID\n"); - if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestStep4dThSendsClearCredentialCommandToDutWithTypeRfid_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4e: TH sends Get Credential Status Command with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep4eThSendsGetCredentialStatusCommandWithTypeFingerVein_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4f: TH sends Clear Credential Command to DUT with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestStep4fThSendsClearCredentialCommandToDutWithTypeFingerVein_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5a: TH sends Get Credential Status Command to DUT with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep5aThSendsGetCredentialStatusCommandToDutWithTypePin_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5b: TH sends Get Credential Status Command to DUT with type RFID\n"); - if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep5bThSendsGetCredentialStatusCommandToDutWithTypeRfid_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep5cThSendsGetCredentialStatusCommandToDutWithTypeFingerVein_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPINCredentialData; - chip::Optional mRFIDCredentialData; - chip::Optional mFingerVeinCredentialData; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionCreateNewUserWithDefaultParameters_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Create new user with default parameters: Error: %@", err); - } else { - NSLog(@"Precondition: Create new user with default parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Precondition: Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThReadsNumberOfTotalUsersSupportedAndSavesForFutureUse_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsMinPINCodeLengthAndSavesForFutureUse_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinPINCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads MinPINCodeLength and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads MinPINCodeLength and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("minPINCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minPINCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsMaxPINCodeLengthAndSavesForFutureUse_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxPINCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads MaxPINCodeLength and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads MaxPINCodeLength and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("maxPINCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxPINCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThReadsMinRFIDCodeLengthAndSavesForFutureUse_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinRFIDCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads MinRFIDCodeLength and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads MinRFIDCodeLength and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("minRFIDCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minRFIDCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eThReadsMaxRFIDCodeLengthAndSavesForFutureUse_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxRFIDCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH reads MaxRFIDCodeLength and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1e: TH reads MaxRFIDCodeLength and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("maxRFIDCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxRFIDCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsSetCredentialCommandToDutWithTypePin_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = mPINCredentialData.HasValue() ? [NSData dataWithBytes:mPINCredentialData.Value().data() length:mPINCredentialData.Value().size()] : [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Set Credential Command to DUT with type PIN: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Set Credential Command to DUT with type PIN: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsSetCredentialCommandToDutWithTypeRfid_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = mRFIDCredentialData.HasValue() ? [NSData dataWithBytes:mRFIDCredentialData.Value().data() length:mRFIDCredentialData.Value().size()] : [[NSData alloc] initWithBytes:"123456789A" length:10]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends Set Credential Command to DUT with type RFID: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends Set Credential Command to DUT with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThSendsSetCredentialCommandToDutWithTypeFingerVein_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = mFingerVeinCredentialData.HasValue() ? [NSData dataWithBytes:mFingerVeinCredentialData.Value().data() length:mFingerVeinCredentialData.Value().size()] : [[NSData alloc] initWithBytes:"123456789A" length:10]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH sends Set Credential Command to DUT with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 2c: TH sends Set Credential Command to DUT with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsGetCredentialStatusCommandWithTypePin_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends Get Credential Status Command with type PIN: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends Get Credential Status Command with type PIN: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendsGetCredentialStatusCommandWithTypeRfid_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends Get Credential Status Command with type RFID: Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends Get Credential Status Command with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThSendsGetCredentialStatusCommandWithTypeFingerVein_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH sends Get Credential Status Command with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 3c: TH sends Get Credential Status Command with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsClearCredentialCommandToDutWithTypePin_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends Clear Credential Command to DUT with type PIN: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends Clear Credential Command to DUT with type PIN: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThSendsGetCredentialStatusCommandWithTypeRfid_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH sends Get Credential Status Command with type RFID: Error: %@", err); - } else { - NSLog(@"Step 4b: TH sends Get Credential Status Command with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThSendsGetCredentialStatusCommandWithTypeFingerVein_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH sends Get Credential Status Command with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 4c: TH sends Get Credential Status Command with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThSendsClearCredentialCommandToDutWithTypeRfid_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH sends Clear Credential Command to DUT with type RFID: Error: %@", err); - } else { - NSLog(@"Step 4d: TH sends Clear Credential Command to DUT with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThSendsGetCredentialStatusCommandWithTypeFingerVein_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH sends Get Credential Status Command with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 4e: TH sends Get Credential Status Command with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThSendsClearCredentialCommandToDutWithTypeFingerVein_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH sends Clear Credential Command to DUT with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 4f: TH sends Clear Credential Command to DUT with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThSendsGetCredentialStatusCommandToDutWithTypePin_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH sends Get Credential Status Command to DUT with type PIN: Error: %@", err); - } else { - NSLog(@"Step 5a: TH sends Get Credential Status Command to DUT with type PIN: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThSendsGetCredentialStatusCommandToDutWithTypeRfid_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH sends Get Credential Status Command to DUT with type RFID: Error: %@", err); - } else { - NSLog(@"Step 5b: TH sends Get Credential Status Command to DUT with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThSendsGetCredentialStatusCommandToDutWithTypeFingerVein_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestGroupsCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestGroupsCluster() - : TestCommandBridge("TestGroupsCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestGroupsCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestGroupsCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestGroupsCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : View Group 0 (invalid)\n"); - err = TestViewGroup0Invalid_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : View First Group (not found)\n"); - err = TestViewFirstGroupNotFound_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Add First Group (no keys)\n"); - err = TestAddFirstGroupNoKeys_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Add KeySet\n"); - err = TestAddKeySet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Write Group Keys\n"); - err = TestWriteGroupKeys_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Add First Group (name too long)\n"); - err = TestAddFirstGroupNameTooLong_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Add First Group (new)\n"); - err = TestAddFirstGroupNew_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : View First Group (new)\n"); - err = TestViewFirstGroupNew_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : View Second Group (not found)\n"); - err = TestViewSecondGroupNotFound_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Get Group Membership 1 (all)\n"); - err = TestGetGroupMembership1All_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Add Second Group (new)\n"); - err = TestAddSecondGroupNew_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : View Second Group (new)\n"); - err = TestViewSecondGroupNew_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : View Group 3 (not found)\n"); - err = TestViewGroup3NotFound_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : View First Group (existing)\n"); - err = TestViewFirstGroupExisting_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : View Second Group (existing)\n"); - err = TestViewSecondGroupExisting_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Get Group Membership 2\n"); - err = TestGetGroupMembership2_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Remove Group 0 (invalid)\n"); - err = TestRemoveGroup0Invalid_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Remove Group 4 (not found)\n"); - err = TestRemoveGroup4NotFound_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Remove Second Group (existing)\n"); - err = TestRemoveSecondGroupExisting_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : View First Group (not removed)\n"); - err = TestViewFirstGroupNotRemoved_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : View Second Group (removed)\n"); - err = TestViewSecondGroupRemoved_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Get Group Membership 3\n"); - err = TestGetGroupMembership3_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Remove All\n"); - err = TestRemoveAll_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : View First Group (removed)\n"); - err = TestViewFirstGroupRemoved_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : View Second Group (still removed)\n"); - err = TestViewSecondGroupStillRemoved_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : View Group 3 (removed)\n"); - err = TestViewGroup3Removed_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Get Group Membership 4\n"); - err = TestGetGroupMembership4_27(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 28; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestViewGroup0Invalid_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:0U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Group 0 (invalid): Error: %@", err); - } else { - NSLog(@"View Group 0 (invalid): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 135U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupNotFound_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (not found): Error: %@", err); - } else { - NSLog(@"View First Group (not found): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddFirstGroupNoKeys_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - params.groupName = @"Group #1"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add First Group (no keys): Error: %@", err); - } else { - NSLog(@"Add First Group (no keys): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 126U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddKeySet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1110000ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1110001ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1110002ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add KeySet: Error: %@", err); - } else { - NSLog(@"Add KeySet: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteGroupKeys_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id groupKeyMapArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = - [NSNumber numberWithUnsignedShort:257U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupId = - [NSNumber numberWithUnsignedShort:258U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - groupKeyMapArgument = temp_0; - } - [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write Group Keys: Error: %@", err); - } else { - NSLog(@"Write Group Keys: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddFirstGroupNameTooLong_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - params.groupName = @"12345678901234567"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add First Group (name too long): Error: %@", err); - } else { - NSLog(@"Add First Group (name too long): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 135U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddFirstGroupNew_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - params.groupName = @"Group #101234567"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add First Group (new): Error: %@", err); - } else { - NSLog(@"Add First Group (new): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupNew_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (new): Error: %@", err); - } else { - NSLog(@"View First Group (new): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #101234567")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupNotFound_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (not found): Error: %@", err); - } else { - NSLog(@"View Second Group (not found): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetGroupMembership1All_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.groupList = temp_0; - } - [cluster getGroupMembershipWithParams:params completion: - ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Group Membership 1 (all): Error: %@", err); - } else { - NSLog(@"Get Group Membership 1 (all): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } - - { - id actualValue = values.groupList; - VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddSecondGroupNew_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - params.groupName = @"Group #2"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add Second Group (new): Error: %@", err); - } else { - NSLog(@"Add Second Group (new): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupNew_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (new): Error: %@", err); - } else { - NSLog(@"View Second Group (new): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #2")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewGroup3NotFound_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:32767U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Group 3 (not found): Error: %@", err); - } else { - NSLog(@"View Group 3 (not found): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 32767U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupExisting_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (existing): Error: %@", err); - } else { - NSLog(@"View First Group (existing): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #101234567")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupExisting_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (existing): Error: %@", err); - } else { - NSLog(@"View Second Group (existing): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #2")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetGroupMembership2_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedShort:258U]; - temp_0[1] = - [NSNumber numberWithUnsignedShort:259U]; - temp_0[2] = - [NSNumber numberWithUnsignedShort:32767U]; - params.groupList = temp_0; - } - [cluster getGroupMembershipWithParams:params completion: - ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Group Membership 2: Error: %@", err); - } else { - NSLog(@"Get Group Membership 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } - - { - id actualValue = values.groupList; - VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveGroup0Invalid_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterRemoveGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:0U]; - [cluster removeGroupWithParams:params completion: - ^(MTRGroupsClusterRemoveGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove Group 0 (invalid): Error: %@", err); - } else { - NSLog(@"Remove Group 0 (invalid): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 135U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveGroup4NotFound_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterRemoveGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:260U]; - [cluster removeGroupWithParams:params completion: - ^(MTRGroupsClusterRemoveGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove Group 4 (not found): Error: %@", err); - } else { - NSLog(@"Remove Group 4 (not found): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 260U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveSecondGroupExisting_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterRemoveGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster removeGroupWithParams:params completion: - ^(MTRGroupsClusterRemoveGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove Second Group (existing): Error: %@", err); - } else { - NSLog(@"Remove Second Group (existing): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupNotRemoved_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (not removed): Error: %@", err); - } else { - NSLog(@"View First Group (not removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #101234567")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupRemoved_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (removed): Error: %@", err); - } else { - NSLog(@"View Second Group (removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetGroupMembership3_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedShort:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedShort:257U]; - temp_0[2] = - [NSNumber numberWithUnsignedShort:258U]; - temp_0[3] = - [NSNumber numberWithUnsignedShort:3U]; - params.groupList = temp_0; - } - [cluster getGroupMembershipWithParams:params completion: - ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Group Membership 3: Error: %@", err); - } else { - NSLog(@"Get Group Membership 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } - - { - id actualValue = values.groupList; - VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveAll_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster removeAllGroupsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove All: Error: %@", err); - } else { - NSLog(@"Remove All: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupRemoved_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (removed): Error: %@", err); - } else { - NSLog(@"View First Group (removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupStillRemoved_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (still removed): Error: %@", err); - } else { - NSLog(@"View Second Group (still removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewGroup3Removed_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:32767U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Group 3 (removed): Error: %@", err); - } else { - NSLog(@"View Group 3 (removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 32767U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetGroupMembership4_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedShort:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedShort:257U]; - temp_0[2] = - [NSNumber numberWithUnsignedShort:258U]; - temp_0[3] = - [NSNumber numberWithUnsignedShort:3U]; - temp_0[4] = - [NSNumber numberWithUnsignedShort:32767U]; - params.groupList = temp_0; - } - [cluster getGroupMembershipWithParams:params completion: - ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Group Membership 4: Error: %@", err); - } else { - NSLog(@"Get Group Membership 4: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } - - { - id actualValue = values.groupList; - VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_G_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_G_1_1() - : TestCommandBridge("Test_TC_G_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_G_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_G_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_G_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !G.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given G.S.F00 ensure featuremap has the correct bit set\n"); - if (ShouldSkip("G.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenGsf00EnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenGsf00EnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given G.S.F00 ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given G.S.F00 ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestScenesFabricRemoval : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestScenesFabricRemoval() - : TestCommandBridge("TestScenesFabricRemoval") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("payload", &mPayload); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("waitAfterCommissioning", 0, UINT16_MAX, &mWaitAfterCommissioning); - AddArgument("PakeVerifier", &mPakeVerifier); - AddArgument("G1", 0, UINT16_MAX, &mG1); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestScenesFabricRemoval() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestScenesFabricRemoval\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestScenesFabricRemoval\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH1\n"); - err = TestCommissionDutToTh1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : TH1 reads the fabric index\n"); - err = TestTh1ReadsTheFabricIndex_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Waiting after opening commissioning window\n"); - err = TestWaitingAfterOpeningCommissioningWindow_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Commission from TH2\n"); - err = TestCommissionFromTh2_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for the commissioned device to be retrieved for TH2\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : TH2 reads the fabric index\n"); - err = TestTh2ReadsTheFabricIndex_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : TH1 sends a RemoveAllGroups command to DUT.\n"); - err = TestTh1SendsARemoveAllGroupsCommandToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : TH 1 Add Group KeySet.\n"); - err = TestTh1AddGroupKeySet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : TH1 Map KeySets to GroupId.\n"); - err = TestTh1MapKeySetsToGroupId_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : TH1 sends a AddGroup command to DUT for G1.\n"); - err = TestTh1SendsAAddGroupCommandToDutForG1_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Preparation step : TH2 Add Group KeySet.\n"); - err = TestPreparationStepTh2AddGroupKeySet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Preparation step TH2 Map KeySets to GroupId.\n"); - err = TestPreparationStepTh2MapKeySetsToGroupId_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : TH2 sends a AddGroup command to DUT for G1.\n"); - err = TestTh2SendsAAddGroupCommandToDutForG1_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : TH1 confirms its Scene table is empty and gets its capacity\n"); - err = TestTh1ConfirmsItsSceneTableIsEmptyAndGetsItsCapacity_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : TH2 confirms its Scene table is empty and has the same capacity as TH1\n"); - err = TestTh2ConfirmsItsSceneTableIsEmptyAndHasTheSameCapacityAsTh1_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : TH1 sends an AddScene command to DUT for Scene 1 G1\n"); - err = TestTh1SendsAnAddSceneCommandToDutForScene1G1_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : TH1 sends an AddScene command to DUT for Scene 2 G1\n"); - err = TestTh1SendsAnAddSceneCommandToDutForScene2G1_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : TH2 sends an AddScene command to DUT for Scene 1 G1\n"); - err = TestTh2SendsAnAddSceneCommandToDutForScene1G1_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : TH2 sends an AddScene command to DUT for Scene 2 G1\n"); - err = TestTh2SendsAnAddSceneCommandToDutForScene2G1_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : TH1 confirms its G1 holds 2 scenes\n"); - err = TestTh1ConfirmsItsG1Holds2Scenes_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : TH2 confirms its G1 holds 2 scenes\n"); - err = TestTh2ConfirmsItsG1Holds2Scenes_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : TH1 sends RemoveFabric command for TH2\n"); - err = TestTh1SendsRemoveFabricCommandForTh2_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : TH1 confirms its G1 still holds 2 scenes\n"); - err = TestTh1ConfirmsItsG1StillHolds2Scenes_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPayload; - chip::Optional mDiscriminator; - chip::Optional mWaitAfterCommissioning; - chip::Optional mPakeVerifier; - chip::Optional mG1; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToTh1_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull th1FabricIndex; - - CHIP_ERROR TestTh1ReadsTheFabricIndex_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 reads the fabric index: Error: %@", err); - } else { - NSLog(@"TH1 reads the fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th1FabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - params.pakePasscodeVerifier = mPakeVerifier.HasValue() ? [NSData dataWithBytes:mPakeVerifier.Value().data() length:mPakeVerifier.Value().size()] : [[NSData alloc] initWithBytes:"\xb9\x61\x70\xaa\xe8\x03\x34\x68\x84\x72\x4f\xe9\xa3\xb2\x87\xc3\x03\x30\xc2\xa6\x60\x37\x5d\x17\xbb\x20\x5a\x8c\xf1\xae\xcb\x35\x04\x57\xf8\xab\x79\xee\x25\x3a\xb6\xa8\xe4\x6b\xb0\x9e\x54\x3a\xe4\x22\x73\x6d\xe5\x01\xe3\xdb\x37\xd4\x41\xfe\x34\x49\x20\xd0\x95\x48\xe4\xc1\x82\x40\x63\x0c\x4f\xf4\x91\x3c\x53\x51\x38\x39\xb7\xc0\x7f\xcc\x06\x27\xa1\xb8\x57\x3a\x14\x9f\xcd\x1f\xa4\x66\xcf" length:97]; - params.discriminator = mDiscriminator.HasValue() ? [NSNumber numberWithUnsignedShort:mDiscriminator.Value()] : [NSNumber numberWithUnsignedShort:3840U]; - params.iterations = - [NSNumber numberWithUnsignedInt:1000UL]; - params.salt = - [[NSData alloc] initWithBytes:"SPAKE2P Key Salt" length:16]; - [cluster openCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitingAfterOpeningCommissioningWindow_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mWaitAfterCommissioning.HasValue() ? mWaitAfterCommissioning.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestCommissionFromTh2_4() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("beta", value); - } - NSNumber * _Nonnull th2FabricIndex; - - CHIP_ERROR TestTh2ReadsTheFabricIndex_6() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 reads the fabric index: Error: %@", err); - } else { - NSLog(@"TH2 reads the fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th2FabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsARemoveAllGroupsCommandToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster removeAllGroupsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends a RemoveAllGroups command to DUT.: Error: %@", err); - } else { - NSLog(@"TH1 sends a RemoveAllGroups command to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1AddGroupKeySet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1110000ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1110001ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1110002ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH 1 Add Group KeySet.: Error: %@", err); - } else { - NSLog(@"TH 1 Add Group KeySet.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1MapKeySetsToGroupId_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id groupKeyMapArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - groupKeyMapArgument = temp_0; - } - [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 Map KeySets to GroupId.: Error: %@", err); - } else { - NSLog(@"TH1 Map KeySets to GroupId.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsAAddGroupCommandToDutForG1_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.groupName = @"Group1"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends a AddGroup command to DUT for G1.: Error: %@", err); - } else { - NSLog(@"TH1 sends a AddGroup command to DUT for G1.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreparationStepTh2AddGroupKeySet_11() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:418U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1120000ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1120001ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1120002ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Preparation step : TH2 Add Group KeySet.: Error: %@", err); - } else { - NSLog(@"Preparation step : TH2 Add Group KeySet.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreparationStepTh2MapKeySetsToGroupId_12() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id groupKeyMapArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = - [NSNumber numberWithUnsignedShort:418U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - groupKeyMapArgument = temp_0; - } - [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Preparation step TH2 Map KeySets to GroupId.: Error: %@", err); - } else { - NSLog(@"Preparation step TH2 Map KeySets to GroupId.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2SendsAAddGroupCommandToDutForG1_13() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.groupName = @"Group1"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 sends a AddGroup command to DUT for G1.: Error: %@", err); - } else { - NSLog(@"TH2 sends a AddGroup command to DUT for G1.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable fabricCapacity; - - CHIP_ERROR TestTh1ConfirmsItsSceneTableIsEmptyAndGetsItsCapacity_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 confirms its Scene table is empty and gets its capacity: Error: %@", err); - } else { - NSLog(@"TH1 confirms its Scene table is empty and gets its capacity: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - fabricCapacity = values.capacity; - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2ConfirmsItsSceneTableIsEmptyAndHasTheSameCapacityAsTh1_15() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 confirms its Scene table is empty and has the same capacity as TH1: Error: %@", err); - } else { - NSLog(@"TH2 confirms its Scene table is empty and has the same capacity as TH1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.capacity; - if (fabricCapacity == nil) { - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); - VerifyOrReturn(CheckValue("Capacity", actualValue, fabricCapacity)); - } - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsAnAddSceneCommandToDutForScene1G1_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedInt:1UL]; - params.sceneName = @"Scene1"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends an AddScene command to DUT for Scene 1 G1: Error: %@", err); - } else { - NSLog(@"TH1 sends an AddScene command to DUT for Scene 1 G1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsAnAddSceneCommandToDutForScene2G1_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:2U]; - params.transitionTime = - [NSNumber numberWithUnsignedInt:0UL]; - params.sceneName = @"Scene2"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends an AddScene command to DUT for Scene 2 G1: Error: %@", err); - } else { - NSLog(@"TH1 sends an AddScene command to DUT for Scene 2 G1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2SendsAnAddSceneCommandToDutForScene1G1_18() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedInt:1000UL]; - params.sceneName = @"Scene1"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 sends an AddScene command to DUT for Scene 1 G1: Error: %@", err); - } else { - NSLog(@"TH2 sends an AddScene command to DUT for Scene 1 G1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2SendsAnAddSceneCommandToDutForScene2G1_19() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:2U]; - params.transitionTime = - [NSNumber numberWithUnsignedInt:0UL]; - params.sceneName = @"Scene2"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 sends an AddScene command to DUT for Scene 2 G1: Error: %@", err); - } else { - NSLog(@"TH2 sends an AddScene command to DUT for Scene 2 G1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1ConfirmsItsG1Holds2Scenes_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 confirms its G1 holds 2 scenes: Error: %@", err); - } else { - NSLog(@"TH1 confirms its G1 holds 2 scenes: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); - VerifyOrReturn(CheckValue("Capacity", actualValue, [fabricCapacity unsignedCharValue] - 2U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneList; - VerifyOrReturn(CheckValue("SceneList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2ConfirmsItsG1Holds2Scenes_21() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 confirms its G1 holds 2 scenes: Error: %@", err); - } else { - NSLog(@"TH2 confirms its G1 holds 2 scenes: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); - VerifyOrReturn(CheckValue("Capacity", actualValue, [fabricCapacity unsignedCharValue] - 2U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneList; - VerifyOrReturn(CheckValue("SceneList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsRemoveFabricCommandForTh2_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [th2FabricIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends RemoveFabric command for TH2: Error: %@", err); - } else { - NSLog(@"TH1 sends RemoveFabric command for TH2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1ConfirmsItsG1StillHolds2Scenes_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 confirms its G1 still holds 2 scenes: Error: %@", err); - } else { - NSLog(@"TH1 confirms its G1 still holds 2 scenes: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); - VerifyOrReturn(CheckValue("Capacity", actualValue, [fabricCapacity unsignedCharValue] - 2U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneList; - VerifyOrReturn(CheckValue("SceneList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_S_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_S_1_1() - : TestCommandBridge("Test_TC_S_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_S_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_S_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_S_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FeatureMap NameSupport bit (global attribute 65532)\n"); - if (ShouldSkip("(!S.S.F00)")) { - NextTest(); - return; - } - err = TestStep3ThReadsFeatureMapNameSupportBitGlobalAttribute65532_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads FeatureMap NameSupport bit (global attribute 65532)\n"); - if (ShouldSkip("(S.S.F00)")) { - NextTest(); - return; - } - err = TestStep3ThReadsFeatureMapNameSupportBitGlobalAttribute65532_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads AttributeList mandatory attributes(global attribute 65531)\n"); - if (ShouldSkip("S.S")) { - NextTest(); - return; - } - err = TestStep4ThReadsAttributeListMandatoryAttributesglobalAttribute65531_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute\n"); - if (ShouldSkip("S.S")) { - NextTest(); - return; - } - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6b: TH reads optional command(CopySceneResponse) AcceptedCommandList (global attribute 65529)\n"); - if (ShouldSkip("S.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsOptionalCommandCopySceneResponseAcceptedCommandListGlobalAttribute65529_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7a: TH reads from the DUT the GeneratedCommandList attribute\n"); - err = TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7b: Read optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528)\n"); - if (ShouldSkip("S.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep7bReadOptionalCommandCopySceneResponseInGeneratedCommandListGlobalAttribute65528_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapNameSupportBitGlobalAttribute65532_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap NameSupport bit (global attribute 65532): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap NameSupport bit (global attribute 65532): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapNameSupportBitGlobalAttribute65532_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap NameSupport bit (global attribute 65532): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap NameSupport bit (global attribute 65532): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAttributeListMandatoryAttributesglobalAttribute65531_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AttributeList mandatory attributes(global attribute 65531): Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AttributeList mandatory attributes(global attribute 65531): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsOptionalCommandCopySceneResponseAcceptedCommandListGlobalAttribute65529_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads optional command(CopySceneResponse) AcceptedCommandList (global attribute 65529): Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads optional command(CopySceneResponse) AcceptedCommandList (global attribute 65529): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bReadOptionalCommandCopySceneResponseInGeneratedCommandListGlobalAttribute65528_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: Read optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528): Error: %@", err); - } else { - NSLog(@"Step 7b: Read optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_S_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_S_2_1() - : TestCommandBridge("Test_TC_S_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_S_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_S_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_S_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the LastConfiguredBy attribute\n"); - if (ShouldSkip("S.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheLastConfiguredByAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the SceneTableSize attribute\n"); - if (ShouldSkip("S.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheSceneTableSizeAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the FabricSceneInfo attribute\n"); - if (ShouldSkip("S.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheFabricSceneInfoAttribute_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheLastConfiguredByAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLastConfiguredByWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the LastConfiguredBy attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the LastConfiguredBy attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lastConfiguredBy", "node_id", "node_id")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheSceneTableSizeAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSceneTableSizeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the SceneTableSize attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the SceneTableSize attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("sceneTableSize", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheFabricSceneInfoAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeFabricSceneInfoWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the FabricSceneInfo attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the FabricSceneInfo attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("fabricSceneInfo", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_S_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_S_2_4() - : TestCommandBridge("Test_TC_S_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("G1", 0, UINT16_MAX, &mG1); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_S_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_S_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_S_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a1 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 2220001 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 2220002\n"); - err = TestStep0aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutUsingAKeyThatIsPreInstalledOnTheThGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a12GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime022200005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime122200017EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime22220002_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH binds GroupId 0x0001 with GroupKeySetID 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster by writing the GroupKeyMap attribute with one entry as follows: List item 1: 1)FabricIndex: 1 2)GroupId: 0x0001 3)GroupKeySetId: 0x01a1\n"); - err = TestStep0bThBindsGroupId0x0001WithGroupKeySetID0x01a1InTheGroupKeyMapAttributeListOnGroupKeyManagementClusterByWritingTheGroupKeyMapAttributeWithOneEntryAsFollowsListItem11FabricIndex12GroupId0x00013GroupKeySetId0x01a1_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 0c: TH sends a RemoveAllGroups command to DUT.\n"); - if (ShouldSkip("G.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep0cThSendsARemoveAllGroupsCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends a AddGroup command to DUT with the GroupID field set to G1.\n"); - if (ShouldSkip("G.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsAAddGroupCommandToDutWithTheGroupIDFieldSetToG1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1.\n"); - if (ShouldSkip("S.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsARemoveAllScenesCommandToDutWithTheGroupIDFieldSetToG1_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x4E20 (20s) and no extension fields set.\n"); - if (ShouldSkip("S.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsAAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x4E2020sAndNoExtensionFieldsSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4b: TH sends a StoreScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.\n"); - if (ShouldSkip("S.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep4bThSendsAStoreSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 1s for level to change\n"); - err = TestWait1sForLevelToChange_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : TH confirm the DUT reached AC2 (on level control cluster) after 1s, which is different from AC1\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter1sWhichIsDifferentFromAc1_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: TH sends a RecallScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01 and the TransitionTime field omitted.\n"); - if (ShouldSkip("S.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep5bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldOmitted_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 20s\n"); - err = TestWait20s_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : TH confirm the DUT reached AC1 (on level control cluster) after 20s\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestThConfirmTheDutReachedAc1OnLevelControlClusterAfter20s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : DUT transitions to AC1 over 20s.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestDutTransitionsToAc1Over20s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && PICS_SC_RECALL_SCENE_TRANSITION_TIME_MS")) { - NextTest(); - return; - } - err = TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 6b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to 5000 (5s).\n"); - if (ShouldSkip("S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME_MS")) { - NextTest(); - return; - } - err = TestStep6bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetTo50005s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Wait 5s\n"); - if (ShouldSkip("S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME_MS")) { - NextTest(); - return; - } - err = TestWait5s_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : TH confirm the DUT reached AC2 (on level control cluster) after 5s\n"); - if (ShouldSkip("S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME_MS && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter5s_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : DUT transitions to AC1 over 5.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestDutTransitionsToAc1Over5_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 7b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to null (no transition time override).\n"); - if (ShouldSkip("S.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep7bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetToNullNoTransitionTimeOverride_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 8: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1\n"); - err = TestStep8ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a1_27(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 28; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mG1; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutUsingAKeyThatIsPreInstalledOnTheThGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a12GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime022200005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime122200017EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime22220002_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1110000ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1110001ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1110002ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a1 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 2220001 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 2220002: Error: %@", err); - } else { - NSLog(@"Step 0a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a1 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 2220001 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 2220002: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThBindsGroupId0x0001WithGroupKeySetID0x01a1InTheGroupKeyMapAttributeListOnGroupKeyManagementClusterByWritingTheGroupKeyMapAttributeWithOneEntryAsFollowsListItem11FabricIndex12GroupId0x00013GroupKeySetId0x01a1_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id groupKeyMapArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - groupKeyMapArgument = temp_0; - } - [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH binds GroupId 0x0001 with GroupKeySetID 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster by writing the GroupKeyMap attribute with one entry as follows: List item 1: 1)FabricIndex: 1 2)GroupId: 0x0001 3)GroupKeySetId: 0x01a1: Error: %@", err); - } else { - NSLog(@"Step 0b: TH binds GroupId 0x0001 with GroupKeySetID 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster by writing the GroupKeyMap attribute with one entry as follows: List item 1: 1)FabricIndex: 1 2)GroupId: 0x0001 3)GroupKeySetId: 0x01a1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0cThSendsARemoveAllGroupsCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster removeAllGroupsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0c: TH sends a RemoveAllGroups command to DUT.: Error: %@", err); - } else { - NSLog(@"Step 0c: TH sends a RemoveAllGroups command to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsAAddGroupCommandToDutWithTheGroupIDFieldSetToG1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.groupName = @"Group1"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends a AddGroup command to DUT with the GroupID field set to G1.: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends a AddGroup command to DUT with the GroupID field set to G1.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsARemoveAllScenesCommandToDutWithTheGroupIDFieldSetToG1_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterRemoveAllScenesParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster removeAllScenesWithParams:params completion: - ^(MTRScenesManagementClusterRemoveAllScenesResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1.: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsAAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x4E2020sAndNoExtensionFieldsSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedInt:20000UL]; - params.sceneName = @"Scene1"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x4E20 (20s) and no extension fields set.: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x4E20 (20s) and no extension fields set.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:100U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please configure AC1 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4bThSendsAStoreSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterStoreSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - [cluster storeSceneWithParams:params completion: - ^(MTRScenesManagementClusterStoreSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH sends a StoreScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH sends a StoreScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); - } else { - NSLog(@"Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1sForLevelToChange_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter1sWhichIsDifferentFromAc1_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 1s, which is different from AC1: Error: %@", err); - } else { - NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 1s, which is different from AC1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please configure AC2 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldOmitted_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterRecallSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - [cluster recallSceneWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH sends a RecallScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01 and the TransitionTime field omitted.: Error: %@", err); - } else { - NSLog(@"Step 5b: TH sends a RecallScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01 and the TransitionTime field omitted.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait20s_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 20500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThConfirmTheDutReachedAc1OnLevelControlClusterAfter20s_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH confirm the DUT reached AC1 (on level control cluster) after 20s: Error: %@", err); - } else { - NSLog(@"TH confirm the DUT reached AC1 (on level control cluster) after 20s: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutTransitionsToAc1Over20s_17() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please confirm that transition to AC1 was made over 20sgarbage: not in length on purpose", 55); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please configure AC2 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetTo50005s_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterRecallSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedInt:5000UL]; - [cluster recallSceneWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to 5000 (5s).: Error: %@", err); - } else { - NSLog(@"Step 6b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to 5000 (5s).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_21() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter5s_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 5s: Error: %@", err); - } else { - NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 5s: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutTransitionsToAc1Over5_23() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please confirm that transition to AC1 was made over 5sgarbage: not in length on purpose", 54); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); - } else { - NSLog(@"Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_25() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please configure AC2 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetToNullNoTransitionTimeOverride_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterRecallSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = nil; - [cluster recallSceneWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to null (no transition time override).: Error: %@", err); - } else { - NSLog(@"Step 7b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to null (no transition time override).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a1_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - [cluster keySetRemoveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1: Error: %@", err); - } else { - NSLog(@"Step 8: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestActivatedCarbonFilterMonitoring : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestActivatedCarbonFilterMonitoring() - : TestCommandBridge("TestActivatedCarbonFilterMonitoring") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestActivatedCarbonFilterMonitoring() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestActivatedCarbonFilterMonitoring\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestActivatedCarbonFilterMonitoring\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Validate the feature map\n"); - err = TestValidateTheFeatureMap_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read Replacement Product List\n"); - err = TestReadReplacementProductList_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestValidateTheFeatureMap_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate the feature map: Error: %@", err); - } else { - NSLog(@"Validate the feature map: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadReplacementProductList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Replacement Product List: Error: %@", err); - } else { - NSLog(@"Read Replacement Product List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ReplacementProductList", [actualValue count], static_cast(5))); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierType, 0U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierValue, @"111112222233")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierType, 1U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierValue, @"gtin8xxx")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierType, 2U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierValue, @"4444455555666")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierType, 3U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierValue, @"gtin14xxxxxxxx")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierType, 4U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierValue, @"oem20xxxxxxxxxxxxxxx")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestHepaFilterMonitoring : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestHepaFilterMonitoring() - : TestCommandBridge("TestHepaFilterMonitoring") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestHepaFilterMonitoring() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestHepaFilterMonitoring\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestHepaFilterMonitoring\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Validate the feature map\n"); - err = TestValidateTheFeatureMap_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read Replacement Product List\n"); - err = TestReadReplacementProductList_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestValidateTheFeatureMap_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate the feature map: Error: %@", err); - } else { - NSLog(@"Validate the feature map: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadReplacementProductList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Replacement Product List: Error: %@", err); - } else { - NSLog(@"Read Replacement Product List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ReplacementProductList", [actualValue count], static_cast(5))); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierType, 0U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierValue, @"111112222233")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierType, 1U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierValue, @"gtin8xxx")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierType, 2U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierValue, @"4444455555666")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierType, 3U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierValue, @"gtin14xxxxxxxx")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierType, 4U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierValue, @"oem20xxxxxxxxxxxxxxx")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACFREMON_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACFREMON_1_1() - : TestCommandBridge("Test_TC_ACFREMON_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACFREMON_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACFREMON_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACFREMON_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!ACFREMON.S.F00 && !ACFREMON.S.F01 && !ACFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given ACFREMON.S.F00(Condition) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("ACFREMON.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenACFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given ACFREMON.S.F01(Warning) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("ACFREMON.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenACFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given ACFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("ACFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenACFREMONSF02ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: TH reads the feature dependent(ACFREMON.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("ACFREMON.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentACFREMONSF00AttributeInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH reads the optional attribute InPlaceIndicator (ACFREMON.S.A0003) in AttributeList\n"); - if (ShouldSkip("ACFREMON.S.A0003")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorAcfremonsa0003InAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: TH reads the optional attribute LastChangedTime (ACFREMON.S.A0004) in AttributeList\n"); - if (ShouldSkip("ACFREMON.S.A0004")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeLastChangedTimeAcfremonsa0004InAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4e: TH reads the optional attribute ReplacementProductList (ACFREMON.S.F02) in AttributeList\n"); - if (ShouldSkip("ACFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeReplacementProductListAcfremonsf02InAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); - if (ShouldSkip("!ACFREMON.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6b: TH reads the optional command (ResetCondition) in AcceptedCommandList\n"); - if (ShouldSkip("ACFREMON.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 16; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenACFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given ACFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given ACFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenACFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given ACFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given ACFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenACFREMONSF02ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given ACFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given ACFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentACFREMONSF00AttributeInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the feature dependent(ACFREMON.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the feature dependent(ACFREMON.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorAcfremonsa0003InAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (ACFREMON.S.A0003) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (ACFREMON.S.A0003) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeLastChangedTimeAcfremonsa0004InAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (ACFREMON.S.A0004) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (ACFREMON.S.A0004) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeReplacementProductListAcfremonsf02InAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (ACFREMON.S.F02) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (ACFREMON.S.F02) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the optional command (ResetCondition) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the optional command (ResetCondition) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACFREMON_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACFREMON_2_1() - : TestCommandBridge("Test_TC_ACFREMON_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACFREMON_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACFREMON_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACFREMON_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the Condition attribute.\n"); - if (ShouldSkip("ACFREMON.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheConditionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the DegradationDirection attribute..\n"); - if (ShouldSkip("ACFREMON.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the ChangeIndication attribute.\n"); - if (ShouldSkip("ACFREMON.S.A0002 && !ACFREMON.S.F01")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheChangeIndicationAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4b: TH reads from the DUT the ChangeIndication attribute.\n"); - if (ShouldSkip("ACFREMON.S.F01 && ACFREMON.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheChangeIndicationAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the InPlaceIndicator attribute\n"); - if (ShouldSkip("ACFREMON.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the LastChangedTime attribute\n"); - if (ShouldSkip("ACFREMON.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the ReplacementProductList attribute\n"); - if (ShouldSkip("ACFREMON.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheConditionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConditionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("condition", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("condition", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("condition", [value unsignedCharValue], 100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDegradationDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("degradationDirection", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("degradationDirection", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("degradationDirection", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheChangeIndicationAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChangeIndicationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the ChangeIndication attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the ChangeIndication attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("changeIndication", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheChangeIndicationAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChangeIndicationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the ChangeIndication attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the ChangeIndication attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ChangeIndication", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("changeIndication", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInPlaceIndicatorWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("inPlaceIndicator", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLastChangedTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lastChangedTime", "epoch_s", "epoch_s")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("replacementProductList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_HEPAFREMON_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_HEPAFREMON_1_1() - : TestCommandBridge("Test_TC_HEPAFREMON_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_HEPAFREMON_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_HEPAFREMON_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_HEPAFREMON_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!HEPAFREMON.S.F00 && !HEPAFREMON.S.F01 && !HEPAFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given HEPAFREMON.S.F00(Condition) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("HEPAFREMON.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenHEPAFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given HEPAFREMON.S.F01(Warning) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("HEPAFREMON.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenHEPAFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given HEPAFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("HEPAFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenHEPAFREMONSF02ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: TH reads the feature dependent(HEPAFREMON.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("HEPAFREMON.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentHEPAFREMONSF00AttributeInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH reads the optional attribute InPlaceIndicator (HEPAFREMON.S.A0003) in AttributeList\n"); - if (ShouldSkip("HEPAFREMON.S.A0003")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorHepafremonsa0003InAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: TH reads the optional attribute LastChangedTime (HEPAFREMON.S.A0004) in AttributeList\n"); - if (ShouldSkip("HEPAFREMON.S.A0004")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeLastChangedTimeHepafremonsa0004InAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4e: TH reads the optional attribute ReplacementProductList (HEPAFREMON.S.F02) in AttributeList\n"); - if (ShouldSkip("HEPAFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeReplacementProductListHepafremonsf02InAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - if (ShouldSkip("!HEPAFREMON.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6: TH reads the optional command (ResetCondition) in AcceptedCommandList\n"); - if (ShouldSkip("HEPAFREMON.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 16; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenHEPAFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given HEPAFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given HEPAFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenHEPAFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given HEPAFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given HEPAFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenHEPAFREMONSF02ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given HEPAFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given HEPAFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentHEPAFREMONSF00AttributeInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the feature dependent(HEPAFREMON.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the feature dependent(HEPAFREMON.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorHepafremonsa0003InAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (HEPAFREMON.S.A0003) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (HEPAFREMON.S.A0003) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeLastChangedTimeHepafremonsa0004InAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (HEPAFREMON.S.A0004) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (HEPAFREMON.S.A0004) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeReplacementProductListHepafremonsf02InAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (HEPAFREMON.S.F02) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (HEPAFREMON.S.F02) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the optional command (ResetCondition) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the optional command (ResetCondition) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_HEPAFREMON_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_HEPAFREMON_2_1() - : TestCommandBridge("Test_TC_HEPAFREMON_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_HEPAFREMON_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_HEPAFREMON_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_HEPAFREMON_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the Condition attribute.\n"); - if (ShouldSkip("HEPAFREMON.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheConditionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the DegradationDirection attribute..\n"); - if (ShouldSkip("HEPAFREMON.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the ChangeIndication attribute.\n"); - if (ShouldSkip("HEPAFREMON.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheChangeIndicationAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the InPlaceIndicator attribute\n"); - if (ShouldSkip("HEPAFREMON.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the LastChangedTime attribute\n"); - if (ShouldSkip("HEPAFREMON.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the ReplacementProductList attribute\n"); - if (ShouldSkip("HEPAFREMON.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheConditionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConditionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("condition", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("condition", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("condition", [value unsignedCharValue], 100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDegradationDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("degradationDirection", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("degradationDirection", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("degradationDirection", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheChangeIndicationAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChangeIndicationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the ChangeIndication attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the ChangeIndication attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("changeIndication", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("changeIndication", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("changeIndication", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInPlaceIndicatorWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("inPlaceIndicator", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLastChangedTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lastChangedTime", "epoch_s", "epoch_s")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("replacementProductList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -#endif // CONFIG_ENABLE_YAML_TESTS - -void registerCommandsTests(Commands & commands) -{ - const char * clusterName = "Tests"; - - commands_list clusterCommands = { -#if CONFIG_ENABLE_YAML_TESTS - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), -#endif // CONFIG_ENABLE_YAML_TESTS - }; - - commands.RegisterCommandSet(clusterName, clusterCommands, "Commands for running YAML tests."); -} diff --git a/zzz_generated/placeholder/app1/zap-generated/test/Commands.h b/zzz_generated/placeholder/app1/zap-generated/test/Commands.h index 35de801fb5d94d..fd7e5da8588d13 100644 --- a/zzz_generated/placeholder/app1/zap-generated/test/Commands.h +++ b/zzz_generated/placeholder/app1/zap-generated/test/Commands.h @@ -21,7 +21,7 @@ #include "TestCommand.h" -#include +#include class Test_TC_WNCV_5_1_SimulatedSuite : public TestCommand { diff --git a/zzz_generated/placeholder/app2/zap-generated/test/Commands.h b/zzz_generated/placeholder/app2/zap-generated/test/Commands.h index 35de801fb5d94d..fd7e5da8588d13 100644 --- a/zzz_generated/placeholder/app2/zap-generated/test/Commands.h +++ b/zzz_generated/placeholder/app2/zap-generated/test/Commands.h @@ -21,7 +21,7 @@ #include "TestCommand.h" -#include +#include class Test_TC_WNCV_5_1_SimulatedSuite : public TestCommand {